[filesystem] Moved generic methods to platform independent code

This commit is contained in:
Marco Rodolfi 2025-01-17 09:19:41 +01:00
parent d7ffa408dd
commit d395891fc9
2 changed files with 23 additions and 23 deletions

View File

@ -24,5 +24,28 @@ bool CreateParentFolder(const std::filesystem::path& path) {
return true;
}
std::vector<FileInfo> ListDirectories(const std::filesystem::path& path) {
std::vector<FileInfo> files = ListFiles(path);
std::vector<FileInfo> directories = {};
std::copy_if(
files.cbegin(), files.cend(), std::back_inserter(directories),
[](const FileInfo& file) { return file.type == FileInfo::Type::kDirectory; });
return std::move(directories);
}
std::vector<FileInfo> FilterByName(const std::vector<FileInfo>& files,
const std::regex pattern) {
std::vector<FileInfo> filtered_entries = {};
std::copy_if(files.cbegin(), files.cend(),
std::back_inserter(filtered_entries), [pattern](const FileInfo& file) {
return std::regex_match(file.name.filename().string(),
pattern);
});
return std::move(filtered_entries);
}
} // namespace filesystem
} // namespace xe

View File

@ -250,29 +250,6 @@ std::vector<FileInfo> ListFiles(const std::filesystem::path& path) {
return std::move(result);
}
std::vector<FileInfo> ListDirectories(const std::filesystem::path& path) {
std::vector<FileInfo> files = ListFiles(path);
std::vector<FileInfo> directories = {};
std::copy_if(
files.cbegin(), files.cend(), std::back_inserter(directories),
[](const FileInfo& file) { return file.type == FileInfo::Type::kDirectory; });
return std::move(directories);
}
std::vector<FileInfo> FilterByName(const std::vector<FileInfo>& files,
const std::regex pattern) {
std::vector<FileInfo> filtered_entries = {};
std::copy_if(files.cbegin(), files.cend(),
std::back_inserter(filtered_entries), [pattern](const FileInfo& file) {
return std::regex_match(file.name.filename().string(),
pattern);
});
return std::move(filtered_entries);
}
bool SetAttributes(const std::filesystem::path& path, uint64_t attributes) {
return false;
}