aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/fs_win.cpp
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-11-20 11:14:58 +0000
committerAlexander Smirnov <alex@ydb.tech>2024-11-20 11:14:58 +0000
commit31773f157bf8164364649b5f470f52dece0a4317 (patch)
tree33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /util/system/fs_win.cpp
parent2c7938962d8689e175574fc1e817c05049f27905 (diff)
parenteff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff)
downloadydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'util/system/fs_win.cpp')
-rw-r--r--util/system/fs_win.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/util/system/fs_win.cpp b/util/system/fs_win.cpp
index ff8a254782..65e695bee4 100644
--- a/util/system/fs_win.cpp
+++ b/util/system/fs_win.cpp
@@ -12,8 +12,9 @@ namespace NFsPrivate {
static LPCWSTR UTF8ToWCHAR(const TStringBuf str, TUtf16String& wstr) {
wstr.resize(str.size());
size_t written = 0;
- if (!UTF8ToWide(str.data(), str.size(), wstr.begin(), written))
+ if (!UTF8ToWide(str.data(), str.size(), wstr.begin(), written)) {
return nullptr;
+ }
wstr.erase(written);
static_assert(sizeof(WCHAR) == sizeof(wchar16), "expect sizeof(WCHAR) == sizeof(wchar16)");
return (const WCHAR*)wstr.data();
@@ -64,8 +65,9 @@ namespace NFsPrivate {
fad.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
::SetFileAttributesW(wname, fad.dwFileAttributes);
}
- if (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ if (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
return ::RemoveDirectoryW(wname) != 0;
+ }
return ::DeleteFileW(wname) != 0;
}
@@ -76,8 +78,9 @@ namespace NFsPrivate {
TString tName(targetName);
{
size_t pos;
- while ((pos = tName.find('/')) != TString::npos)
+ while ((pos = tName.find('/')) != TString::npos) {
tName.replace(pos, 1, LOCSLASH_S);
+ }
}
TUtf16String tstr;
LPCWSTR wname = UTF8ToWCHAR(tName, tstr);
@@ -127,8 +130,9 @@ namespace NFsPrivate {
TTempBuf result;
LPWSTR buf = reinterpret_cast<LPWSTR>(result.Data());
int r = GetCurrentDirectoryW(result.Size() / sizeof(WCHAR), buf);
- if (r == 0)
+ if (r == 0) {
throw TIoSystemError() << "failed to GetCurrentDirectory";
+ }
return WCHARToUTF8(buf, r);
}