From: Jay Freeman (saurik) Date: Wed, 23 Dec 2015 16:31:40 +0000 (-0800) Subject: Provide access to errno (though not from console). X-Git-Tag: v0.9.590~142 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/19e13c2de7065201c9a5a54e9a1a5409ed4a4cdc Provide access to errno (though not from console). --- diff --git a/Execute.cpp b/Execute.cpp index 7b3f2f2..be79e00 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1147,6 +1147,9 @@ extern "C" const char *CYBridgeHash(CYPool &pool, CYUTF8String name) { } static bool All_hasProperty(JSContextRef context, JSObjectRef object, JSStringRef property) { + if (JSStringIsEqualToUTF8CString(property, "errno")) + return true; + JSObjectRef global(CYGetGlobalObject(context)); JSObjectRef cycript(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Cycript")))); JSObjectRef alls(CYCastJSObject(context, CYGetProperty(context, cycript, CYJSString("alls")))); @@ -1164,6 +1167,9 @@ static bool All_hasProperty(JSContextRef context, JSObjectRef object, JSStringRe } static JSValueRef All_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry { + if (JSStringIsEqualToUTF8CString(property, "errno")) + return CYCastJSValue(context, errno); + JSObjectRef global(CYGetGlobalObject(context)); JSObjectRef cycript(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Cycript")))); JSObjectRef alls(CYCastJSObject(context, CYGetProperty(context, cycript, CYJSString("alls")))); diff --git a/libcycript.cy b/libcycript.cy index a079383..79a1735 100644 --- a/libcycript.cy +++ b/libcycript.cy @@ -159,7 +159,7 @@ require.resolve = function(name) { var _syscall = function(value) { if (value == -1) - throw new Error("system call failed"); + throw new Error(strerror(errno)); }; var info = *new (struct stat);