subdirectory support

This commit is contained in:
Nishi 2026-05-10 00:22:00 +09:00
commit 96f3fa1f70
Signed by: nishi
GPG key ID: 27EF69B208EB9343
9 changed files with 109 additions and 29 deletions

View file

@ -95,6 +95,15 @@ static duk_ret_t js_fs_close(duk_context* self) {
return 0;
}
static duk_ret_t js_fs_cwd(duk_context* self) {
char path[1024];
getcwd(path, 1024);
duk_push_string(self, path);
return 1;
}
void js_fs_init(void) {
int obj;
@ -112,5 +121,8 @@ void js_fs_init(void) {
duk_push_c_function(js_ctx, js_fs_close, 1);
duk_put_prop_string(js_ctx, obj, "close");
duk_push_c_function(js_ctx, js_fs_cwd, 0);
duk_put_prop_string(js_ctx, obj, "cwd");
duk_put_prop_string(js_ctx, 0, "fs");
}