|
@ -47,8 +47,6 @@ |
|
|
#include <unistd.h> /* setuid, getuid */ |
|
|
#include <unistd.h> /* setuid, getuid */ |
|
|
#else |
|
|
#else |
|
|
#include <direct.h> |
|
|
#include <direct.h> |
|
|
#define chdir _chdir |
|
|
|
|
|
#define getcwd _getcwd |
|
|
|
|
|
#include <process.h> |
|
|
#include <process.h> |
|
|
#define getpid _getpid |
|
|
#define getpid _getpid |
|
|
#include <io.h> |
|
|
#include <io.h> |
|
@ -1231,10 +1229,10 @@ static Handle<Value> Chdir(const Arguments& args) { |
|
|
|
|
|
|
|
|
String::Utf8Value path(args[0]->ToString()); |
|
|
String::Utf8Value path(args[0]->ToString()); |
|
|
|
|
|
|
|
|
int r = chdir(*path); |
|
|
uv_err_t r = uv_chdir(*path); |
|
|
|
|
|
|
|
|
if (r != 0) { |
|
|
if (r.code != UV_OK) { |
|
|
return ThrowException(Exception::Error(String::New(strerror(errno)))); |
|
|
return ThrowException(UVException(r.code, "uv_chdir")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return Undefined(); |
|
|
return Undefined(); |
|
@ -1243,18 +1241,25 @@ static Handle<Value> Chdir(const Arguments& args) { |
|
|
|
|
|
|
|
|
static Handle<Value> Cwd(const Arguments& args) { |
|
|
static Handle<Value> Cwd(const Arguments& args) { |
|
|
HandleScope scope; |
|
|
HandleScope scope; |
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
/* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */ |
|
|
|
|
|
char buf[MAX_PATH * 4 + 1]; |
|
|
|
|
|
#else |
|
|
|
|
|
char buf[PATH_MAX + 1]; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
char *r = getcwd(getbuf, ARRAY_SIZE(getbuf) - 1); |
|
|
uv_err_t r = uv_cwd(buf, ARRAY_SIZE(buf) - 1); |
|
|
if (r == NULL) { |
|
|
if (r.code != UV_OK) { |
|
|
return ThrowException(Exception::Error(String::New(strerror(errno)))); |
|
|
return ThrowException(UVException(r.code, "uv_cwd")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getbuf[ARRAY_SIZE(getbuf) - 1] = '\0'; |
|
|
buf[ARRAY_SIZE(buf) - 1] = '\0'; |
|
|
Local<String> cwd = String::New(r); |
|
|
Local<String> cwd = String::New(buf); |
|
|
|
|
|
|
|
|
return scope.Close(cwd); |
|
|
return scope.Close(cwd); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
#ifdef _WIN32 |
|
|
static Handle<Value> CwdForDrive(const Arguments& args) { |
|
|
static Handle<Value> CwdForDrive(const Arguments& args) { |
|
|
HandleScope scope; |
|
|
HandleScope scope; |
|
|