Everywhere: Change exclude path configuration formatting
This commit is contained in:
@@ -89,12 +89,4 @@ void from_json(const nlohmann::json& object, Settings& settings)
|
||||
if (object.find("systemDirectories") != object.end()) {
|
||||
object.at("systemDirectories").get_to(settings.systemDirectories);
|
||||
}
|
||||
|
||||
// Check for correct exclude type values
|
||||
for (const auto& path : settings.excludePaths) {
|
||||
if (path.second != "file" && path.second != "directory" && path.second != "endsWith") {
|
||||
fprintf(stderr, "\033[31;1mConfig:\033[0m invalid exclude type '%s'\n", path.second.c_str());
|
||||
raise(SIGABRT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <filesystem> // path
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -18,12 +17,13 @@
|
||||
#include "util/singleton.h"
|
||||
|
||||
struct Settings {
|
||||
std::map<std::string, std::string> excludePaths {
|
||||
{ ".git", "directory" },
|
||||
{ ".md", "endsWith" },
|
||||
{ "packages", "file" },
|
||||
{ "README.org", "endsWith" },
|
||||
{ "screenshot.png", "file" },
|
||||
std::vector<std::string> excludePaths {
|
||||
".git/",
|
||||
"*.md",
|
||||
"manafiles.json",
|
||||
"packages",
|
||||
"README.org",
|
||||
"screenshot.png",
|
||||
};
|
||||
std::vector<std::filesystem::path> systemDirectories {
|
||||
"/boot",
|
||||
@@ -38,10 +38,10 @@ public:
|
||||
virtual ~Config();
|
||||
|
||||
void setSystemDirectories(const std::vector<std::filesystem::path>& systemDirectories) { m_settings.systemDirectories = systemDirectories; }
|
||||
void setExcludePaths(const std::map<std::string, std::string>& excludePaths) { m_settings.excludePaths = excludePaths; }
|
||||
void setExcludePaths(const std::vector<std::string>& excludePaths) { m_settings.excludePaths = excludePaths; }
|
||||
void setVerbose(bool verbose) { m_verbose = verbose; }
|
||||
|
||||
const std::map<std::string, std::string>& excludePaths() const { return m_settings.excludePaths; }
|
||||
const std::vector<std::string>& excludePaths() const { return m_settings.excludePaths; }
|
||||
const std::vector<std::filesystem::path>& systemDirectories() const { return m_settings.systemDirectories; }
|
||||
|
||||
const std::filesystem::path& workingDirectory() const { return m_workingDirectory; }
|
||||
|
||||
+1
-2
@@ -115,8 +115,7 @@ bool Dotfile::filter(const std::filesystem::directory_entry& path)
|
||||
size_t cutFrom = pathString.find(Config::the().workingDirectory()) == 0 ? Config::the().workingDirectorySize() : 0;
|
||||
pathString = pathString.substr(cutFrom);
|
||||
|
||||
for (const auto& excludePathMapEntry : Config::the().excludePaths()) {
|
||||
const auto& excludePath = excludePathMapEntry.first;
|
||||
for (const auto& excludePath : Config::the().excludePaths()) {
|
||||
|
||||
if (pathString == excludePath) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user