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

Method findByPattern

Engine/source/core/volume.cpp:721–785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719}
720
721S32 MountSystem::findByPattern( const Path &inBasePath, const String &inFilePattern, bool inRecursive, Vector<String> &outList, bool includeDirs/* =false */, bool multiMatch /* = true */ )
722{
723 if (mFindByPatternOverrideFS.isNull() && !inBasePath.isDirectory() )
724 return -1;
725
726 DirectoryRef dir = NULL;
727 if (mFindByPatternOverrideFS.isNull())
728 // open directory using standard mount system search
729 dir = openDirectory( inBasePath );
730 else
731 {
732 // use specified filesystem to open directory
733 FileNodeRef fNode = mFindByPatternOverrideFS->resolve(inBasePath);
734 if (fNode && (dir = dynamic_cast<Directory*>(fNode.getPointer())) != NULL)
735 dir->open();
736 }
737
738 if ( dir == NULL )
739 return -1;
740
741 if (includeDirs)
742 {
743 // prepend cheesy "DIR:" annotation for directories
744 outList.push_back(String("DIR:") + inBasePath.getPath());
745 }
746
747 FileNode::Attributes attrs;
748
749 Vector<String> recurseDirs;
750
751 while ( dir->read( &attrs ) )
752 {
753 // skip hidden files
754 if ( attrs.name.c_str()[0] == '.' )
755 continue;
756
757 String name( attrs.name );
758
759 if ( (attrs.flags & FileNode::Directory) && inRecursive )
760 {
761 name += '/';
762 String path = Path::Join( inBasePath, '/', name );
763 recurseDirs.push_back( path );
764 }
765
766 if ( !multiMatch && FindMatch::isMatch( inFilePattern, attrs.name, false ) )
767 {
768 String path = Path::Join( inBasePath, '/', name );
769 outList.push_back( path );
770 }
771
772 if ( multiMatch && FindMatch::isMatchMultipleExprs( inFilePattern, attrs.name, false ) )
773 {
774 String path = Path::Join( inBasePath, '/', name );
775 outList.push_back( path );
776 }
777 }
778

Callers 1

FindByPatternFunction · 0.45

Calls 12

StringClass · 0.50
isNullMethod · 0.45
isDirectoryMethod · 0.45
resolveMethod · 0.45
getPointerMethod · 0.45
openMethod · 0.45
push_backMethod · 0.45
getPathMethod · 0.45
readMethod · 0.45
c_strMethod · 0.45
closeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected