GetDirListing: remove dupes

This commit is contained in:
Glenn Maynard
2003-12-07 06:21:39 +00:00
parent 5934f21394
commit c77a783bec
+7
View File
@@ -97,6 +97,8 @@ CString LoadedDriver::GetPath( CString path )
return path.Right( path.size() - MountPoint.size() );
}
bool ilt( const CString &a, const CString &b ) { return a.CompareNoCase(b) < 0; }
bool ieq( const CString &a, const CString &b ) { return a.CompareNoCase(b) == 0; }
void RageFileManager::GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bReturnPathToo )
{
for( unsigned i = 0; i < g_Drivers.size(); ++i )
@@ -116,6 +118,11 @@ void RageFileManager::GetDirListing( CString sPath, CStringArray &AddTo, bool bO
AddTo[j] = ld.MountPoint + AddTo[j];
}
/* More than one driver might return the same file. Remove duplicates (case-
* insensitively). */
sort( AddTo.begin(), AddTo.end(), ilt );
CStringArray::iterator it = unique( AddTo.begin(), AddTo.end(), ieq );
AddTo.erase(it, AddTo.end());
}
#include "RageFileDriverDirect.h"