clean up floating globals
move FS mounting to ArchHooks
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "RageLog.h"
|
||||
#include "RageThreads.h"
|
||||
#include "Foreach.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
|
||||
#include <cerrno>
|
||||
#if defined(LINUX)
|
||||
@@ -22,8 +23,8 @@ RageFileManager *FILEMAN = NULL;
|
||||
/* Lock this before touching any of these globals (except FILEMAN itself). */
|
||||
static RageEvent *g_Mutex;
|
||||
|
||||
CString InitialWorkingDirectory;
|
||||
CString DirOfExecutable;
|
||||
CString RageFileManagerUtil::sInitialWorkingDirectory;
|
||||
CString RageFileManagerUtil::sDirOfExecutable;
|
||||
|
||||
struct LoadedDriver
|
||||
{
|
||||
@@ -213,15 +214,15 @@ static CString GetDirOfExecutable( CString argv0 )
|
||||
|
||||
static void ChangeToDirOfExecutable( CString argv0 )
|
||||
{
|
||||
InitialWorkingDirectory = GetCwd();
|
||||
DirOfExecutable = GetDirOfExecutable( argv0 );
|
||||
RageFileManagerUtil::sInitialWorkingDirectory = GetCwd();
|
||||
RageFileManagerUtil::sDirOfExecutable = GetDirOfExecutable( argv0 );
|
||||
|
||||
/* Set the CWD. Any effects of this is platform-specific; most files are read and
|
||||
* written through RageFile. See also RageFileManager::RageFileManager. */
|
||||
#if defined(_WINDOWS)
|
||||
chdir( DirOfExecutable + "/.." );
|
||||
chdir( RageFileManagerUtil::sDirOfExecutable + "/.." );
|
||||
#elif defined(MACOSX)
|
||||
chdir( DirOfExecutable + "/../../.." );
|
||||
chdir( sDirOfExecutable + "/../../.." );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -244,70 +245,7 @@ RageFileManager::RageFileManager( CString argv0 )
|
||||
|
||||
void RageFileManager::MountInitialFilesystems()
|
||||
{
|
||||
/* Add file search paths, higher priority first. */
|
||||
#if defined(XBOX)
|
||||
RageFileManager::Mount( "dir", "D:\\", "/" );
|
||||
#elif defined(LINUX)
|
||||
/* Mount the root filesystem, so we can read files in /proc, /etc, and so on.
|
||||
* This is /rootfs, not /root, to avoid confusion with root's home directory. */
|
||||
RageFileManager::Mount( "dir", "/", "/rootfs" );
|
||||
|
||||
/* Mount /proc, so Alsa9Buf::GetSoundCardDebugInfo() and others can access it.
|
||||
* (Deprecated; use rootfs.) */
|
||||
RageFileManager::Mount( "dir", "/proc", "/proc" );
|
||||
|
||||
/* We can almost do this, to have machine profiles be system-global to eg. share
|
||||
* scores. It would need to handle permissions properly. */
|
||||
/* RageFileManager::Mount( "dir", "/var/lib/games/stepmania", "/Save/Profiles" ); */
|
||||
|
||||
// CString Home = getenv( "HOME" ) + "/" + PRODUCT_NAME;
|
||||
|
||||
/*
|
||||
* Next: path to write general mutable user data. If the above path fails (eg.
|
||||
* wrong permissions, doesn't exist), machine memcard data will also go in here.
|
||||
* XXX: It seems silly to have two ~ directories. If we're going to create a
|
||||
* directory on our own, it seems like it should be a dot directory, but it
|
||||
* seems wrong to put lots of data (eg. music) in one. Hmm.
|
||||
*/
|
||||
/* XXX: create */
|
||||
/* RageFileManager::Mount( "dir", Home + "." PRODUCT_NAME, "/Data" ); */
|
||||
|
||||
/* Next, search ~/StepMania. This is where users can put music, themes, etc. */
|
||||
/* RageFileManager::Mount( "dir", Home + PRODUCT_NAME, "/" ); */
|
||||
|
||||
/* Search for a directory with "Songs" in it. Be careful: the CWD is likely to
|
||||
* be ~, and it's possible that some users will have a ~/Songs/ directory that
|
||||
* has nothing to do with us, so check the initial directory last. */
|
||||
CString Root = "";
|
||||
struct stat st;
|
||||
if( Root == "" && !stat( DirOfExecutable + "/Songs", &st ) && st.st_mode&S_IFDIR )
|
||||
Root = DirOfExecutable;
|
||||
if( Root == "" && !stat( InitialWorkingDirectory + "/Songs", &st ) && st.st_mode&S_IFDIR )
|
||||
Root = InitialWorkingDirectory;
|
||||
if( Root == "" )
|
||||
RageException::Throw( "Couldn't find \"Songs\"" );
|
||||
|
||||
RageFileManager::Mount( "dir", Root, "/" );
|
||||
#elif defined(_WINDOWS)
|
||||
/* All Windows data goes in the directory one level above the executable. */
|
||||
CHECKPOINT_M( ssprintf( "DOE \"%s\"", DirOfExecutable.c_str()) );
|
||||
CStringArray parts;
|
||||
split( DirOfExecutable, "/", parts );
|
||||
CHECKPOINT_M( ssprintf( "... %i parts", parts.size()) );
|
||||
ASSERT_M( parts.size() > 1, ssprintf("Strange DirOfExecutable: %s", DirOfExecutable.c_str()) );
|
||||
CString Dir = join( "/", parts.begin(), parts.end()-1 );
|
||||
RageFileManager::Mount( "dir", Dir, "/" );
|
||||
#elif defined(MACOSX)
|
||||
CHECKPOINT_M( ssprintf("DOE \"%s\"", DirOfExecutable.c_str()) );
|
||||
CStringArray parts;
|
||||
split( DirOfExecutable, "/", parts );
|
||||
ASSERT( parts.size() > 3 );
|
||||
CString Dir = '/' + join( "/", parts.begin(), parts.end()-3 );
|
||||
RageFileManager::Mount( "dir", Dir, "/" );
|
||||
#else
|
||||
/* Paths relative to the CWD: */
|
||||
RageFileManager::Mount( "dir", ".", "/" );
|
||||
#endif
|
||||
HOOKS->MountInitialFilesystems( RageFileManagerUtil::sDirOfExecutable );
|
||||
}
|
||||
|
||||
RageFileManager::~RageFileManager()
|
||||
|
||||
Reference in New Issue
Block a user