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:
parent
e8effd4556
commit
509214d669
19
src/win/fs.c
19
src/win/fs.c
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user