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

Method createPath

Engine/source/core/volume.cpp:1008–1041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1006}
1007
1008bool MountSystem::createPath(const Path& path)
1009{
1010 if (path.getPath().isEmpty())
1011 return true;
1012
1013 // See if the pathectory exists
1014 Path dir;
1015 dir.setRoot(path.getRoot());
1016 dir.setPath(path.getPath());
1017
1018 // in a virtual mount system, isDirectory may return true if the directory exists in a read only FS,
1019 // but the directory may not exist on a writeable filesystem that is also mounted.
1020 // So get the target filesystem that will
1021 // be used for the full writable path and and make sure the directory exists on it.
1022 FileSystemRef fsRef = getFileSystem(path);
1023
1024 if (isDirectory(dir,fsRef))
1025 return true;
1026
1027 // Start from the top and work our way down
1028 Path sub;
1029 dir.setPath(path.isAbsolute()? String("/"): String());
1030 for (U32 i = 0; i < path.getDirectoryCount(); i++)
1031 {
1032 sub.setPath(path.getDirectory(i));
1033 dir.appendPath(sub);
1034 if (!isDirectory(dir,fsRef))
1035 {
1036 if (!createDirectory(dir,fsRef))
1037 return false;
1038 }
1039 }
1040 return true;
1041}
1042
1043
1044//-----------------------------------------------------------------------------

Callers 1

CreatePathFunction · 0.45

Calls 10

isAbsoluteMethod · 0.80
getDirectoryCountMethod · 0.80
getDirectoryMethod · 0.80
appendPathMethod · 0.80
StringClass · 0.50
isEmptyMethod · 0.45
getPathMethod · 0.45
setRootMethod · 0.45
getRootMethod · 0.45
setPathMethod · 0.45

Tested by

no test coverage detected