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:
@@ -282,6 +282,11 @@ void RageFileManager::MountInitialFilesystems()
|
|||||||
HOOKS->MountInitialFilesystems( RageFileManagerUtil::sDirOfExecutable );
|
HOOKS->MountInitialFilesystems( RageFileManagerUtil::sDirOfExecutable );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RageFileManager::MountUserFilesystems()
|
||||||
|
{
|
||||||
|
HOOKS->MountUserFilesystems( RageFileManagerUtil::sDirOfExecutable );
|
||||||
|
}
|
||||||
|
|
||||||
RageFileManager::~RageFileManager()
|
RageFileManager::~RageFileManager()
|
||||||
{
|
{
|
||||||
/* Note that drivers can use previously-loaded drivers, eg. to load a ZIP
|
/* Note that drivers can use previously-loaded drivers, eg. to load a ZIP
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public:
|
|||||||
RageFileManager( const RString &argv0 );
|
RageFileManager( const RString &argv0 );
|
||||||
~RageFileManager();
|
~RageFileManager();
|
||||||
void MountInitialFilesystems();
|
void MountInitialFilesystems();
|
||||||
|
void MountUserFilesystems();
|
||||||
|
|
||||||
void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
|
void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
|
||||||
bool Move( const RString &sOldPath, const RString &sNewPath );
|
bool Move( const RString &sOldPath, const RString &sNewPath );
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace SpecialFiles
|
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 PACKAGES_DIR; // system packages (not user packages)
|
||||||
extern const RString KEYMAPS_PATH;
|
extern const RString KEYMAPS_PATH;
|
||||||
extern const RString PREFERENCES_INI_PATH;
|
extern const RString PREFERENCES_INI_PATH;
|
||||||
|
|||||||
@@ -949,6 +949,10 @@ int main(int argc, char* argv[])
|
|||||||
/* Almost everything uses this to read and write files. Load this early. */
|
/* Almost everything uses this to read and write files. Load this early. */
|
||||||
FILEMAN = new RageFileManager( argv[0] );
|
FILEMAN = new RageFileManager( argv[0] );
|
||||||
FILEMAN->MountInitialFilesystems();
|
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. */
|
/* Set this up next. Do this early, since it's needed for RageException::Throw. */
|
||||||
LOG = new RageLog;
|
LOG = new RageLog;
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
static void MountInitialFilesystems( const RString &sDirOfExecutable );
|
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.
|
* Platform-specific code calls this to indicate focus changes.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
|||||||
return ret;
|
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. */
|
/* All Windows data goes in the directory one level above the executable. */
|
||||||
CHECKPOINT_M( ssprintf( "DOE \"%s\"", sDirOfExecutable.c_str()) );
|
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()) );
|
CHECKPOINT_M( ssprintf( "... %i asParts", asParts.size()) );
|
||||||
ASSERT_M( asParts.size() > 1, ssprintf("Strange sDirOfExecutable: %s", sDirOfExecutable.c_str()) );
|
ASSERT_M( asParts.size() > 1, ssprintf("Strange sDirOfExecutable: %s", sDirOfExecutable.c_str()) );
|
||||||
RString sDir = join( "/", asParts.begin(), asParts.end()-1 );
|
RString sDir = join( "/", asParts.begin(), asParts.end()-1 );
|
||||||
|
return sDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||||
|
{
|
||||||
|
RString sDir = GetMountDir( sDirOfExecutable );
|
||||||
FILEMAN->Mount( "dir", sDir, "/" );
|
FILEMAN->Mount( "dir", sDir, "/" );
|
||||||
|
}
|
||||||
|
|
||||||
/* Experimental: Check for a sentinel file and then operate in portable mode. */
|
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||||
// TODO: Make this cross-platform?
|
{
|
||||||
bool bPortable = DoesFileExist("Portable.ini");
|
RString sAppDataDir = SpecialDirs::GetAppDataDir() + PRODUCT_ID;
|
||||||
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;
|
|
||||||
FILEMAN->Mount( "dir", sAppDataDir + "/Cache", "/Cache" );
|
FILEMAN->Mount( "dir", sAppDataDir + "/Cache", "/Cache" );
|
||||||
FILEMAN->Mount( "dir", sAppDataDir + "/Logs", "/Logs" );
|
FILEMAN->Mount( "dir", sAppDataDir + "/Logs", "/Logs" );
|
||||||
FILEMAN->Mount( "dir", sAppDataDir + "/Save", "/Save" );
|
FILEMAN->Mount( "dir", sAppDataDir + "/Save", "/Save" );
|
||||||
|
|||||||
Reference in New Issue
Block a user