|
|
|
@ -26,7 +26,7 @@ Dotfile::~Dotfile()
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
void Dotfile::list() |
|
|
|
|
void Dotfile::list(const std::vector<std::string>& targets) |
|
|
|
|
{ |
|
|
|
|
if (s_workingDirectory.empty()) { |
|
|
|
|
fprintf(stderr, "\033[31;1mDotfile:\033[0m working directory is unset\n"); |
|
|
|
@ -43,6 +43,9 @@ void Dotfile::list()
|
|
|
|
|
if (path.is_directory() || filter(path)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (!targets.empty() && !include(path.path().string(), targets)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
printf("%s\n", path.path().c_str() + workingDirectory); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -72,4 +75,15 @@ bool Dotfile::filter(const std::filesystem::path& path)
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Dotfile::include(const std::filesystem::path& path, const std::vector<std::string>& targets) |
|
|
|
|
{ |
|
|
|
|
for (const auto& target : targets) { |
|
|
|
|
if (path.string().find(s_workingDirectory / target) == 0) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace Util
|
|
|
|
|