From 073bfeade69781f38081fab167432c807ea9e42b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 31 Aug 2006 19:28:12 +0000 Subject: [PATCH] Fix a confusing case: if eg. both "My Docs\StepMania\Save\Preferences.ini" and "Program Files\StepMania\Save\Preferences.ini" exist, we'll read and write the PF one consistently. However, if the PF one is read-only, we'll read the one in PF and write the one in Docs, which is useless and confusing. Only write to files if we'll read them, too. --- stepmania/src/RageFileManager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stepmania/src/RageFileManager.cpp b/stepmania/src/RageFileManager.cpp index 3da2b7c719..0e7d286fe7 100644 --- a/stepmania/src/RageFileManager.cpp +++ b/stepmania/src/RageFileManager.cpp @@ -806,10 +806,19 @@ RageFileBasic *RageFileManager::OpenForWriting( const RString &sPath, int mode, stable_sort( Values.begin(), Values.end(), SortBySecond ); + /* Only write files if they'll be read. If a file exists in any driver, don't + * create or write files in any driver mounted after it, because when we later + * try to read it, we'll get that file and not the one we wrote. */ + int iMaximumDriver = apDriverList.size(); + if( Values.size() > 0 && Values[0].second == 0 ) + iMaximumDriver = Values[0].first; + iError = 0; for( unsigned i = 0; i < Values.size(); ++i ) { const int iDriver = Values[i].first; + if( iDriver > iMaximumDriver ) + continue; LoadedDriver &ld = *apDriverList[iDriver]; const RString sDriverPath = ld.GetPath( sPath ); ASSERT( !sDriverPath.empty() );