From c9ebff2c73a6130587534527386a7d398be94d58 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 19 Jan 2018 01:24:43 +0100 Subject: [PATCH 3/3] Revert "win: use RemoveDirectoryW() instead of _wmrmdir()" Reverted for breaking `test/parallel/test-child-process-cwd.js` from the Node.js test suite. Instead of ENOENT when trying to remove a directory that does not exist, it started failing with ENOTDIR. This reverts commit 15f29dc08fe72cd189002f1b8ae22fd82264deef. --- src/win/error.c | 2 +- src/win/fs.c | 7 ++----- test/test-fs.c | 22 ++++------------------ 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/win/error.c b/src/win/error.c index 1ec3d6e2..9b03bfef 100644 --- a/src/win/error.c +++ b/src/win/error.c @@ -131,7 +131,7 @@ int uv_translate_sys_error(int sys_errno) { case WSAENETUNREACH: return UV_ENETUNREACH; case WSAENOBUFS: return UV_ENOBUFS; case ERROR_BAD_PATHNAME: return UV_ENOENT; - case ERROR_DIRECTORY: return UV_ENOTDIR; + case ERROR_DIRECTORY: return UV_ENOENT; case ERROR_FILE_NOT_FOUND: return UV_ENOENT; case ERROR_INVALID_NAME: return UV_ENOENT; case ERROR_INVALID_DRIVE: return UV_ENOENT; diff --git a/src/win/fs.c b/src/win/fs.c index 0905a24e..097b00e0 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -723,11 +723,8 @@ void fs__write(uv_fs_t* req) { void fs__rmdir(uv_fs_t* req) { - if (RemoveDirectoryW(req->file.pathw)) { - SET_REQ_SUCCESS(req); - } else { - SET_REQ_WIN32_ERROR(req, GetLastError()); - } + int result = _wrmdir(req->file.pathw); + SET_REQ_RESULT(req, result); } diff --git a/test/test-fs.c b/test/test-fs.c index 241416bc..7c481f07 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -469,19 +469,10 @@ static void mkdtemp_cb(uv_fs_t* req) { static void rmdir_cb(uv_fs_t* req) { ASSERT(req == &rmdir_req); ASSERT(req->fs_type == UV_FS_RMDIR); + ASSERT(req->result == 0); + rmdir_cb_count++; ASSERT(req->path); - switch (rmdir_cb_count++) { - default: - ASSERT(0); - case 0: - ASSERT(req->result == UV_ENOTDIR); - ASSERT(memcmp(req->path, "test_dir/file1\0", 15) == 0); - break; - case 1: - ASSERT(req->result == 0); - ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); - break; - } + ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); uv_fs_req_cleanup(req); } @@ -995,11 +986,6 @@ TEST_IMPL(fs_async_dir) { ASSERT(stat_cb_count == 4); - r = uv_fs_rmdir(loop, &rmdir_req, "test_dir/file1", rmdir_cb); - ASSERT(r == 0); - uv_run(loop, UV_RUN_DEFAULT); - ASSERT(rmdir_cb_count == 1); - r = uv_fs_unlink(loop, &unlink_req, "test_dir/file1", unlink_cb); ASSERT(r == 0); uv_run(loop, UV_RUN_DEFAULT); @@ -1013,7 +999,7 @@ TEST_IMPL(fs_async_dir) { r = uv_fs_rmdir(loop, &rmdir_req, "test_dir", rmdir_cb); ASSERT(r == 0); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(rmdir_cb_count == 2); + ASSERT(rmdir_cb_count == 1); /* Cleanup */ unlink("test_dir/file1"); -- 2.15.1