diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-09-14 13:46:07 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-09-14 13:46:54 -0700 |
commit | a6ef3eb271833721e40938205a4894d9823db237 (patch) | |
tree | 4edf86eeb2e3763a09992866a1ace99ad77ced2a /deps/uv/src/win/fs.c | |
parent | 70966002c05b5da594c219c080207c12709bb8eb (diff) | |
download | node-new-a6ef3eb271833721e40938205a4894d9823db237.tar.gz |
Upgrade libuv to 4197fc7
and use return value from sync uv_fs functions
Diffstat (limited to 'deps/uv/src/win/fs.c')
-rw-r--r-- | deps/uv/src/win/fs.c | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index b1952056bf..93fa5eb36b 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -133,7 +133,6 @@ static void uv_fs_req_init_sync(uv_loop_t* loop, uv_fs_t* req, void fs__open(uv_fs_t* req, const char* path, int flags, int mode) { DWORD access; DWORD share; - SECURITY_ATTRIBUTES sa; DWORD disposition; DWORD attributes; HANDLE file; @@ -168,14 +167,6 @@ void fs__open(uv_fs_t* req, const char* path, int flags, int mode) { */ share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = NULL; - if (flags & _O_NOINHERIT) { - sa.bInheritHandle = FALSE; - } else { - sa.bInheritHandle = TRUE; - } - switch (flags & (_O_CREAT | _O_EXCL | _O_TRUNC)) { case 0: case _O_EXCL: @@ -233,7 +224,7 @@ void fs__open(uv_fs_t* req, const char* path, int flags, int mode) { file = CreateFileA(path, access, share, - &sa, + NULL, disposition, attributes, NULL); @@ -407,7 +398,6 @@ void fs__readdir(uv_fs_t* req, const char* path, int flags) { req->ptr = buf; req->flags |= UV_FS_FREE_PTR; -done: SET_REQ_RESULT(req, result); } @@ -605,6 +595,8 @@ void fs__readlink(uv_fs_t* req, const char* path) { DWORD bytes_returned; REPARSE_DATA_BUFFER* reparse_data; int utf8size; + wchar_t* substitute_name; + int substitute_name_length; symlink = CreateFileA(path, 0, @@ -648,8 +640,17 @@ void fs__readlink(uv_fs_t* req, const char* path) { goto done; } - utf8size = uv_utf16_to_utf8(reparse_data->SymbolicLinkReparseBuffer.PathBuffer + (reparse_data->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t)), - reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t), + substitute_name = reparse_data->SymbolicLinkReparseBuffer.PathBuffer + (reparse_data->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t)); + substitute_name_length = reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t); + + /* Strip off the leading \??\ from the substitute name buffer.*/ + if (memcmp(substitute_name, L"\\??\\", 8) == 0) { + substitute_name += 4; + substitute_name_length -= 4; + } + + utf8size = uv_utf16_to_utf8(substitute_name, + substitute_name_length, NULL, 0); if (!utf8size) { @@ -663,10 +664,8 @@ void fs__readlink(uv_fs_t* req, const char* path) { uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); } - req->flags |= UV_FS_FREE_PTR; - - utf8size = uv_utf16_to_utf8(reparse_data->SymbolicLinkReparseBuffer.PathBuffer + (reparse_data->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t)), - reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t), + utf8size = uv_utf16_to_utf8(substitute_name, + substitute_name_length, req->ptr, utf8size); if (!utf8size) { @@ -675,6 +674,7 @@ void fs__readlink(uv_fs_t* req, const char* path) { goto done; } + req->flags |= UV_FS_FREE_PTR; ((char*)req->ptr)[utf8size] = '\0'; result = 0; @@ -805,6 +805,7 @@ int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_req_init_sync(loop, req, UV_FS_OPEN); fs__open(req, path, flags, mode); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -820,6 +821,7 @@ int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { uv_fs_req_init_sync(loop, req, UV_FS_CLOSE); fs__close(req, file); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -836,6 +838,7 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, uv_fs_req_init_sync(loop, req, UV_FS_READ); fs__read(req, file, buf, length, offset); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -852,6 +855,7 @@ int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, uv_fs_req_init_sync(loop, req, UV_FS_WRITE); fs__write(req, file, buf, length, offset); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -867,6 +871,7 @@ int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_req_init_sync(loop, req, UV_FS_UNLINK); fs__unlink(req, path); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -883,6 +888,7 @@ int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_req_init_sync(loop, req, UV_FS_MKDIR); fs__mkdir(req, path, mode); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -897,6 +903,7 @@ int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { uv_fs_req_init_sync(loop, req, UV_FS_RMDIR); fs__rmdir(req, path); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -913,6 +920,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_req_init_sync(loop, req, UV_FS_READDIR); fs__readdir(req, path, flags); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -930,6 +938,7 @@ int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_req_init_sync(loop, req, UV_FS_LINK); fs__link(req, path, new_path); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -947,6 +956,7 @@ int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_req_init_sync(loop, req, UV_FS_SYMLINK); fs__symlink(req, path, new_path, flags); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -962,6 +972,7 @@ int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_req_init_sync(loop, req, UV_FS_READLINK); fs__readlink(req, path); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -978,6 +989,7 @@ int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid, uv_fs_req_init_sync(loop, req, UV_FS_CHOWN); fs__nop(req); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -994,6 +1006,7 @@ int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid, uv_fs_req_init_sync(loop, req, UV_FS_FCHOWN); fs__nop(req); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1030,6 +1043,7 @@ int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { free(path2); } SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1067,6 +1081,7 @@ int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { free(path2); } SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1082,6 +1097,7 @@ int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { uv_fs_req_init_sync(loop, req, UV_FS_FSTAT); fs__fstat(req, file); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1099,6 +1115,7 @@ int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_req_init_sync(loop, req, UV_FS_RENAME); fs__rename(req, path, new_path); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1114,6 +1131,7 @@ int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { uv_fs_req_init_sync(loop, req, UV_FS_FDATASYNC); fs__fsync(req, file); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1129,6 +1147,7 @@ int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { uv_fs_req_init_sync(loop, req, UV_FS_FSYNC); fs__fsync(req, file); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1145,6 +1164,7 @@ int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE); fs__ftruncate(req, file, offset); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1161,6 +1181,7 @@ int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, uv_fs_req_init_sync(loop, req, UV_FS_SENDFILE); fs__sendfile(req, out_fd, in_fd, in_offset, length); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1177,6 +1198,7 @@ int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_req_init_sync(loop, req, UV_FS_CHMOD); fs__chmod(req, path, mode); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1193,6 +1215,7 @@ int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode, uv_fs_req_init_sync(loop, req, UV_FS_FCHMOD); fs__fchmod(req, file, mode); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1210,6 +1233,7 @@ int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, uv_fs_req_init_sync(loop, req, UV_FS_UTIME); fs__utime(req, path, atime, mtime); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; @@ -1228,6 +1252,7 @@ int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, uv_fs_req_init_sync(loop, req, UV_FS_FUTIME); fs__futime(req, file, atime, mtime); SET_UV_LAST_ERROR_FROM_REQ(req); + return req->result; } return 0; |