win,fs: use CreateDirectoryW instead of _wmkdir

No functional changes are intended [NFCI], but this may make it easier
in the future to implement and respect the `modes` flag.

PR-URL: https://github.com/libuv/libuv/pull/2921
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
This commit is contained in:
Mustafa M 2020-08-04 11:06:11 -04:00 committed by GitHub
parent e8effd4556
commit 509214d669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1221,12 +1221,12 @@ void fs__unlink(uv_fs_t* req) {
void fs__mkdir(uv_fs_t* req) {
/* TODO: use req->mode. */
req->result = _wmkdir(req->file.pathw);
if (req->result == -1) {
req->sys_errno_ = _doserrno;
req->result = req->sys_errno_ == ERROR_INVALID_NAME
? UV_EINVAL
: uv_translate_sys_error(req->sys_errno_);
if (CreateDirectoryW(req->file.pathw, NULL)) {
SET_REQ_RESULT(req, 0);
} else {
SET_REQ_WIN32_ERROR(req, GetLastError());
if (req->sys_errno_ == ERROR_INVALID_NAME)
req->result = UV_EINVAL;
}
}
@ -1279,10 +1279,13 @@ void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) {
static int fs__mkdtemp_func(uv_fs_t* req) {
if (_wmkdir(req->file.pathw) == 0) {
DWORD error;
if (CreateDirectoryW(req->file.pathw, NULL)) {
SET_REQ_RESULT(req, 0);
return 1;
} else if (errno != EEXIST) {
}
error = GetLastError();
if (error != ERROR_ALREADY_EXISTS) {
SET_REQ_RESULT(req, -1);
return 1;
}