From 19e13c2de7065201c9a5a54e9a1a5409ed4a4cdc Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 23 Dec 2015 08:31:40 -0800 Subject: [PATCH] Provide access to errno (though not from console). --- Execute.cpp | 6 ++++++ libcycript.cy | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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); -- 2.47.2