gnucash master: Amend previous commit
Geert Janssens
gjanssens at code.gnucash.org
Mon Sep 4 17:13:43 EDT 2017
Updated via https://github.com/Gnucash/gnucash/commit/d96bb3eb (commit)
from https://github.com/Gnucash/gnucash/commit/d6677ff3 (commit)
commit d96bb3ebd5f31ed81e9dab156e966296e15842f7
Author: Geert Janssens <geert at kobaltwit.be>
Date: Mon Sep 4 22:04:04 2017 +0200
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.
diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt
index 9800a41..710d39a 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 9103e20..8bbca8d 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 <codecvt>
-#include <string>
#include <boost/filesystem.hpp>
+#if PLATFORM(WINDOWS)
+#include <codecvt>
+#include <locale>
+#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<std::codecvt_utf8<wchar_t>> 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<std::codecvt_utf8<wchar_t>> 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];
Summary of changes:
libgnucash/core-utils/CMakeLists.txt | 7 +----
libgnucash/core-utils/gnc-filepath-utils.cpp | 40 ++++++++++------------------
2 files changed, 15 insertions(+), 32 deletions(-)
More information about the gnucash-changes
mailing list