MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _dumpDirectories

Method _dumpDirectories

Engine/source/core/volume.cpp:598–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596}
597
598bool MountSystem::_dumpDirectories(DirectoryRef directory, Vector<StringTableEntry>& directories, S32 depth, bool noBasePath, S32 currentDepth, const Path& basePath)
599{
600 Vector<Torque::Path> directoryPaths;
601 if (!directory->dumpDirectories(directoryPaths))
602 {
603 return false;
604 }
605
606 // Queries against / will return a directory count of 1, but the code relies on actual directory entries (Eg. /data) so we handle that special case
607 const U32 basePathDirectoryCount = String::compare(basePath.getFullPathWithoutRoot(), "/") == 0 ? basePath.getDirectoryCount() - 1 : basePath.getDirectoryCount();
608
609 for (U32 iteration = 0; iteration < directoryPaths.size(); ++iteration)
610 {
611 const Path& directoryPath = directoryPaths[iteration];
612
613 // Load the full path to the directory unless we're not supposed to include base paths
614 String directoryPathString = directoryPath.getFullPath().c_str();
615 if (noBasePath)
616 {
617 // Build a path representing the directory tree *after* the base path query but excluding the base
618 // So if we queried for data/ and are currently processing data/ExampleModule/datablocks we want to output
619 // ExampleModule/datablocks
620 Path newDirectoryPath;
621 for (U32 iteration = basePathDirectoryCount; iteration < directoryPath.getDirectoryCount(); ++iteration)
622 {
623 if (iteration > basePathDirectoryCount)
624 {
625 newDirectoryPath.setPath(newDirectoryPath.getPath() + "/");
626 }
627 newDirectoryPath.setPath(newDirectoryPath.getPath() + directoryPath.getDirectory(iteration));
628 }
629
630 newDirectoryPath.setFileName(directoryPath.getFileName());
631 newDirectoryPath.setExtension(directoryPath.getExtension());
632 directoryPathString = newDirectoryPath.getFullPathWithoutRoot();
633 }
634
635 // Output result and enumerate subdirectories if we're not too deep according to the depth parameter
636 directories.push_back(StringTable->insert(directoryPathString, true));
637 if (currentDepth <= depth)
638 {
639 const String subdirectoryPath = directoryPath.getFullPath() + "/";
640
641 DirectoryRef nextDirectory = OpenDirectory(subdirectoryPath);
642 _dumpDirectories(nextDirectory, directories, depth, noBasePath, currentDepth + 1, basePath);
643 }
644 }
645
646 return true;
647}
648
649bool MountSystem::dumpDirectories(const Path& path, Vector<StringTableEntry>& directories, S32 depth, bool noBasePath)
650{

Callers

nothing calls this directly

Calls 15

compareFunction · 0.85
OpenDirectoryFunction · 0.85
getDirectoryCountMethod · 0.80
getDirectoryMethod · 0.80
getFileNameMethod · 0.80
dumpDirectoriesMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
setPathMethod · 0.45
getPathMethod · 0.45
setExtensionMethod · 0.45

Tested by

no test coverage detected