nothing fixed
This commit is contained in:
parent
44aaf183e7
commit
6d5610c05c
|
@ -3,16 +3,23 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
bool TreeStructurer::should_ignore_dir(const std::string& dirname) {
|
bool TreeStructurer::should_ignore_dir(const std::string& dirname) {
|
||||||
static const std::vector<std::string> ignore_list = {
|
static const std::vector<std::string> ignore_list = {
|
||||||
"build", "venv", "myenv", "dist", "node_modules", "CMakeFiles",
|
"build", "venv", "myenv", "dist", "node_modules", "CMakeFiles",
|
||||||
".git", ".idea", ".vscode", "__pycache__"
|
".git", ".idea", ".vscode", "__pycache__"
|
||||||
};
|
};
|
||||||
|
|
||||||
return dirname[0] == '.' ||
|
// Ignore directories in the ignore list
|
||||||
dirname[0] == '_' || // This will catch __pycache__ and _directories
|
if (std::find(ignore_list.begin(), ignore_list.end(), dirname) != ignore_list.end()) {
|
||||||
std::find(ignore_list.begin(), ignore_list.end(), dirname) != ignore_list.end();
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore directories starting with '.' or '_'
|
||||||
|
if (!dirname.empty() && (dirname[0] == '.' || dirname[0] == '_')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeStructurer::should_ignore_file(const std::string& filename) {
|
bool TreeStructurer::should_ignore_file(const std::string& filename) {
|
||||||
|
@ -20,45 +27,61 @@ bool TreeStructurer::should_ignore_file(const std::string& filename) {
|
||||||
".pyc", ".pyo", ".pyd", ".so", ".dll", ".dylib",
|
".pyc", ".pyo", ".pyd", ".so", ".dll", ".dylib",
|
||||||
".o", ".obj", ".a", ".lib"
|
".o", ".obj", ".a", ".lib"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (filename[0] == '.') return true;
|
// Ignore files starting with '.' or '_'
|
||||||
|
if (!filename.empty() && (filename[0] == '.' || filename[0] == '_')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore files with specific extensions
|
||||||
fs::path path(filename);
|
fs::path path(filename);
|
||||||
std::string ext = path.extension().string();
|
std::string ext = path.extension().string();
|
||||||
return std::find(ignore_extensions.begin(), ignore_extensions.end(), ext) != ignore_extensions.end();
|
if (std::find(ignore_extensions.begin(), ignore_extensions.end(), ext) != ignore_extensions.end()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<fs::path> TreeStructurer::get_filtered_paths(const fs::path& start) {
|
std::vector<fs::path> TreeStructurer::get_filtered_paths(const fs::path& start) {
|
||||||
std::vector<fs::path> paths;
|
std::vector<fs::path> paths;
|
||||||
|
|
||||||
for(const auto& entry : fs::recursive_directory_iterator(start)) {
|
for (const auto& entry : fs::recursive_directory_iterator(start)) {
|
||||||
const auto& path = entry.path();
|
const auto& path = entry.path();
|
||||||
bool should_include = true;
|
|
||||||
|
// Skip any path that contains an ignored directory
|
||||||
for(auto it = path.begin(); it != path.end(); ++it) {
|
bool contains_ignored_dir = false;
|
||||||
if(should_ignore_dir(it->string())) {
|
for (auto it = path.begin(); it != path.end(); ++it) {
|
||||||
should_include = false;
|
if (should_ignore_dir(it->string())) {
|
||||||
|
contains_ignored_dir = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (contains_ignored_dir) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(should_include) {
|
// Handle directories
|
||||||
if(fs::is_directory(path)) {
|
if (fs::is_directory(path)) {
|
||||||
if(!should_ignore_dir(path.filename().string())) {
|
if (!should_ignore_dir(path.filename().string())) {
|
||||||
paths.push_back(path);
|
paths.push_back(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
// Handle files
|
||||||
if(!should_ignore_file(path.filename().string())) {
|
else {
|
||||||
paths.push_back(path);
|
if (!should_ignore_file(path.filename().string())) {
|
||||||
}
|
paths.push_back(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(paths.begin(), paths.end());
|
std::sort(paths.begin(), paths.end());
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string TreeStructurer::create_indent(int level) {
|
std::string TreeStructurer::create_indent(int level) {
|
||||||
if (level == 0) return "";
|
if (level == 0) return "";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue