How can i read a file by javascript

How can i read a file by javascript
0.0 0


I try the CCFileUtils

var content = cc.FileUtils.getInstance().getFileData(file, “rb”, 0);
// content 0 ?

but the response is nothing.

and view jsb_cocos2dx_auto.cpp

JSBool js\_cocos2dx\_CCFileUtils\_getFileData(JSContext \*cx, uint32\_t argc, jsval \*vp)
    jsval \*argv = JS\_ARGV(cx, vp);
    JSBool ok = JS\_TRUE;
    JSObject \*obj = JS\_THIS\_OBJECT(cx, vp);
    js\_proxy\_t \*proxy; JS\_GET\_NATIVE\_PROXY(proxy, obj);
    cocos2d::CCFileUtils\* cobj = (cocos2d::CCFileUtils \*)(proxy ? proxy-\>ptr : NULL);
    JSB\_PRECONDITION2( cobj, cx, JS\_FALSE, "Invalid Native Object");
    if (argc  3) {

const char* arg0;
const char* arg1;
unsigned long* arg2;
std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str();
* #pragma warning NO CONVERSION TO NATIVE FOR unsigned long**;
unsigned char** ret = cobj->getFileData(arg0, arg1, arg2);
jsval jsret;
* #pragma warning NO CONVERSION FROM NATIVE FOR unsigned char*;
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;

JS_ReportError(cx, “wrong number of arguments: d, was expecting d”, argc, 3);
return JS_FALSE;

is that mean the CCFileUtils is incomplete?


I want to use CCFileUtils for read a zip file
but when i call getFileDataFromZip
the app crash


You could get the byte array from *cc.FileUtils.getInstance().getByteArrayFromFile(filename)*