win, fs: use FILE_WRITE_ATTRIBUTES when opening files
This allows for running uv_fs_fchmod on files with Archive flag cleared Refs: https://github.com/nodejs/node/issues/12803 PR-URL: https://github.com/libuv/libuv/pull/1777 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
edf05b97f0
commit
aa1beaa07c
@ -434,6 +434,8 @@ void fs__open(uv_fs_t* req) {
|
||||
access |= FILE_APPEND_DATA;
|
||||
}
|
||||
|
||||
access |= FILE_WRITE_ATTRIBUTES;
|
||||
|
||||
/*
|
||||
* Here is where we deviate significantly from what CRT's _open()
|
||||
* does. We indiscriminately use all the sharing modes, to match
|
||||
|
||||
@ -1367,6 +1367,28 @@ TEST_IMPL(fs_chmod) {
|
||||
|
||||
check_permission("test_file", 0600);
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Test clearing read-only flag from files with Archive flag cleared */
|
||||
/* Make the file read-only and clear archive flag */
|
||||
r = SetFileAttributes("test_file", FILE_ATTRIBUTE_READONLY);
|
||||
ASSERT(r != 0);
|
||||
check_permission("test_file", 0400);
|
||||
|
||||
r = uv_fs_open(NULL, &req, "test_file", 0, 0, NULL);
|
||||
ASSERT(r >= 0);
|
||||
ASSERT(req.result >= 0);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
r = uv_fs_fchmod(NULL, &req, file, 0600, NULL);
|
||||
ASSERT(r == 0);
|
||||
ASSERT(req.result == 0);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
check_permission("test_file", 0600);
|
||||
/* Restore Archive flag for rest of the tests */
|
||||
r = SetFileAttributes("test_file", FILE_ATTRIBUTE_ARCHIVE);
|
||||
ASSERT(r != 0);
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
/* async chmod */
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user