mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Load files from subfolders in texturepacks
Updated and rebased version of a PR by red-001
This commit is contained in:
parent
ae9b1aa177
commit
05d93c7fa1
7 changed files with 63 additions and 19 deletions
|
@ -380,15 +380,36 @@ std::string TempPath()
|
|||
|
||||
#endif
|
||||
|
||||
void GetRecursiveSubPaths(const std::string &path, std::vector<std::string> &dst)
|
||||
void GetRecursiveDirs(std::vector<std::string> &dirs, const std::string &dir)
|
||||
{
|
||||
static const std::set<char> chars_to_ignore = { '_', '.' };
|
||||
if (dir.empty() || !IsDir(dir))
|
||||
return;
|
||||
dirs.push_back(dir);
|
||||
fs::GetRecursiveSubPaths(dir, dirs, false, chars_to_ignore);
|
||||
}
|
||||
|
||||
std::vector<std::string> GetRecursiveDirs(const std::string &dir)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
GetRecursiveDirs(result, dir);
|
||||
return result;
|
||||
}
|
||||
|
||||
void GetRecursiveSubPaths(const std::string &path,
|
||||
std::vector<std::string> &dst,
|
||||
bool list_files,
|
||||
const std::set<char> &ignore)
|
||||
{
|
||||
std::vector<DirListNode> content = GetDirListing(path);
|
||||
for (const auto &n : content) {
|
||||
std::string fullpath = path + DIR_DELIM + n.name;
|
||||
dst.push_back(fullpath);
|
||||
if (n.dir) {
|
||||
GetRecursiveSubPaths(fullpath, dst);
|
||||
}
|
||||
if (ignore.count(n.name[0]))
|
||||
continue;
|
||||
if (list_files || n.dir)
|
||||
dst.push_back(fullpath);
|
||||
if (n.dir)
|
||||
GetRecursiveSubPaths(fullpath, dst, list_files, ignore);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue