Implement Process.cwd (#41)
* Implement `Process.cwd` * Update `os` test suite
This commit is contained in:
+17
-1
@@ -1,4 +1,5 @@
|
||||
#include "os.h"
|
||||
#include "uv.h"
|
||||
#include "wren.h"
|
||||
|
||||
#if __APPLE__
|
||||
@@ -68,4 +69,19 @@ void processAllArguments(WrenVM* vm)
|
||||
wrenSetSlotString(vm, 1, args[i]);
|
||||
wrenInsertInList(vm, 0, -1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void processCwd(WrenVM* vm)
|
||||
{
|
||||
wrenEnsureSlots(vm, 1);
|
||||
|
||||
char buffer[PATH_MAX * 4];
|
||||
size_t length = sizeof(buffer);
|
||||
if (uv_cwd(buffer, &length) != 0)
|
||||
{
|
||||
wrenSetSlotString(vm, 0, "Cannot get current working directory.");
|
||||
return wrenAbortFiber(vm, 0);
|
||||
}
|
||||
|
||||
wrenSetSlotString(vm, 0, buffer);
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@ class Process {
|
||||
static arguments { allArguments[2..-1] }
|
||||
|
||||
foreign static allArguments
|
||||
foreign static cwd
|
||||
}
|
||||
|
||||
@@ -12,4 +12,5 @@ static const char* osModuleSource =
|
||||
" static arguments { allArguments[2..-1] }\n"
|
||||
"\n"
|
||||
" foreign static allArguments\n"
|
||||
" foreign static cwd\n"
|
||||
"}\n";
|
||||
|
||||
Reference in New Issue
Block a user