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

Method findByPattern

Engine/source/core/volume.cpp:878–938  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

876}
877
878S32 MountSystem::findByPattern( const Path &inBasePath, const String &inFilePattern, bool inRecursive, Vector<String> &outList, bool includeDirs/* =false */, bool multiMatch /* = true */ )
879{
880 if (mFindByPatternOverrideFS.isNull() && !inBasePath.isDirectory() )
881 return -1;
882
883 DirectoryRef dir = NULL;
884 if (mFindByPatternOverrideFS.isNull())
885 // open directory using standard mount system search
886 dir = openDirectory( inBasePath );
887 else
888 {
889 // use specified filesystem to open directory
890 FileNodeRef fNode = mFindByPatternOverrideFS->resolveLoose(inBasePath);
891 if (fNode && (dir = dynamic_cast<Directory*>(fNode.getPointer())) != NULL)
892 dir->open();
893 }
894
895 if ( dir == NULL )
896 return -1;
897
898 if (includeDirs)
899 {
900 // prepend cheesy "DIR:" annotation for directories
901 outList.push_back(String("DIR:") + inBasePath.getPath());
902 }
903
904 FileNode::Attributes attrs;
905
906 Vector<String> recurseDirs;
907
908 while ( dir->read( &attrs ) )
909 {
910 String name( attrs.name );
911
912 if ( (attrs.flags & FileNode::Directory) && inRecursive )
913 {
914 name += '/';
915 String path = Path::Join( inBasePath, '/', name );
916 recurseDirs.push_back( path );
917 }
918
919 if ( !multiMatch && FindMatch::isMatch( inFilePattern, attrs.name, false ) )
920 {
921 String path = Path::Join( inBasePath, '/', name );
922 outList.push_back( path );
923 }
924
925 if ( multiMatch && FindMatch::isMatchMultipleExprs( inFilePattern, attrs.name, false ) )
926 {
927 String path = Path::Join( inBasePath, '/', name );
928 outList.push_back( path );
929 }
930 }
931
932 dir->close();
933
934 for ( S32 i = 0; i < recurseDirs.size(); i++ )
935 findByPattern( recurseDirs[i], inFilePattern, true, outList, includeDirs, multiMatch );

Callers 1

FindByPatternFunction · 0.45

Calls 11

openMethod · 0.65
closeMethod · 0.65
StringClass · 0.50
isNullMethod · 0.45
isDirectoryMethod · 0.45
resolveLooseMethod · 0.45
getPointerMethod · 0.45
push_backMethod · 0.45
getPathMethod · 0.45
readMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected