diff options
author | Bert Belder <bertbelder@gmail.com> | 2011-09-09 15:05:12 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2011-09-09 15:05:12 +0200 |
commit | 97cf216c74796e7f6dbc65e346ce69cbb160c67f (patch) | |
tree | e30e261bca3689e589cabe9951f7fd2d9c03b6e8 /deps/uv/src/win/fs.c | |
parent | b5db0767d515d1a372d2bf97c0c44d00c4623eaa (diff) | |
download | node-new-97cf216c74796e7f6dbc65e346ce69cbb160c67f.tar.gz |
Upgrade libuv to e95a29ee18
Diffstat (limited to 'deps/uv/src/win/fs.c')
-rw-r--r-- | deps/uv/src/win/fs.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index 92a9842855..b1952056bf 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -82,6 +82,17 @@ req->last_error = error; \ req->flags |= UV_FS_LAST_ERROR_SET; +#define SET_REQ_RESULT(req, result_value) \ + req->result = (result_value); \ + if (req->result == -1) { \ + req->errorno = uv_translate_sys_error(_doserrno); \ + } + +#define SET_REQ_RESULT_WIN32_ERROR(req, sys_errno) \ + req->result = -1; \ + req->errorno = uv_translate_sys_error(sys_errno); \ + SET_REQ_LAST_ERROR(req, sys_errno); + void uv_fs_init() { _fmode = _O_BINARY; @@ -227,8 +238,8 @@ void fs__open(uv_fs_t* req, const char* path, int flags, int mode) { attributes, NULL); if (file == INVALID_HANDLE_VALUE) { - result = -1; - goto end; + SET_REQ_RESULT_WIN32_ERROR(req, GetLastError()); + return; } result = _open_osfhandle((intptr_t)file, flags); end: @@ -356,9 +367,8 @@ void fs__readdir(uv_fs_t* req, const char* path, int flags) { free(path2); if(dir == INVALID_HANDLE_VALUE) { - result = -1; - SET_REQ_LAST_ERROR(req, GetLastError()); - goto done; + SET_REQ_RESULT_WIN32_ERROR(req, GetLastError()); + return; } buf = (char*)malloc(buf_size); @@ -439,9 +449,10 @@ void fs__rename(uv_fs_t* req, const char* path, const char* new_path) { void fs__fsync(uv_fs_t* req, uv_file file) { int result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1; if (result == -1) { - SET_REQ_LAST_ERROR(req, GetLastError()); + SET_REQ_RESULT_WIN32_ERROR(req, GetLastError()); + } else { + SET_REQ_RESULT(req, result); } - SET_REQ_RESULT(req, result); } @@ -560,9 +571,10 @@ void fs__futime(uv_fs_t* req, uv_file file, double atime, double mtime) { void fs__link(uv_fs_t* req, const char* path, const char* new_path) { int result = CreateHardLinkA(new_path, path, NULL) ? 0 : -1; if (result == -1) { - SET_REQ_LAST_ERROR(req, GetLastError()); + SET_REQ_RESULT_WIN32_ERROR(req, GetLastError()); + } else { + SET_REQ_RESULT(req, result); } - SET_REQ_RESULT(req, result); } @@ -589,7 +601,7 @@ void fs__readlink(uv_fs_t* req, const char* path) { int result = -1; BOOL rv; HANDLE symlink; - void* buffer; + void* buffer = NULL; DWORD bytes_returned; REPARSE_DATA_BUFFER* reparse_data; int utf8size; |