From 58bf5b98eee4b65bb340ab14d6d7591a4c49605f Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 23 Sep 2021 17:19:43 +0200 Subject: [PATCH] Manager: Add function to check if file is system type --- src/dotfile.cpp | 21 ++++++++++++--------- src/dotfile.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/dotfile.cpp b/src/dotfile.cpp index 94067af..6069630 100644 --- a/src/dotfile.cpp +++ b/src/dotfile.cpp @@ -45,7 +45,6 @@ void Dotfile::add(const std::vector& targets) std::vector systemTargets; // Separate home and system targets - bool isSystem = false; for (size_t i = 0; i < targets.size(); ++i) { if (!std::filesystem::is_regular_file(targets.at(i)) && !std::filesystem::is_directory(targets.at(i)) @@ -54,14 +53,7 @@ void Dotfile::add(const std::vector& targets) continue; } - isSystem = false; - for (const auto& systemDirectory : s_systemDirectories) { - if (targets.at(i).find(systemDirectory) == 0) { - isSystem = true; - } - } - - if (isSystem) { + if (isSystemTarget(targets.at(i))) { systemTargets.push_back(i); } else { @@ -218,4 +210,15 @@ bool Dotfile::include(const std::filesystem::path& path, const std::vector& targets, const std::function& callback); bool filter(const std::filesystem::path& path); bool include(const std::filesystem::path& path, const std::vector& targets); + bool isSystemTarget(const std::string& target); static std::vector s_excludePaths; static std::vector s_systemDirectories;