feat: implement Process.cwd foreign method using libuv uv_cwd
Add a new `Process.cwd` static method that retrieves the current working directory via libuv's `uv_cwd` function. The implementation includes proper error handling that aborts the fiber with a descriptive message on failure. The foreign method is registered in the module table and exposed in the Wren API with a foreign static declaration. A test suite validates that the returned value is a non-empty string starting with "/", resolves correctly via `File.realPath`, and corresponds to an existing directory.
This commit is contained in:
@@ -25,6 +25,7 @@ extern void fileWriteBytes(WrenVM* vm);
|
||||
extern void platformIsPosix(WrenVM* vm);
|
||||
extern void platformName(WrenVM* vm);
|
||||
extern void processAllArguments(WrenVM* vm);
|
||||
extern void processCwd(WrenVM* vm);
|
||||
extern void statPath(WrenVM* vm);
|
||||
extern void statBlockCount(WrenVM* vm);
|
||||
extern void statBlockSize(WrenVM* vm);
|
||||
@@ -165,6 +166,7 @@ static ModuleRegistry modules[] =
|
||||
END_CLASS
|
||||
CLASS(Process)
|
||||
STATIC_METHOD("allArguments", processAllArguments)
|
||||
STATIC_METHOD("cwd", processCwd)
|
||||
END_CLASS
|
||||
END_MODULE
|
||||
MODULE(repl)
|
||||
|
||||
Reference in New Issue
Block a user