Skip to content

Commit

Permalink
win, fs: mkdir really return UV_EINVAL for invalid names
Browse files Browse the repository at this point in the history
Makes uv_fs_mkdir return UV_EINVAL for invalid directory names instead
of UV_ENOENT.

Refs: nodejs/node#31177
PR-URL: libuv#2601
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
  • Loading branch information
seishun authored and JeffroMF committed May 16, 2022
1 parent 6799191 commit b1399b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,8 @@ void fs__mkdir(uv_fs_t* req) {
SET_REQ_RESULT(req, 0);
} else {
SET_REQ_WIN32_ERROR(req, GetLastError());
if (req->sys_errno_ == ERROR_INVALID_NAME)
if (req->sys_errno_ == ERROR_INVALID_NAME ||
req->sys_errno_ == ERROR_DIRECTORY)
req->result = UV_EINVAL;
}
}
Expand Down
1 change: 1 addition & 0 deletions test/test-fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4437,6 +4437,7 @@ TEST_IMPL(fs_invalid_mkdir_name) {
loop = uv_default_loop();
r = uv_fs_mkdir(loop, &req, "invalid>", 0, NULL);
ASSERT(r == UV_EINVAL);
ASSERT_EQ(UV_EINVAL, uv_fs_mkdir(loop, &req, "test:lol", 0, NULL));

return 0;
}
Expand Down

0 comments on commit b1399b8

Please sign in to comment.