git repos / PlatformFolders

commit 34cc125e

Poul Sander · 2019-03-07 19:49
34cc125ea75d791eb7e4253c65ebf79985ec8b66 patch · browse files
parent 386db851ccd52b4be991b159621e749e33eeae96
parent c7c13350ee90c7626953daca7071ea91b8525a24

Merge pull request #17 from sum01/fix_win_utf_function

Fix win utf function

Changed files

M sago/platform_folders.cpp before
M sago/platform_folders.h before
diff --git a/sago/platform_folders.cpp b/sago/platform_folders.cpp index 0917284..5f419f1 100644 --- a/sago/platform_folders.cpp +++ b/sago/platform_folders.cpp
@@ -72,7 +72,7 @@ static std::string getHome() {
return res;
}
-#endif
+#endif
#ifdef _WIN32
// Make sure we don't bring in all the extra junk with windows.h
@@ -91,7 +91,7 @@ static std::string getHome() {
namespace sago {
namespace internal {
-static std::string win32_utf16_to_utf8(const wchar_t* wstr) {
+std::string win32_utf16_to_utf8(const wchar_t* wstr) {
std::string res;
// If the 6th parameter is 0 then WideCharToMultiByte returns the number of bytes needed to store the result.
int actualSize = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
@@ -191,21 +191,21 @@ namespace sago {
#if !defined(_WIN32) && !defined(__APPLE__)
namespace internal {
- void appendExtraFoldersTokenizer(const char* envName, const char* envValue, std::vector<std::string>& folders) {
- std::stringstream ss(envValue);
- std::string value;
- while (std::getline(ss, value, ':')) {
- if (value[0] == '/') {
- folders.push_back(value);
- }
- else {
- //Unless the system is wrongly configured this should never happen... But of course some systems will be incorectly configured.
- //The XDG documentation indicates that the folder should be ignored but that the program should continue.
- std::cerr << "Skipping path \"" << value << "\" in \"" << envName << "\" because it does not start with a \"/\"\n";
- }
+void appendExtraFoldersTokenizer(const char* envName, const char* envValue, std::vector<std::string>& folders) {
+ std::stringstream ss(envValue);
+ std::string value;
+ while (std::getline(ss, value, ':')) {
+ if (value[0] == '/') {
+ folders.push_back(value);
+ }
+ else {
+ //Unless the system is wrongly configured this should never happen... But of course some systems will be incorectly configured.
+ //The XDG documentation indicates that the folder should be ignored but that the program should continue.
+ std::cerr << "Skipping path \"" << value << "\" in \"" << envName << "\" because it does not start with a \"/\"\n";
}
}
}
+}
#endif
std::string getDataHome() {
@@ -273,7 +273,8 @@ static void PlatformFoldersAddFromFile(const std::string& filename, std::map<std
std::size_t valueEnd = line.find('"', valueStart+1);
std::string value = line.substr(valueStart+1, valueEnd - valueStart - 1);
folders[key] = value;
- } catch (std::exception& e) {
+ }
+ catch (std::exception& e) {
std::cerr << "WARNING: Failed to process \"" << line << "\" from \"" << filename << "\". Error: "<< e.what() << "\n";
continue;
}
diff --git a/sago/platform_folders.h b/sago/platform_folders.h index a9a6477..4563410 100644 --- a/sago/platform_folders.h +++ b/sago/platform_folders.h
@@ -39,12 +39,12 @@ namespace sago {
#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace internal {
- #if !defined(_WIN32) && !defined(__APPLE__)
- void appendExtraFoldersTokenizer(const char* envName, const char* envValue, std::vector<std::string>& folders);
- #endif
- #ifdef _WIN32
- std::string win32_utf16_to_utf8(const wchar_t* wstr);
- #endif
+#if !defined(_WIN32) && !defined(__APPLE__)
+void appendExtraFoldersTokenizer(const char* envName, const char* envValue, std::vector<std::string>& folders);
+#endif
+#ifdef _WIN32
+std::string win32_utf16_to_utf8(const wchar_t* wstr);
+#endif
}
#endif //DOXYGEN_SHOULD_SKIP_THIS
@@ -225,7 +225,7 @@ public:
*/
std::string getPicturesFolder() const;
/**
- * Use sago::getPublicFolder() instead!
+ * Use sago::getPublicFolder() instead!
*/
std::string getPublicFolder() const;
/**