Port ResolvePath from OpenITG.

Also, forgot to [sqlite] this earlier.
This commit is contained in:
Jason Felds
2011-06-15 22:36:58 -04:00
parent 4379df289d
commit bfe6e0076d
2 changed files with 42 additions and 0 deletions
+36
View File
@@ -731,6 +731,42 @@ int RageFileManager::GetFileHash( const RString &sPath_ )
return iRet;
}
RString RageFileManager::ResolvePath(const RString &path)
{
RString tmpPath = path;
NormalizePath(tmpPath);
RString resolvedPath = tmpPath;
vector<LoadedDriver *> apDriverList;
ReferenceAllDrivers( apDriverList );
for( unsigned i = 0; i < apDriverList.size(); ++i )
{
LoadedDriver *pDriver = apDriverList[i];
const RString driverPath = pDriver->GetPath( tmpPath );
if ( driverPath.empty() || pDriver->m_sRoot.empty() )
continue;
if ( pDriver->m_sType != "dir" && pDriver->m_sType != "dirro" )
continue;
int iMountPointLen = pDriver->m_sMountPoint.length();
if( tmpPath.substr(0, iMountPointLen) != pDriver->m_sMountPoint )
continue;
resolvedPath = pDriver->m_sRoot + "/" + RString(tmpPath.substr(iMountPointLen));
break;
}
UnreferenceAllDrivers( apDriverList );
NormalizePath( resolvedPath );
return resolvedPath;
}
static bool SortBySecond( const pair<int,int> &a, const pair<int,int> &b )
{
return a.second < b.second;