diff --git a/stepmania/src/RageFileManager.cpp b/stepmania/src/RageFileManager.cpp index 00d654ad8f..7eb8358b7f 100644 --- a/stepmania/src/RageFileManager.cpp +++ b/stepmania/src/RageFileManager.cpp @@ -401,6 +401,34 @@ void RageFileManager::GetDirListing( CString sPath, CStringArray &AddTo, bool bO } } +/* Files may only be moved within the same file driver. */ +bool RageFileManager::MoveFile( CString sOldPath, CString sNewPath ) +{ + vector aDriverList; + ReferenceAllDrivers( aDriverList ); + + NormalizePath( sOldPath ); + NormalizePath( sNewPath ); + + /* Multiple drivers may have the same file. */ + bool Deleted = false; + for( unsigned i = 0; i < aDriverList.size(); ++i ) + { + const CString sOldDriverPath = aDriverList[i].GetPath( sOldPath ); + const CString sNewDriverPath = aDriverList[i].GetPath( sNewPath ); + if( sOldDriverPath.size() == 0 || sNewDriverPath.size() == 0 ) + continue; + + bool ret = aDriverList[i].driver->MoveFile( sOldDriverPath, sNewDriverPath ); + if( ret ) + Deleted = true; + } + + UnreferenceAllDrivers( aDriverList ); + + return Deleted; +} + bool RageFileManager::Remove( CString sPath ) { vector apDriverList; diff --git a/stepmania/src/RageFileManager.h b/stepmania/src/RageFileManager.h index 1e02000cc1..7086da2b1a 100644 --- a/stepmania/src/RageFileManager.h +++ b/stepmania/src/RageFileManager.h @@ -16,6 +16,7 @@ public: void MountInitialFilesystems(); void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bReturnPathToo ); + bool MoveFile( CString sOldPath, CString sNewPath ); bool Remove( CString sPath ); void CreateDir( CString sDir );