return [path, errorcode] */
| 3417 | |
| 3418 | /* return [path, errorcode] */ |
| 3419 | static JSValue js_os_readlink(JSContext *ctx, JSValueConst this_val, |
| 3420 | int argc, JSValueConst *argv) |
| 3421 | { |
| 3422 | const char *path; |
| 3423 | char buf[JS__PATH_MAX]; |
| 3424 | int err; |
| 3425 | ssize_t res; |
| 3426 | |
| 3427 | path = JS_ToCString(ctx, argv[0]); |
| 3428 | if (!path) |
| 3429 | return JS_EXCEPTION; |
| 3430 | res = readlink(path, buf, sizeof(buf) - 1); |
| 3431 | if (res < 0) { |
| 3432 | buf[0] = '\0'; |
| 3433 | err = errno; |
| 3434 | } else { |
| 3435 | buf[res] = '\0'; |
| 3436 | err = 0; |
| 3437 | } |
| 3438 | JS_FreeCString(ctx, path); |
| 3439 | return make_string_error(ctx, buf, err); |
| 3440 | } |
| 3441 | |
| 3442 | static char **build_envp(JSContext *ctx, JSValue obj) |
| 3443 | { |
nothing calls this directly
no test coverage detected