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 15f29dc08f.
PR-URL: https://github.com/libuv/libuv/pull/1717
Refs: https://github.com/nodejs/node/issues/18014
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
b0f3310bb1
commit
9f07a3673b
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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->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);
|
||||
rmdir_cb_count++;
|
||||
ASSERT(req->path);
|
||||
ASSERT(memcmp(req->path, "test_dir\0", 9) == 0);
|
||||
break;
|
||||
}
|
||||
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");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user