Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

windows: fix error reporting for uv_fs_ functions

  • Loading branch information...
Igor Zinkovsky
Igor Zinkovsky committed Sep 28, 2011
1 parent e7a53ae commit 4fb120f6494677ebfab0028a2f7b0cfd7dca09c4
Showing with 28 additions and 4 deletions.
  1. +10 −4 src/win/fs.c
  2. +16 −0 test/test-fs.c
  3. +2 −0 test/test-list.h
@@ -76,6 +76,8 @@
#define SET_UV_LAST_ERROR_FROM_REQ(req) \
if (req->flags & UV_FS_LAST_ERROR_SET) { \
uv__set_sys_error(req->loop, req->last_error); \
} else if (req->result == -1) { \
uv__set_error(req->loop, req->errorno, req->last_error); \
}

#define SET_REQ_LAST_ERROR(req, error) \
@@ -85,7 +87,8 @@
#define SET_REQ_RESULT(req, result_value) \
req->result = (result_value); \
if (req->result == -1) { \
req->errorno = uv_translate_sys_error(_doserrno); \
req->last_error = _doserrno; \
req->errorno = uv_translate_sys_error(req->last_error); \
}

#define SET_REQ_RESULT_WIN32_ERROR(req, sys_errno) \
@@ -576,11 +579,14 @@ void fs__symlink(uv_fs_t* req, const char* path, const char* new_path,
path,
flags & UV_FS_SYMLINK_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) ? 0 : -1;
if (result == -1) {
SET_REQ_LAST_ERROR(req, GetLastError());
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
return;
}
} else {
result = -1;
errno = ENOSYS;
req->result = -1;
req->errorno = UV_ENOTSUP;
req->last_error = ERROR_SUCCESS;
return;
}

SET_REQ_RESULT(req, result);
@@ -1245,3 +1245,19 @@ TEST_IMPL(fs_futime) {

return 0;
}


TEST_IMPL(fs_stat_missing_path) {
uv_fs_t req;
int r;

loop = uv_default_loop();

r = uv_fs_stat(loop, &req, "non_existent_file", NULL);
ASSERT(r == -1);
ASSERT(req.result == -1);
ASSERT(uv_last_error(loop).code == UV_ENOENT);
uv_fs_req_cleanup(&req);

return 0;
}
@@ -91,6 +91,7 @@ TEST_DECLARE (fs_link)
TEST_DECLARE (fs_symlink)
TEST_DECLARE (fs_utime)
TEST_DECLARE (fs_futime)
TEST_DECLARE (fs_stat_missing_path)
TEST_DECLARE (fs_event_watch_dir)
TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_current_dir)
@@ -216,6 +217,7 @@ TASK_LIST_START
TEST_ENTRY (fs_utime)
TEST_ENTRY (fs_futime)
TEST_ENTRY (fs_symlink)
TEST_ENTRY (fs_stat_missing_path)
TEST_ENTRY (fs_event_watch_dir)
TEST_ENTRY (fs_event_watch_file)
TEST_ENTRY (fs_event_watch_file_current_dir)

0 comments on commit 4fb120f

Please sign in to comment.
You can’t perform that action at this time.