diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-04-11 12:41:55 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-04-11 12:41:55 +0200 |
commit | 19e37c05d6ddcd70bc60286654a6a42731bbba4e (patch) | |
tree | 2d6bbc2475f8d2815457f1f53f8258366c94a415 /src/common/util.cpp | |
parent | Merge pull request #5366 (diff) | |
parent | util: name replace_file arguments better (diff) | |
download | monero-19e37c05d6ddcd70bc60286654a6a42731bbba4e.tar.xz |
Merge pull request #5367
07b716bf util: name replace_file arguments better (moneromooo-monero)
Diffstat (limited to 'src/common/util.cpp')
-rw-r--r-- | src/common/util.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp index 728efc294..3388974ce 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -641,16 +641,16 @@ std::string get_nix_version_display_string() return res; } - std::error_code replace_file(const std::string& replacement_name, const std::string& replaced_name) + std::error_code replace_file(const std::string& old_name, const std::string& new_name) { int code; #if defined(WIN32) // Maximizing chances for success std::wstring wide_replacement_name; - try { wide_replacement_name = string_tools::utf8_to_utf16(replacement_name); } + try { wide_replacement_name = string_tools::utf8_to_utf16(old_name); } catch (...) { return std::error_code(GetLastError(), std::system_category()); } std::wstring wide_replaced_name; - try { wide_replaced_name = string_tools::utf8_to_utf16(replaced_name); } + try { wide_replaced_name = string_tools::utf8_to_utf16(new_name); } catch (...) { return std::error_code(GetLastError(), std::system_category()); } DWORD attributes = ::GetFileAttributesW(wide_replaced_name.c_str()); @@ -662,7 +662,7 @@ std::string get_nix_version_display_string() bool ok = 0 != ::MoveFileExW(wide_replacement_name.c_str(), wide_replaced_name.c_str(), MOVEFILE_REPLACE_EXISTING); code = ok ? 0 : static_cast<int>(::GetLastError()); #else - bool ok = 0 == std::rename(replacement_name.c_str(), replaced_name.c_str()); + bool ok = 0 == std::rename(old_name.c_str(), new_name.c_str()); code = ok ? 0 : errno; #endif return std::error_code(code, std::system_category()); |