plaform-independent handling of Portable.ini. Portable mode no longer saves inside of a directory called Portable in Win32 (made the platform-independent logic simpler).

This commit is contained in:
Chris Danford
2009-04-11 21:28:31 +00:00
parent 054942663e
commit c0b747ba86
6 changed files with 27 additions and 9 deletions
+5
View File
@@ -282,6 +282,11 @@ void RageFileManager::MountInitialFilesystems()
HOOKS->MountInitialFilesystems( RageFileManagerUtil::sDirOfExecutable );
}
void RageFileManager::MountUserFilesystems()
{
HOOKS->MountUserFilesystems( RageFileManagerUtil::sDirOfExecutable );
}
RageFileManager::~RageFileManager()
{
/* Note that drivers can use previously-loaded drivers, eg. to load a ZIP
+1
View File
@@ -18,6 +18,7 @@ public:
RageFileManager( const RString &argv0 );
~RageFileManager();
void MountInitialFilesystems();
void MountUserFilesystems();
void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
bool Move( const RString &sOldPath, const RString &sNewPath );
+1 -1
View File
@@ -5,7 +5,7 @@
namespace SpecialFiles
{
extern const RString USER_PACKAGES_DIR;
extern const RString USER_PACKAGES_DIR; // user packages should be a separate dir from system packages so that we can write to it (installing a package)
extern const RString PACKAGES_DIR; // system packages (not user packages)
extern const RString KEYMAPS_PATH;
extern const RString PREFERENCES_INI_PATH;
+4
View File
@@ -949,6 +949,10 @@ int main(int argc, char* argv[])
/* Almost everything uses this to read and write files. Load this early. */
FILEMAN = new RageFileManager( argv[0] );
FILEMAN->MountInitialFilesystems();
bool bPortable = DoesFileExist("Portable.ini");
if( !bPortable )
FILEMAN->MountUserFilesystems();
/* Set this up next. Do this early, since it's needed for RageException::Throw. */
LOG = new RageLog;
+5
View File
@@ -93,6 +93,11 @@ public:
*/
static void MountInitialFilesystems( const RString &sDirOfExecutable );
/*
* Add file search paths for user-writable directories.
*/
static void MountUserFilesystems( const RString &sDirOfExecutable );
/*
* Platform-specific code calls this to indicate focus changes.
*/
@@ -40,7 +40,7 @@ int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
return ret;
}
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
static RString GetMountDir( const RString &sDirOfExecutable )
{
/* All Windows data goes in the directory one level above the executable. */
CHECKPOINT_M( ssprintf( "DOE \"%s\"", sDirOfExecutable.c_str()) );
@@ -49,15 +49,18 @@ void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
CHECKPOINT_M( ssprintf( "... %i asParts", asParts.size()) );
ASSERT_M( asParts.size() > 1, ssprintf("Strange sDirOfExecutable: %s", sDirOfExecutable.c_str()) );
RString sDir = join( "/", asParts.begin(), asParts.end()-1 );
return sDir;
}
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
{
RString sDir = GetMountDir( sDirOfExecutable );
FILEMAN->Mount( "dir", sDir, "/" );
}
/* Experimental: Check for a sentinel file and then operate in portable mode. */
// TODO: Make this cross-platform?
bool bPortable = DoesFileExist("Portable.ini");
RString sPortableDir = sDir + "/Portable";
// Mount everything game-writable (not counting the editor) to the user's directory.
RString sAppDataDir = bPortable ? sPortableDir : SpecialDirs::GetAppDataDir() + PRODUCT_ID;
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
{
RString sAppDataDir = SpecialDirs::GetAppDataDir() + PRODUCT_ID;
FILEMAN->Mount( "dir", sAppDataDir + "/Cache", "/Cache" );
FILEMAN->Mount( "dir", sAppDataDir + "/Logs", "/Logs" );
FILEMAN->Mount( "dir", sAppDataDir + "/Save", "/Save" );