From d96bb3ebd5f31ed81e9dab156e966296e15842f7 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 4 Sep 2017 22:04:04 +0200 Subject: [PATCH] Amend previous commit The utf8 conversion is only used in the Windows specific section so there's no need to define an overloaded function on std::string in this case. Also CMakeLists.txt doesn't require the MingW specific library name setting for boost::filesystem. Just removing the hardcoded one allows the build to pick the right name up from the Boost_LIBRARIES variable. --- libgnucash/core-utils/CMakeLists.txt | 7 +--- libgnucash/core-utils/gnc-filepath-utils.cpp | 40 +++++++------------- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt index 9800a415fc..710d39a226 100644 --- a/libgnucash/core-utils/CMakeLists.txt +++ b/libgnucash/core-utils/CMakeLists.txt @@ -116,13 +116,8 @@ SET(core_utils_noinst_HEADERS gnc-path.h ) -if (MINGW64) - SET(BOOST_FILESYSTEM -lboost_filesystem-mt) -else() - SET(BOOST_FILESYSTEM -lboost_filesystem) -endif() SET(core_utils_ALL_SOURCES ${core_utils_SOURCES} ${core_utils_noinst_HEADERS}) -SET(core_utils_ALL_LIBRARIES ${Boost_LIBRARIES} ${BOOST_FILESYSTEM} ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS} ${GOBJECT_LDFLAGS} ${GTK_MAC_LDFLAGS}) +SET(core_utils_ALL_LIBRARIES ${Boost_LIBRARIES} ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS} ${GOBJECT_LDFLAGS} ${GTK_MAC_LDFLAGS}) SET(core_utils_ALL_INCLUDES ${CMAKE_SOURCE_DIR}/common ${CMAKE_BINARY_DIR}/common diff --git a/libgnucash/core-utils/gnc-filepath-utils.cpp b/libgnucash/core-utils/gnc-filepath-utils.cpp index 9103e20fc2..8bbca8d3fe 100644 --- a/libgnucash/core-utils/gnc-filepath-utils.cpp +++ b/libgnucash/core-utils/gnc-filepath-utils.cpp @@ -61,31 +61,16 @@ extern "C" { #endif } -#include -#include #include +#if PLATFORM(WINDOWS) +#include +#include +#endif + namespace bfs = boost::filesystem; namespace bst = boost::system; -/* - * Converts UTF16 to UTF8. Pinched from Nicolai M. Josuttis, "The C++ - * Standard Library, Second Edition", 2012, Addison-Wesley. - */ -static std::string utf8(const std::wstring& str) -{ - std::wstring_convert> myconv; - return myconv.to_bytes(str); -} - -/* - * Does nothing, it's just here so to save a bunch of ifdefs later. - */ -static std::string utf8(const std::string& str) -{ - return str; -} - /** * Scrubs a filename by changing "strange" chars (e.g. those that are not * valid in a win32 file name) to "_". @@ -394,7 +379,7 @@ copy_recursive(const bfs::path& src, const bfs::path& dest) { g_warning("An error occured while trying to migrate the user configation from\n%s to\n%s" "The reported failure is\n%s", - src.c_str(), gnc_userdata_home.string(), + src.string().c_str(), gnc_userdata_home.string().c_str(), ex.what()); return false; } @@ -408,30 +393,33 @@ copy_recursive(const bfs::path& src, const bfs::path& dest) * So this function is a copy of glib's internal get_special_folder * and minimally adjusted to fetch CSIDL_APPDATA */ -static gchar * +static char * win32_get_userdata_home (void) { wchar_t path[MAX_PATH+1]; HRESULT hr; LPITEMIDLIST pidl = NULL; BOOL b; - gchar *retval = NULL; + char *retval = NULL; hr = SHGetSpecialFolderLocation (NULL, CSIDL_APPDATA, &pidl); if (hr == S_OK) { b = SHGetPathFromIDListW (pidl, path); if (b) - retval = g_strdup(utf8(path).c_str()); + { + std::wstring_convert> utf8_conv; + retval = g_strdup(utf8_conv.to_bytes(path).c_str()); + } CoTaskMemFree (pidl); } return retval; } #elif defined MAC_INTEGRATION -static gchar* +static char* quarz_get_userdata_home(void) { - gchar *retval = NULL; + char *retval = NULL; NSFileManager*fm = [NSFileManager defaultManager]; NSArray* appSupportDir = [fm URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];