MCPcopy Create free account
hub / github.com/buke/quickjs-go / js_os_readlink

Function js_os_readlink

deps/quickjs/quickjs-libc.c:3419–3440  ·  view source on GitHub ↗

return [path, errorcode] */

Source from the content-addressed store, hash-verified

3417
3418/* return [path, errorcode] */
3419static 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
3442static char **build_envp(JSContext *ctx, JSValue obj)
3443{

Callers

nothing calls this directly

Calls 2

JS_ToCStringFunction · 0.85
make_string_errorFunction · 0.85

Tested by

no test coverage detected