From 88e56987d55c492034f4efada9a2f6d6d120be6b Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Tue, 1 Dec 2015 17:34:49 +0100 Subject: [PATCH] windows: GUI index config: convert backslashes in skippedPaths --- src/qtgui/confgui/confgui.cpp | 16 ++++++++++++++-- src/utils/pathut.cpp | 14 +++++++------- src/utils/pathut.h | 5 +++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/qtgui/confgui/confgui.cpp b/src/qtgui/confgui/confgui.cpp index 131adf5c..f81665f4 100644 --- a/src/qtgui/confgui/confgui.cpp +++ b/src/qtgui/confgui/confgui.cpp @@ -376,15 +376,27 @@ void ConfParamSLW::showInputDialog() void ConfParamSLW::listToConf() { list ls; + LOGDEB2(("ConfParamSLW::listToConf. m_fsencoding %d\n", int(m_fsencoding))); for (int i = 0; i < m_lb->count(); i++) { // General parameters are encoded as utf-8. File names as // local8bit There is no hope for 8bit file names anyway // except for luck: the original encoding is unknown. + // As a special Windows hack, if fsencoding is set, we convert + // backslashes to slashes. This is an awful hack because + // fsencoding does not necessarily imply that the values are + // paths, and it will come back to haunt us one day. QString text = m_lb->item(i)->text(); - if (m_fsencoding) + if (m_fsencoding) { +#ifdef _WIN32 + string pth((const char *)(text.toLocal8Bit())); + path_slashize(pth); + ls.push_back(pth); +#else ls.push_back((const char *)(text.toLocal8Bit())); - else +#endif + } else { ls.push_back((const char *)(text.toUtf8())); + } } string s; stringsToString(ls, s); diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 8e09f43e..1697e031 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -123,7 +123,7 @@ string path_tchartoutf8(TCHAR *text) string path_thisexecpath() { TCHAR text[MAX_PATH]; - DWORD length = GetModuleFileName(NULL, text, MAX_PATH); + GetModuleFileName(NULL, text, MAX_PATH); #ifdef NTDDI_WIN8_future PathCchRemoveFileSpec(text, MAX_PATH); #else @@ -162,9 +162,9 @@ bool fsocc(const string &path, int *pc, long long *avmbs) return false; } if (pc) - *pc = int(100 * double(freebytesavail) / double(totalbytes)); + *pc = int((100 * freebytesavail.QuadPart) / totalbytes.QuadPart); if (avmbs) - *avmbs = totalbytes / FSOCC_MB; + *avmbs = int(totalbytes.QuadPart / FSOCC_MB); return true; #else #ifdef sun @@ -398,7 +398,7 @@ bool TempDir::wipe() void path_catslash(string &s) { -#ifdef WIN32 +#ifdef _WIN32 path_slashize(s); #endif if (s.empty() || s[s.length() - 1] != '/') @@ -416,7 +416,7 @@ string path_cat(const string &s1, const string &s2) string path_getfather(const string &s) { string father = s; -#ifdef WIN32 +#ifdef _WIN32 path_slashize(father); #endif @@ -444,7 +444,7 @@ string path_getfather(const string &s) string path_getsimple(const string &s) { string simple = s; -#ifdef WIN32 +#ifdef _WIN32 path_slashize(simple); #endif @@ -544,7 +544,7 @@ string path_tildexpand(const string &s) if (s.empty() || s[0] != '~') return s; string o = s; -#ifdef WIN32 +#ifdef _WIN32 path_slashize(o); #endif diff --git a/src/utils/pathut.h b/src/utils/pathut.h index 4e4ad1ab..a8c03d1f 100644 --- a/src/utils/pathut.h +++ b/src/utils/pathut.h @@ -121,6 +121,11 @@ extern bool path_isroot(const std::string& p); /// Turn absolute path into file:// url extern std::string path_pathtofileurl(const std::string& path); +#ifdef _WIN32 +/// Convert \ separators to / +void path_slashize(std::string& s); +#endif + /// Temporary file class class TempFileInternal { public: