| 876 | } |
| 877 | |
| 878 | S32 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 ); |
no test coverage detected