diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-03-05 19:15:54 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-03-05 19:15:54 +0200 |
commit | 237f0179b70eb795772e815f2e9ff6f056f53c22 (patch) | |
tree | 8e2e88d92272256b65652e41a5cf56881cb85f30 /src/wallet/wallet2.cpp | |
parent | Merge pull request #3343 (diff) | |
parent | Wallet2 + CLI wallet: UTF-8 support for filenames and paths under Windows (diff) | |
download | monero-237f0179b70eb795772e815f2e9ff6f056f53c22.tar.xz |
Merge pull request #3313
43026822 Wallet2 + CLI wallet: UTF-8 support for filenames and paths under Windows (rbrunner7)
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r-- | src/wallet/wallet2.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 9b2595716..4a6c6fad2 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3781,12 +3781,24 @@ void wallet2::store_to(const std::string &path, const epee::wipeable_string &pas } } else { // save to new file +#ifdef WIN32 + // On Windows avoid using std::ofstream which does not work with UTF-8 filenames + // The price to pay is temporary higher memory consumption for string stream + binary archive + std::ostringstream oss; + binary_archive<true> oar(oss); + bool success = ::serialization::serialize(oar, cache_file_data); + if (success) { + success = epee::file_io_utils::save_string_to_file(new_file, oss.str()); + } + THROW_WALLET_EXCEPTION_IF(!success, error::file_save_error, new_file); +#else std::ofstream ostr; ostr.open(new_file, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc); binary_archive<true> oar(ostr); bool success = ::serialization::serialize(oar, cache_file_data); ostr.close(); THROW_WALLET_EXCEPTION_IF(!success || !ostr.good(), error::file_save_error, new_file); +#endif // here we have "*.new" file, we need to rename it to be without ".new" std::error_code e = tools::replace_file(new_file, m_wallet_file); |