|
@ -34,8 +34,8 @@ |
|
|
#include "internal.h" |
|
|
#include "internal.h" |
|
|
|
|
|
|
|
|
#define UV_FS_ASYNC_QUEUED 0x0001 |
|
|
#define UV_FS_ASYNC_QUEUED 0x0001 |
|
|
#define UV_FS_FREE_ARG0 0x0002 |
|
|
#define UV_FS_FREE_PATH 0x0002 |
|
|
#define UV_FS_FREE_ARG1 0x0004 |
|
|
#define UV_FS_FREE_NEW_PATH 0x0004 |
|
|
#define UV_FS_FREE_PTR 0x0008 |
|
|
#define UV_FS_FREE_PTR 0x0008 |
|
|
#define UV_FS_CLEANEDUP 0x0010 |
|
|
#define UV_FS_CLEANEDUP 0x0010 |
|
|
|
|
|
|
|
@ -51,31 +51,6 @@ |
|
|
return -1; \ |
|
|
return -1; \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#define STRDUP_ARG(req, i) \ |
|
|
|
|
|
req->arg##i = (void*)strdup((const char*)req->arg##i); \ |
|
|
|
|
|
if (!req->arg##i) { \ |
|
|
|
|
|
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); \ |
|
|
|
|
|
} \ |
|
|
|
|
|
req->flags |= UV_FS_FREE_ARG##i; |
|
|
|
|
|
|
|
|
|
|
|
#define SET_ALLOCED_ARG(req, i) \ |
|
|
|
|
|
req->flags |= UV_FS_FREE_ARG##i; |
|
|
|
|
|
|
|
|
|
|
|
#define WRAP_REQ_ARGS1(req, a0) \ |
|
|
|
|
|
req->arg0 = (void*)a0; |
|
|
|
|
|
|
|
|
|
|
|
#define WRAP_REQ_ARGS2(req, a0, a1) \ |
|
|
|
|
|
WRAP_REQ_ARGS1(req, a0) \ |
|
|
|
|
|
req->arg1 = (void*)a1; |
|
|
|
|
|
|
|
|
|
|
|
#define WRAP_REQ_ARGS3(req, a0, a1, a2) \ |
|
|
|
|
|
WRAP_REQ_ARGS2(req, a0, a1) \ |
|
|
|
|
|
req->arg2 = (void*)a2; |
|
|
|
|
|
|
|
|
|
|
|
#define WRAP_REQ_ARGS4(req, a0, a1, a2, a3) \ |
|
|
|
|
|
WRAP_REQ_ARGS3(req, a0, a1, a2) \ |
|
|
|
|
|
req->arg3 = (void*)a3; |
|
|
|
|
|
|
|
|
|
|
|
#define QUEUE_FS_TP_JOB(loop, req) \ |
|
|
#define QUEUE_FS_TP_JOB(loop, req) \ |
|
|
if (!QueueUserWorkItem(&uv_fs_thread_proc, \ |
|
|
if (!QueueUserWorkItem(&uv_fs_thread_proc, \ |
|
|
req, \ |
|
|
req, \ |
|
@ -289,7 +264,7 @@ void fs__close(uv_fs_t* req, uv_file file) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length, |
|
|
void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length, |
|
|
off_t offset) { |
|
|
int64_t offset) { |
|
|
HANDLE handle; |
|
|
HANDLE handle; |
|
|
OVERLAPPED overlapped, *overlapped_ptr; |
|
|
OVERLAPPED overlapped, *overlapped_ptr; |
|
|
LARGE_INTEGER offset_; |
|
|
LARGE_INTEGER offset_; |
|
@ -335,7 +310,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length, |
|
|
void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length, |
|
|
off_t offset) { |
|
|
int64_t offset) { |
|
|
HANDLE handle; |
|
|
HANDLE handle; |
|
|
OVERLAPPED overlapped, *overlapped_ptr; |
|
|
OVERLAPPED overlapped, *overlapped_ptr; |
|
|
LARGE_INTEGER offset_; |
|
|
LARGE_INTEGER offset_; |
|
@ -597,31 +572,34 @@ void fs__fsync(uv_fs_t* req, uv_file file) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fs__ftruncate(uv_fs_t* req, uv_file file, off_t offset) { |
|
|
void fs__ftruncate(uv_fs_t* req, uv_file file, int64_t offset) { |
|
|
int result; |
|
|
int result; |
|
|
|
|
|
|
|
|
VERIFY_UV_FILE(file, req); |
|
|
VERIFY_UV_FILE(file, req); |
|
|
|
|
|
|
|
|
result = _chsize(file, offset); |
|
|
result = _chsize_s(file, offset); |
|
|
SET_REQ_RESULT(req, result); |
|
|
SET_REQ_RESULT(req, result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fs__sendfile(uv_fs_t* req, uv_file out_file, uv_file in_file, |
|
|
void fs__sendfile(uv_fs_t* req, uv_file out_file, uv_file in_file, |
|
|
off_t in_offset, size_t length) { |
|
|
int64_t in_offset, size_t length) { |
|
|
const size_t max_buf_size = 65536; |
|
|
const size_t max_buf_size = 65536; |
|
|
size_t buf_size = length < max_buf_size ? length : max_buf_size; |
|
|
size_t buf_size = length < max_buf_size ? length : max_buf_size; |
|
|
int n, result = 0; |
|
|
int n, result = 0; |
|
|
|
|
|
int64_t result_offset = 0; |
|
|
char* buf = (char*)malloc(buf_size); |
|
|
char* buf = (char*)malloc(buf_size); |
|
|
if (!buf) { |
|
|
if (!buf) { |
|
|
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); |
|
|
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (in_offset != -1) { |
|
|
if (in_offset != -1) { |
|
|
result = _lseek(in_file, in_offset, SEEK_SET); |
|
|
result_offset = _lseeki64(in_file, in_offset, SEEK_SET); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (result != -1) { |
|
|
if (result_offset == -1) { |
|
|
|
|
|
result = -1; |
|
|
|
|
|
} else { |
|
|
while (length > 0) { |
|
|
while (length > 0) { |
|
|
n = _read(in_file, buf, length < buf_size ? length : buf_size); |
|
|
n = _read(in_file, buf, length < buf_size ? length : buf_size); |
|
|
if (n == 0) { |
|
|
if (n == 0) { |
|
@ -868,78 +846,66 @@ static DWORD WINAPI uv_fs_thread_proc(void* parameter) { |
|
|
|
|
|
|
|
|
switch (req->fs_type) { |
|
|
switch (req->fs_type) { |
|
|
case UV_FS_OPEN: |
|
|
case UV_FS_OPEN: |
|
|
fs__open(req, req->pathw, (int)req->arg0, (int)req->arg1); |
|
|
fs__open(req, req->pathw, req->file_flags, (int)req->mode); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_CLOSE: |
|
|
case UV_FS_CLOSE: |
|
|
fs__close(req, (uv_file)req->arg0); |
|
|
fs__close(req, req->file); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_READ: |
|
|
case UV_FS_READ: |
|
|
fs__read(req, |
|
|
fs__read(req, req->file, req->buf, req->length, req->offset); |
|
|
(uv_file) req->arg0, |
|
|
|
|
|
req->arg1, |
|
|
|
|
|
(size_t) req->arg2, |
|
|
|
|
|
(off_t) req->arg3); |
|
|
|
|
|
break; |
|
|
break; |
|
|
case UV_FS_WRITE: |
|
|
case UV_FS_WRITE: |
|
|
fs__write(req, |
|
|
fs__write(req, req->file, req->buf, req->length, req->offset); |
|
|
(uv_file)req->arg0, |
|
|
|
|
|
req->arg1, |
|
|
|
|
|
(size_t) req->arg2, |
|
|
|
|
|
(off_t) req->arg3); |
|
|
|
|
|
break; |
|
|
break; |
|
|
case UV_FS_UNLINK: |
|
|
case UV_FS_UNLINK: |
|
|
fs__unlink(req, req->pathw); |
|
|
fs__unlink(req, req->pathw); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_MKDIR: |
|
|
case UV_FS_MKDIR: |
|
|
fs__mkdir(req, req->pathw, (int)req->arg0); |
|
|
fs__mkdir(req, req->pathw, req->mode); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_RMDIR: |
|
|
case UV_FS_RMDIR: |
|
|
fs__rmdir(req, req->pathw); |
|
|
fs__rmdir(req, req->pathw); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_READDIR: |
|
|
case UV_FS_READDIR: |
|
|
fs__readdir(req, req->pathw, (int)req->arg0); |
|
|
fs__readdir(req, req->pathw, req->file_flags); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_STAT: |
|
|
case UV_FS_STAT: |
|
|
case UV_FS_LSTAT: |
|
|
case UV_FS_LSTAT: |
|
|
fs__stat(req, req->pathw); |
|
|
fs__stat(req, req->pathw); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_FSTAT: |
|
|
case UV_FS_FSTAT: |
|
|
fs__fstat(req, (uv_file)req->arg0); |
|
|
fs__fstat(req, req->file); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_RENAME: |
|
|
case UV_FS_RENAME: |
|
|
fs__rename(req, req->pathw, (const wchar_t*)req->arg0); |
|
|
fs__rename(req, req->pathw, req->new_pathw); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_FSYNC: |
|
|
case UV_FS_FSYNC: |
|
|
case UV_FS_FDATASYNC: |
|
|
case UV_FS_FDATASYNC: |
|
|
fs__fsync(req, (uv_file)req->arg0); |
|
|
fs__fsync(req, req->file); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_FTRUNCATE: |
|
|
case UV_FS_FTRUNCATE: |
|
|
fs__ftruncate(req, (uv_file)req->arg0, (off_t)req->arg1); |
|
|
fs__ftruncate(req, req->file, req->offset); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_SENDFILE: |
|
|
case UV_FS_SENDFILE: |
|
|
fs__sendfile(req, |
|
|
fs__sendfile(req, req->file_out, req->file, req->offset, req->length); |
|
|
(uv_file) req->arg0, |
|
|
|
|
|
(uv_file) req->arg1, |
|
|
|
|
|
(off_t) req->arg2, |
|
|
|
|
|
(size_t) req->arg3); |
|
|
|
|
|
break; |
|
|
break; |
|
|
case UV_FS_CHMOD: |
|
|
case UV_FS_CHMOD: |
|
|
fs__chmod(req, req->pathw, (int)req->arg0); |
|
|
fs__chmod(req, req->pathw, req->mode); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_FCHMOD: |
|
|
case UV_FS_FCHMOD: |
|
|
fs__fchmod(req, (uv_file)req->arg0, (int)req->arg1); |
|
|
fs__fchmod(req, req->file, req->mode); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_UTIME: |
|
|
case UV_FS_UTIME: |
|
|
fs__utime(req, req->pathw, req->arg4, req->arg5); |
|
|
fs__utime(req, req->pathw, req->atime, req->mtime); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_FUTIME: |
|
|
case UV_FS_FUTIME: |
|
|
fs__futime(req, (uv_file)req->arg0, req->arg4, req->arg5); |
|
|
fs__futime(req, req->file, req->atime, req->mtime); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_LINK: |
|
|
case UV_FS_LINK: |
|
|
fs__link(req, req->pathw, (const wchar_t*)req->arg0); |
|
|
fs__link(req, req->pathw, req->new_pathw); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_SYMLINK: |
|
|
case UV_FS_SYMLINK: |
|
|
fs__symlink(req, req->pathw, (const wchar_t*)req->arg0, (int)req->arg1); |
|
|
fs__symlink(req, req->pathw, req->new_pathw, req->file_flags); |
|
|
break; |
|
|
break; |
|
|
case UV_FS_READLINK: |
|
|
case UV_FS_READLINK: |
|
|
fs__readlink(req, req->pathw); |
|
|
fs__readlink(req, req->pathw); |
|
@ -968,7 +934,8 @@ int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_OPEN, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_OPEN, path, pathw, cb); |
|
|
WRAP_REQ_ARGS2(req, flags, mode); |
|
|
req->file_flags = flags; |
|
|
|
|
|
req->mode = mode; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_OPEN); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_OPEN); |
|
@ -985,7 +952,7 @@ int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, |
|
|
int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_CLOSE, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_CLOSE, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS1(req, file); |
|
|
req->file = file; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_CLOSE); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_CLOSE); |
|
@ -999,10 +966,13 @@ int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, |
|
|
int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, |
|
|
size_t length, off_t offset, uv_fs_cb cb) { |
|
|
size_t length, int64_t offset, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_READ, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_READ, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS4(req, file, buf, length, offset); |
|
|
req->file = file; |
|
|
|
|
|
req->buf = buf; |
|
|
|
|
|
req->length = length; |
|
|
|
|
|
req->offset = offset; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_READ); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_READ); |
|
@ -1016,10 +986,13 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, |
|
|
int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, |
|
|
size_t length, off_t offset, uv_fs_cb cb) { |
|
|
size_t length, int64_t offset, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_WRITE, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_WRITE, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS4(req, file, buf, length, offset); |
|
|
req->file = file; |
|
|
|
|
|
req->buf = buf; |
|
|
|
|
|
req->length = length; |
|
|
|
|
|
req->offset = offset; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_WRITE); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_WRITE); |
|
@ -1065,7 +1038,7 @@ int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_MKDIR, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_MKDIR, path, pathw, cb); |
|
|
WRAP_REQ_ARGS1(req, mode); |
|
|
req->mode = mode; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_MKDIR); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_MKDIR); |
|
@ -1111,7 +1084,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_READDIR, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_READDIR, path, pathw, cb); |
|
|
WRAP_REQ_ARGS1(req, flags); |
|
|
req->file_flags = flags; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_READDIR); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_READDIR); |
|
@ -1137,8 +1110,8 @@ int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_LINK, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_LINK, path, pathw, cb); |
|
|
WRAP_REQ_ARGS1(req, new_pathw); |
|
|
req->new_pathw = new_pathw; |
|
|
SET_ALLOCED_ARG(req, 0); |
|
|
req->flags |= UV_FS_FREE_NEW_PATH; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_LINK); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_LINK); |
|
@ -1165,8 +1138,8 @@ int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_SYMLINK, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_SYMLINK, path, pathw, cb); |
|
|
WRAP_REQ_ARGS2(req, new_pathw, flags); |
|
|
req->new_pathw = new_pathw; |
|
|
SET_ALLOCED_ARG(req, 0); |
|
|
req->flags |= UV_FS_FREE_NEW_PATH; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_SYMLINK); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_SYMLINK); |
|
@ -1214,7 +1187,6 @@ int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_CHOWN, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_CHOWN, path, pathw, cb); |
|
|
WRAP_REQ_ARGS2(req, uid, gid); |
|
|
|
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_CHOWN); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_CHOWN); |
|
@ -1232,7 +1204,6 @@ int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid, |
|
|
int gid, uv_fs_cb cb) { |
|
|
int gid, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FCHOWN, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FCHOWN, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS3(req, file, uid, gid); |
|
|
|
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FCHOWN); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FCHOWN); |
|
@ -1335,7 +1306,7 @@ int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { |
|
|
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FSTAT, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FSTAT, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS1(req, file); |
|
|
req->file = file; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FSTAT); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FSTAT); |
|
@ -1360,8 +1331,8 @@ int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_RENAME, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_RENAME, path, pathw, cb); |
|
|
WRAP_REQ_ARGS1(req, new_pathw); |
|
|
req->new_pathw = new_pathw; |
|
|
SET_ALLOCED_ARG(req, 0); |
|
|
req->flags |= UV_FS_FREE_NEW_PATH; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_RENAME); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_RENAME); |
|
@ -1379,7 +1350,7 @@ int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, |
|
|
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FDATASYNC, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FDATASYNC, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS1(req, file); |
|
|
req->file = file; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FDATASYNC); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FDATASYNC); |
|
@ -1395,7 +1366,7 @@ int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FSYNC, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FSYNC, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS1(req, file); |
|
|
req->file = file; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FSYNC); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FSYNC); |
|
@ -1409,10 +1380,11 @@ int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, |
|
|
int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, |
|
|
off_t offset, uv_fs_cb cb) { |
|
|
int64_t offset, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FTRUNCATE, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FTRUNCATE, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS2(req, file, offset); |
|
|
req->file = file; |
|
|
|
|
|
req->offset = offset; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE); |
|
@ -1426,10 +1398,13 @@ int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, |
|
|
int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, |
|
|
uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb) { |
|
|
uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_SENDFILE, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_SENDFILE, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS4(req, out_fd, in_fd, in_offset, length); |
|
|
req->file_out = out_fd; |
|
|
|
|
|
req->file = in_fd; |
|
|
|
|
|
req->offset = in_offset; |
|
|
|
|
|
req->length = length; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_SENDFILE); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_SENDFILE); |
|
@ -1452,7 +1427,7 @@ int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_CHMOD, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_CHMOD, path, pathw, cb); |
|
|
WRAP_REQ_ARGS1(req, mode); |
|
|
req->mode = mode; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_CHMOD); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_CHMOD); |
|
@ -1470,7 +1445,8 @@ int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode, |
|
|
uv_fs_cb cb) { |
|
|
uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FCHMOD, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FCHMOD, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS2(req, file, mode); |
|
|
req->file = file; |
|
|
|
|
|
req->mode = mode; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FCHMOD); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FCHMOD); |
|
@ -1493,8 +1469,8 @@ int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, |
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_UTIME, path, pathw, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_UTIME, path, pathw, cb); |
|
|
req->arg4 = (ssize_t)atime; |
|
|
req->atime = atime; |
|
|
req->arg5 = (ssize_t)mtime; |
|
|
req->mtime = mtime; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_UTIME); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_UTIME); |
|
@ -1512,9 +1488,9 @@ int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, |
|
|
double mtime, uv_fs_cb cb) { |
|
|
double mtime, uv_fs_cb cb) { |
|
|
if (cb) { |
|
|
if (cb) { |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FUTIME, NULL, NULL, cb); |
|
|
uv_fs_req_init_async(loop, req, UV_FS_FUTIME, NULL, NULL, cb); |
|
|
WRAP_REQ_ARGS1(req, file); |
|
|
req->file = file; |
|
|
req->arg4 = (ssize_t)atime; |
|
|
req->atime = atime; |
|
|
req->arg5 = (ssize_t)mtime; |
|
|
req->mtime = mtime; |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
QUEUE_FS_TP_JOB(loop, req); |
|
|
} else { |
|
|
} else { |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FUTIME); |
|
|
uv_fs_req_init_sync(loop, req, UV_FS_FUTIME); |
|
@ -1541,14 +1517,14 @@ void uv_fs_req_cleanup(uv_fs_t* req) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (req->flags & UV_FS_FREE_ARG0 && req->arg0) { |
|
|
if (req->flags & UV_FS_FREE_PATH && req->pathw) { |
|
|
free(req->arg0); |
|
|
free(req->pathw); |
|
|
req->arg0 = NULL; |
|
|
req->pathw = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (req->flags & UV_FS_FREE_ARG1 && req->arg1) { |
|
|
if (req->flags & UV_FS_FREE_NEW_PATH && req->new_pathw) { |
|
|
free(req->arg1); |
|
|
free(req->new_pathw); |
|
|
req->arg1 = NULL; |
|
|
req->new_pathw = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (req->flags & UV_FS_FREE_PTR && req->ptr) { |
|
|
if (req->flags & UV_FS_FREE_PTR && req->ptr) { |
|
@ -1562,11 +1538,6 @@ void uv_fs_req_cleanup(uv_fs_t* req) { |
|
|
req->path = NULL; |
|
|
req->path = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (req->pathw) { |
|
|
|
|
|
free(req->pathw); |
|
|
|
|
|
req->pathw = NULL; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (req->flags & UV_FS_ASYNC_QUEUED) { |
|
|
if (req->flags & UV_FS_ASYNC_QUEUED) { |
|
|
uv_unref(loop); |
|
|
uv_unref(loop); |
|
|
} |
|
|
} |
|
|