commit 880fc26f
Backported PlatformFoldersAddFromFile from 4.0.0 in case someone needs a 3.X.X version
Changed files
| M | CMakeLists.txt before |
| M | doxygen.conf before |
| M | sago/platform_folders.cpp before |
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28a8297..ceee0e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
-project(platform_folders VERSION 3.2.0 LANGUAGES CXX)
+project(platform_folders VERSION 3.2.1 LANGUAGES CXX)
# Since it's off, the library will be static by default
option(BUILD_SHARED_LIBS "Build shared instead of static." OFF)
diff --git a/doxygen.conf b/doxygen.conf
index 88aa44e..db05267 100644
--- a/doxygen.conf
+++ b/doxygen.conf
@@ -38,7 +38,7 @@ PROJECT_NAME = "Platform folders"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = "3.2.0"
+PROJECT_NUMBER = "3.2.1"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/sago/platform_folders.cpp b/sago/platform_folders.cpp
index 34e6bae..f55e4ad 100644
--- a/sago/platform_folders.cpp
+++ b/sago/platform_folders.cpp
@@ -236,14 +236,20 @@ static void PlatformFoldersAddFromFile(const std::string& filename, std::map<std
std::ifstream infile(filename.c_str());
std::string line;
while (std::getline(infile, line)) {
- if (line.length() == 0 || line.at(0) == '#') {
+ if (line.length() == 0 || line.at(0) == '#' || line.substr(0, 4) != "XDG_" || line.find("_DIR") == std::string::npos) {
+ continue;
+ }
+ try {
+ std::size_t splitPos = line.find('=');
+ std::string key = line.substr(0, splitPos);
+ std::size_t valueStart = line.find('"', splitPos);
+ 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) {
+ std::cerr << "WARNING: Failed to process \"" << line << "\" from \"" << filename << "\". Error: "<< e.what() << "\n";
continue;
}
- std::size_t splitPos = line.find("=");
- std::string key = line.substr(0, splitPos);
- std::string value = line.substr(splitPos+2, line.length()-splitPos-3);
- folders[key] = value;
- //std::cout << key << " : " << value << "\n";
}
}