diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index c1ea6bdd..f691d096 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -12,10 +12,9 @@ set_property(TARGET zlibstatic PROPERTY FOLDER "contrib") set_property(TARGET lmdb PROPERTY FOLDER "contrib") - - if(MSVC) set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267") else() - set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value") + set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-discarded-qualifiers ") + set_property(TARGET zlibstatic APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-discarded-qualifiers ") endif() diff --git a/contrib/db/liblmdb/CMakeLists.txt b/contrib/db/liblmdb/CMakeLists.txt index 4a60e07c..dc491820 100644 --- a/contrib/db/liblmdb/CMakeLists.txt +++ b/contrib/db/liblmdb/CMakeLists.txt @@ -4,7 +4,7 @@ set (lmdb_sources mdb.c midl.c) include_directories("${CMAKE_CURRENT_SOURCE_DIR}") if(NOT MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return -Wno-discarded-qualifiers -Wno-unused-but-set-variable -Wno-implicit-fallthrough -Wno-maybe-uninitialized ") endif() if(FREEBSD) add_definitions(-DMDB_DSYNC=O_SYNC) diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h index 39a96942..8e5fa6fd 100644 --- a/contrib/epee/include/file_io_utils.h +++ b/contrib/epee/include/file_io_utils.h @@ -52,6 +52,7 @@ #endif #include "include_base_utils.h" +#include "string_coding.h" namespace epee { @@ -380,16 +381,18 @@ namespace file_io_utils typedef int native_filesystem_handle; #endif + // uses UTF-8 for unicode names for all systems inline bool open_and_lock_file(const std::string file_path, native_filesystem_handle& h_file) { #ifdef WIN32 - h_file = ::CreateFileA(file_path.c_str(), // name of the write - GENERIC_WRITE, // open for writing - 0, // do not share - NULL, // default security - OPEN_ALWAYS, // create new file only - FILE_ATTRIBUTE_NORMAL, // normal file - NULL); // no attr. template + std::wstring file_path_w = epee::string_encoding::utf8_to_wstring(file_path); + h_file = ::CreateFileW(file_path_w.c_str(), // name of the file + GENERIC_WRITE, // open for writing + 0, // do not share + NULL, // default security + OPEN_ALWAYS, // create new file only + FILE_ATTRIBUTE_NORMAL, // normal file + NULL); // no attr. template if (h_file == INVALID_HANDLE_VALUE) return false; else diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 8f932e10..00a4c9ff 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -65,6 +65,7 @@ DISABLE_VS_WARNINGS(4100) #include "syncobj.h" #include "sync_locked_object.h" +#include "string_coding.h" #define LOG_LEVEL_SILENT -1 @@ -694,13 +695,13 @@ namespace log_space class file_output_stream : public ibase_log_stream { public: - typedef std::map named_log_streams; + typedef std::map named_log_streams; - file_output_stream( std::string default_log_file_name, std::string log_path ) + file_output_stream( const std::string& default_log_file_name, const std::string& log_path ) { m_default_log_filename = default_log_file_name; m_max_logfile_size = 0; - m_default_log_path = log_path; + m_default_log_path_w = epee::string_encoding::utf8_to_wstring(log_path); m_pdefault_file_stream = add_new_stream_and_open(default_log_file_name.c_str()); } @@ -718,20 +719,22 @@ namespace log_space } private: named_log_streams m_log_file_names; - std::string m_default_log_path; - std::ofstream* m_pdefault_file_stream; + std::wstring m_default_log_path_w; + boost::filesystem::ofstream* m_pdefault_file_stream; std::string m_log_rotate_cmd; std::string m_default_log_filename; uint64_t m_max_logfile_size; - std::ofstream* add_new_stream_and_open(const char* pstream_name) + // gets utf-8 encoded string + boost::filesystem::ofstream* add_new_stream_and_open(const char* pstream_name) { //log_space::rotate_log_file((m_default_log_path + "\\" + pstream_name).c_str()); boost::system::error_code ec; - boost::filesystem::create_directories(m_default_log_path, ec); - std::ofstream* pstream = (m_log_file_names[pstream_name] = new std::ofstream); - std::string target_path = m_default_log_path + "/" + pstream_name; + boost::filesystem::create_directories(m_default_log_path_w, ec); + boost::filesystem::ofstream* pstream = (m_log_file_names[pstream_name] = new boost::filesystem::ofstream); + std::wstring target_path = m_default_log_path_w + L"/" + epee::string_encoding::utf8_to_wstring(pstream_name); + pstream->open( target_path.c_str(), std::ios_base::out | std::ios::app /*ios_base::trunc */); if(pstream->fail()) return NULL; @@ -754,7 +757,7 @@ namespace log_space virtual bool out_buffer( const char* buffer, int buffer_len, int log_level, int color, const char* plog_name = NULL ) { - std::ofstream* m_target_file_stream = m_pdefault_file_stream; + boost::filesystem::ofstream* m_target_file_stream = m_pdefault_file_stream; if(plog_name) { //find named stream named_log_streams::iterator it = m_log_file_names.find(plog_name); @@ -769,9 +772,10 @@ namespace log_space m_target_file_stream->write(buffer, buffer_len ); m_target_file_stream->flush(); + /* if(m_max_logfile_size) { - std::ofstream::pos_type pt = m_target_file_stream->tellp(); + boost::filesystem::ofstream::pos_type pt = m_target_file_stream->tellp(); uint64_t current_sz = pt; if(current_sz > m_max_logfile_size) { @@ -818,12 +822,13 @@ namespace log_space misc_utils::call_sys_cmd(m_log_rotate_cmd_local_copy); } - m_target_file_stream->open( (m_default_log_path + "/" + log_file_name).c_str(), std::ios_base::out | std::ios::app /*ios_base::trunc */); + + m_target_file_stream->open( (m_default_log_path + "/" + log_file_name).c_str(), std::ios_base::out | std::ios::app / * ios_base::trunc * /); if(m_target_file_stream->fail()) return false; } } - + */ return true; } int get_type(){return LOGGER_FILE;} diff --git a/src/common/db_backend_lmdb.cpp b/src/common/db_backend_lmdb.cpp index fdb289ff..6c913f34 100644 --- a/src/common/db_backend_lmdb.cpp +++ b/src/common/db_backend_lmdb.cpp @@ -49,10 +49,6 @@ namespace tools CHECK_AND_ASSERT_MESS_LMDB_DB(res, false, "Unable to mdb_env_set_mapsize"); m_path = path_; -#ifdef WIN32 - m_path = epee::string_encoding::convert_ansii_to_utf8(m_path); -#endif - CHECK_AND_ASSERT_MES(tools::create_directories_if_necessary(m_path), false, "create_directories_if_necessary failed: " << m_path); res = mdb_env_open(m_penv, m_path.c_str(), MDB_NORDAHEAD , 0644); diff --git a/src/common/util.cpp b/src/common/util.cpp index 48fd7588..999c5401 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -24,6 +24,8 @@ using namespace epee; #include +#include "string_coding.h" + namespace tools { std::function signal_handler::m_handler; @@ -450,18 +452,22 @@ std::string get_nix_version_display_string() #ifdef WIN32 - std::string get_special_folder_path(int nfolder, bool iscreate) + std::wstring get_special_folder_path_w(int nfolder, bool iscreate) { - namespace fs = boost::filesystem; - char psz_path[MAX_PATH] = ""; + wchar_t psz_path[MAX_PATH] = L""; - if(SHGetSpecialFolderPathA(NULL, psz_path, nfolder, iscreate)) + if (SHGetSpecialFolderPathW(NULL, psz_path, nfolder, iscreate)) { return psz_path; } - LOG_ERROR("SHGetSpecialFolderPathA() failed, could not obtain requested path."); - return ""; + LOG_ERROR("SHGetSpecialFolderPathW(" << nfolder << ", " << iscreate << ") failed, could not obtain requested path."); + return L""; + } + + std::string get_special_folder_path_utf8(int nfolder, bool iscreate) + { + return epee::string_encoding::wstring_to_utf8(get_special_folder_path_w(nfolder, iscreate)); } #endif @@ -476,9 +482,9 @@ std::string get_nix_version_display_string() #ifdef WIN32 // Windows #ifdef _M_X64 - config_folder = get_special_folder_path(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT; + config_folder = get_special_folder_path_utf8(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT; #else - config_folder = get_special_folder_path(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT + "-x86"; + config_folder = get_special_folder_path_utf8(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT + "-x86"; #endif #else std::string pathRet; @@ -518,7 +524,7 @@ std::string get_nix_version_display_string() std::string wallets_dir; #ifdef WIN32 // Windows - wallets_dir = get_special_folder_path(CSIDL_PERSONAL, true) + "/" + CURRENCY_NAME_BASE; + wallets_dir = get_special_folder_path_utf8(CSIDL_PERSONAL, true) + "/" + CURRENCY_NAME_BASE; #else std::string pathRet; char* pszHome = getenv("HOME"); @@ -553,7 +559,7 @@ std::string get_nix_version_display_string() { namespace fs = boost::filesystem; boost::system::error_code ec; - fs::path fs_path(path); + fs::path fs_path = epee::string_encoding::utf8_to_wstring(path); if (fs::is_directory(fs_path, ec)) { return true; diff --git a/src/currency_core/currency_core.cpp b/src/currency_core/currency_core.cpp index 54b93443..a79dfb2a 100644 --- a/src/currency_core/currency_core.cpp +++ b/src/currency_core/currency_core.cpp @@ -18,6 +18,7 @@ using namespace epee; #include "currency_core/currency_config.h" #include "currency_format_utils.h" #include "misc_language.h" +#include "string_coding.h" #define MINIMUM_REQUIRED_FREE_SPACE_BYTES (1024 * 1024 * 100) @@ -717,10 +718,27 @@ namespace currency //----------------------------------------------------------------------------------------------- bool core::check_if_free_space_critically_low(uint64_t* p_available_space /* = nullptr */) { - boost::filesystem::space_info si = boost::filesystem::space(m_config_folder); - if (p_available_space != nullptr) - *p_available_space = si.available; - return si.available < MINIMUM_REQUIRED_FREE_SPACE_BYTES; + namespace fs = boost::filesystem; + + try + { + CHECK_AND_ASSERT_MES(tools::create_directories_if_necessary(m_config_folder), false, "create_directories_if_necessary failed: " << m_config_folder); + std::wstring config_folder_w = epee::string_encoding::utf8_to_wstring(m_config_folder); + fs::space_info si = fs::space(config_folder_w); + if (p_available_space != nullptr) + *p_available_space = si.available; + return si.available < MINIMUM_REQUIRED_FREE_SPACE_BYTES; + } + catch (std::exception& e) + { + LOG_ERROR("failed to determine free space: " << e.what()); + return false; + } + catch (...) + { + LOG_ERROR("failed to determine free space: unknown exception"); + return false; + } } void core::check_free_space() diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 45c77b65..db6e604f 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -154,11 +154,6 @@ namespace return message_writer(color ? epee::log_space::console_color_green : epee::log_space::console_color_default, false, std::string(), LOG_LEVEL_2); } - message_writer success_msg_writer(epee::log_space::console_colors color) - { - return message_writer(color, true, std::string(), LOG_LEVEL_2); - } - message_writer fail_msg_writer() { return message_writer(epee::log_space::console_color_red, true, "Error: ", LOG_LEVEL_0); diff --git a/src/version.h.in b/src/version.h.in index b685d4a8..68442457 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -7,6 +7,6 @@ #define PROJECT_REVISION "0" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 57 +#define PROJECT_VERSION_BUILD_NO 58 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 15a36e4d..3bb392c3 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1890,7 +1890,7 @@ void wallet2::load_keys2ki(bool create_if_not_exist, bool& need_to_resync) m_pending_key_images.clear(); for (size_t i = 0, size = m_pending_key_images_file_container.size(); i < size; ++i) { - out_key_to_ki item = AUTO_VAL_INIT(item); + out_key_to_ki item = AUTO_VAL_INIT_T(out_key_to_ki); ok = m_pending_key_images_file_container.get_item(i, item); WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(ok, "m_pending_key_images_file_container.get_item() failed for index " << i << ", size: " << m_pending_key_images_file_container.size()); ok = m_pending_key_images.insert(std::make_pair(item.out_key, item.key_image)).second; @@ -4002,7 +4002,7 @@ void wallet2::prepare_transaction(const construct_tx_param& ctp, finalize_tx_par //---------------------------------------------------------------------------------------------------- void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::transaction& tx, crypto::secret_key& tx_key, bool broadcast_tx) { - TIME_MEASURE_START_MS(construct_tx_time); + //TIME_MEASURE_START_MS(construct_tx_time); bool r = currency::construct_tx(m_account.get_keys(), ftp.sources, ftp.prepared_destinations, @@ -4016,10 +4016,10 @@ void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::trans ftp.tx_outs_attr, ftp.shuffle, ftp.flags); - TIME_MEASURE_FINISH_MS(construct_tx_time); + //TIME_MEASURE_FINISH_MS(construct_tx_time); THROW_IF_FALSE_WALLET_EX(r, error::tx_not_constructed, ftp.sources, ftp.prepared_destinations, ftp.unlock_time); - TIME_MEASURE_START_MS(sign_ms_input_time); + //TIME_MEASURE_START_MS(sign_ms_input_time); if (ftp.multisig_id != currency::null_hash) { // In case there's multisig input is used -- sign it partially with this wallet's keys (we don't have any others here). @@ -4031,21 +4031,21 @@ void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::trans r = sign_multisig_input_in_tx(tx, 0, m_account.get_keys(), ms_source_tx, &is_tx_input_fully_signed); // it's assumed that ms input is the first one (index 0) WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(r && !is_tx_input_fully_signed, "sign_multisig_input_in_tx failed: r = " << r << ", is_tx_input_fully_signed = " << is_tx_input_fully_signed); } - TIME_MEASURE_FINISH_MS(sign_ms_input_time); + //TIME_MEASURE_FINISH_MS(sign_ms_input_time); m_tx_keys.insert(std::make_pair(get_transaction_hash(tx), tx_key)); THROW_IF_FALSE_WALLET_EX(get_object_blobsize(tx) < CURRENCY_MAX_TRANSACTION_BLOB_SIZE, error::tx_too_big, tx, m_upper_transaction_size_limit); - TIME_MEASURE_START(send_transaction_to_network_time); + //TIME_MEASURE_START(send_transaction_to_network_time); if (broadcast_tx) send_transaction_to_network(tx); - TIME_MEASURE_FINISH(send_transaction_to_network_time); + //TIME_MEASURE_FINISH(send_transaction_to_network_time); - TIME_MEASURE_START(add_sent_tx_detailed_info_time); + //TIME_MEASURE_START(add_sent_tx_detailed_info_time); if (broadcast_tx) add_sent_tx_detailed_info(tx, ftp.prepared_destinations, ftp.selected_transfers); - TIME_MEASURE_FINISH(add_sent_tx_detailed_info_time); + //TIME_MEASURE_FINISH(add_sent_tx_detailed_info_time); /* TODO WLT_LOG_GREEN("[prepare_transaction]: get_needed_money_time: " << get_needed_money_time << " ms"