diff options
author | setser <setser@yandex-team.ru> | 2022-03-16 14:01:41 +0300 |
---|---|---|
committer | setser <setser@yandex-team.ru> | 2022-03-16 14:01:41 +0300 |
commit | e53b11f9862a561704077616d62587223ffa9d70 (patch) | |
tree | 4f0147ef87635abfe52322bdf40807223a34f053 /util/system/fs_win.cpp | |
parent | 3af0e2692ba281186cf54a397141a4b578793470 (diff) | |
download | ydb-e53b11f9862a561704077616d62587223ffa9d70.tar.gz |
Remove read-only files and directories on Windows (to match behavior on unix)
Current behavior of RemoveDirWithContents does not allow removing
directories if any of files in this directory is read-only. This
behavior, however, does not allow, for example, to remove temporary
directory, in which git repository was created (on *nix systems,
however, this problem was not noticed). This PR overrides this behavior.
ref:1faf91e233008b4aece4f2b953884b52346ce2be
Diffstat (limited to 'util/system/fs_win.cpp')
-rw-r--r-- | util/system/fs_win.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/util/system/fs_win.cpp b/util/system/fs_win.cpp index e9f4e5ac33..45d7454b2f 100644 --- a/util/system/fs_win.cpp +++ b/util/system/fs_win.cpp @@ -60,6 +60,10 @@ namespace NFsPrivate { } WIN32_FILE_ATTRIBUTE_DATA fad; if (::GetFileAttributesExW(wname, GetFileExInfoStandard, &fad)) { + if (fad.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { + fad.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; + ::SetFileAttributesW(wname, fad.dwFileAttributes); + } if (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) return ::RemoveDirectoryW(wname) != 0; return ::DeleteFileW(wname) != 0; |