| 719 | } |
| 720 | |
| 721 | S32 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 |
no test coverage detected