aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorrbrunner7 <rbrunner@dreamshare.ch>2018-02-22 19:52:55 +0100
committerrbrunner7 <rbrunner@dreamshare.ch>2018-02-25 12:57:58 +0100
commit430268224d71bfc6a359f20c6db712462ce0bb25 (patch)
treef095671ade4fa74e93fac65a442cb7c4c587f812 /src/wallet
parentMerge pull request #3245 (diff)
downloadmonero-430268224d71bfc6a359f20c6db712462ce0bb25.tar.xz
Wallet2 + CLI wallet: UTF-8 support for filenames and paths under Windows
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/api/wallet.cpp10
-rw-r--r--src/wallet/wallet2.cpp12
2 files changed, 22 insertions, 0 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 5ce8ede8d..de17e5608 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -44,6 +44,11 @@
#include <sstream>
#include <unordered_map>
+#ifdef WIN32
+#include <boost/locale.hpp>
+#include <boost/filesystem.hpp>
+#endif
+
using namespace std;
using namespace cryptonote;
@@ -291,6 +296,11 @@ uint64_t Wallet::maximumAllowedAmount()
}
void Wallet::init(const char *argv0, const char *default_log_base_name) {
+#ifdef WIN32
+ // Activate UTF-8 support for Boost filesystem classes on Windows
+ std::locale::global(boost::locale::generator().generate(""));
+ boost::filesystem::path::imbue(std::locale());
+#endif
epee::string_tools::set_module_name_and_folder(argv0);
mlog_configure(mlog_get_default_log_path(default_log_base_name), true);
}
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 3bad743cf..92b683552 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -3737,12 +3737,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);