From c9ae7a6f9580eb4f2fe8a73ecdb9b543a10e2673 Mon Sep 17 00:00:00 2001 From: Igor Zinkovsky Date: Wed, 28 Sep 2011 12:59:39 -0700 Subject: [PATCH] windows: don't strip the trailing slash from filename if it follows a device name --- src/win/fs.c | 10 +++++----- test/test-fs.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win/fs.c b/src/win/fs.c index 2969cfa0..e410ec92 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -77,7 +77,7 @@ 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); \ + uv__set_error(req->loop, (uv_err_code)req->errorno, req->last_error); \ } #define SET_REQ_LAST_ERROR(req, error) \ @@ -1022,9 +1022,9 @@ int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid, int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { int len = strlen(path); char* path2 = NULL; - int has_backslash = (path[len - 1] == '\\' || path[len - 1] == '/'); - if (path[len - 1] == '\\' || path[len - 1] == '/') { + if (len > 1 && path[len - 2] != ':' && + (path[len - 1] == '\\' || path[len - 1] == '/')) { path2 = strdup(path); if (!path2) { uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); @@ -1060,9 +1060,9 @@ int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { int len = strlen(path); char* path2 = NULL; - int has_backslash = (path[len - 1] == '\\' || path[len - 1] == '/'); - if (path[len - 1] == '\\' || path[len - 1] == '/') { + if (len > 1 && path[len - 2] != ':' && + (path[len - 1] == '\\' || path[len - 1] == '/')) { path2 = strdup(path); if (!path2) { uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); diff --git a/test/test-fs.c b/test/test-fs.c index 910e938d..dfc373b6 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -1077,7 +1077,7 @@ TEST_IMPL(fs_symlink) { r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink", 0, NULL); #ifdef _WIN32 if (r == -1) { - if (req.errorno == ENOSYS) { + if (uv_last_error(loop).code == UV_ENOTSUP) { /* * Windows doesn't support symlinks on older versions. * We just pass the test and bail out early if we get ENOTSUP.