diff --git a/stepmania/src/RageFileManager.cpp b/stepmania/src/RageFileManager.cpp index a1f4f0e0d9..1a097dde84 100644 --- a/stepmania/src/RageFileManager.cpp +++ b/stepmania/src/RageFileManager.cpp @@ -857,34 +857,42 @@ void GetDirListing( const RString &sPath, vector &AddTo, bool bOnlyDirs void GetDirListingRecursive( const RString &sDir, const RString &sMatch, vector &AddTo ) { ASSERT( sDir.Right(1) == "/" ); - GetDirListing( sDir+sMatch, AddTo, false, true ); - GetDirListing( sDir+"*", AddTo, true, true ); - for( unsigned i=0; i vsFiles; + GetDirListing( sDir+sMatch, vsFiles, false, true ); + vector vsDirs; + GetDirListing( sDir+"*", vsDirs, true, true ); + for( int i=0; i<(int)vsDirs.size(); i++ ) { - if( IsADirectory( AddTo[i] ) ) - { - GetDirListing( AddTo[i]+"/"+sMatch, AddTo, false, true ); - GetDirListing( AddTo[i]+"/*", AddTo, true, true ); - AddTo.erase( AddTo.begin()+i ); - i--; - } + GetDirListing( vsDirs[i]+"/"+sMatch, vsFiles, false, true ); + GetDirListing( vsDirs[i]+"/*", vsDirs, true, true ); + vsDirs.erase( vsDirs.begin()+i ); + i--; + } + for( int i=vsFiles.size()-1; i>=0; i-- ) + { + if( !IsADirectory(vsFiles[i]) ) + AddTo.push_back( vsFiles[i] ); } } void GetDirListingRecursive( RageFileDriver *prfd, const RString &sDir, const RString &sMatch, vector &AddTo ) { ASSERT( sDir.Right(1) == "/" ); - prfd->GetDirListing( sDir+sMatch, AddTo, false, true ); - prfd->GetDirListing( sDir+"*", AddTo, true, true ); - for( unsigned i=0; i vsFiles; + prfd->GetDirListing( sDir+sMatch, vsFiles, false, true ); + vector vsDirs; + prfd->GetDirListing( sDir+"*", vsDirs, true, true ); + for( int i=0; i<(int)vsDirs.size(); i++ ) { - if( prfd->GetFileType(AddTo[i]) == RageFileManager::TYPE_DIR ) - { - prfd->GetDirListing( AddTo[i]+"/"+sMatch, AddTo, false, true ); - prfd->GetDirListing( AddTo[i]+"/*", AddTo, true, true ); - AddTo.erase( AddTo.begin()+i ); - i--; - } + prfd->GetDirListing( vsDirs[i]+"/"+sMatch, vsFiles, false, true ); + prfd->GetDirListing( vsDirs[i]+"/*", vsDirs, true, true ); + vsDirs.erase( vsDirs.begin()+i ); + i--; + } + for( int i=vsFiles.size()-1; i>=0; i-- ) + { + if( prfd->GetFileType(vsFiles[i]) != RageFileManager::TYPE_DIR ) + AddTo.push_back( vsFiles[i] ); } }