From d58b3186f080c35388b22f1e20afa9dc7aa771e4 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 25 Jun 2005 22:34:54 +0000 Subject: [PATCH] allow mounting RageFileDrivers directly --- stepmania/src/RageFileManager.cpp | 55 ++++++++++++++++++++++--------- stepmania/src/RageFileManager.h | 1 + 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/stepmania/src/RageFileManager.cpp b/stepmania/src/RageFileManager.cpp index 1c52c2f086..89b95f95e3 100644 --- a/stepmania/src/RageFileManager.cpp +++ b/stepmania/src/RageFileManager.cpp @@ -430,22 +430,36 @@ void RageFileManager::CreateDir( CString sDir ) FILEMAN->Remove( sTempFile ); } +static void AdjustMountpoint( CString &sMountPoint ) +{ + FixSlashesInPlace( sMountPoint ); + + ASSERT_M( sMountPoint.Left(1) == "/", "Mountpoints must be absolute: " + sMountPoint ); + + if( sMountPoint.size() && sMountPoint.Right(1) != "/" ) + sMountPoint += '/'; + + if( sMountPoint.Left(1) != "/" ) + sMountPoint = "/" + sMountPoint; + +} + +static void AddFilesystemDriver( const LoadedDriver *pLoadedDriver, bool bAddToEnd ) +{ + g_Mutex->Lock(); + g_Drivers.insert( bAddToEnd? g_Drivers.end():g_Drivers.begin(), *pLoadedDriver ); + g_Mountpoints->LoadFromDrivers( g_Drivers ); + g_Mutex->Unlock(); +} + void RageFileManager::Mount( CString Type, CString Root, CString MountPoint, bool bAddToEnd ) { FixSlashesInPlace( Root ); - FixSlashesInPlace( MountPoint ); + AdjustMountpoint( MountPoint ); - ASSERT_M( MountPoint.Left(1) == "/", "Mountpoints must be absolute: " + MountPoint ); - - if( MountPoint.size() && MountPoint.Right(1) != "/" ) - MountPoint += '/'; - - if( MountPoint.Left(1) != "/" ) - MountPoint = "/" + MountPoint; ASSERT( Root != "" ); - CHECKPOINT_M( ssprintf("\"%s\", \"%s\", \"%s\"", - Type.c_str(), Root.c_str(), MountPoint.c_str() ) ); + CHECKPOINT_M( ssprintf("\"%s\", \"%s\", \"%s\"", Type.c_str(), Root.c_str(), MountPoint.c_str() ) ); // Unmount anything that was previously mounted here. Unmount( Type, Root, MountPoint ); @@ -471,12 +485,21 @@ void RageFileManager::Mount( CString Type, CString Root, CString MountPoint, boo ld.Root = Root; ld.MountPoint = MountPoint; - g_Mutex->Lock(); - g_Drivers.insert( bAddToEnd? g_Drivers.end():g_Drivers.begin(), ld ); - CHECKPOINT; - g_Mountpoints->LoadFromDrivers( g_Drivers ); - CHECKPOINT; - g_Mutex->Unlock(); + AddFilesystemDriver( &ld, bAddToEnd ); +} + +/* Mount a custom filesystem. */ +void RageFileManager::Mount( RageFileDriver *pDriver, CString sMountPoint, bool bAddToEnd ) +{ + AdjustMountpoint( sMountPoint ); + + LoadedDriver ld; + ld.driver = pDriver; + ld.Type = ""; + ld.Root = ""; + ld.MountPoint = sMountPoint; + + AddFilesystemDriver( &ld, bAddToEnd ); } void RageFileManager::Unmount( CString Type, CString Root, CString MountPoint ) diff --git a/stepmania/src/RageFileManager.h b/stepmania/src/RageFileManager.h index 35f07df015..88ab7b29ca 100644 --- a/stepmania/src/RageFileManager.h +++ b/stepmania/src/RageFileManager.h @@ -31,6 +31,7 @@ public: int GetFileHash( CString sPath ); void Mount( CString Type, CString RealPath, CString MountPoint, bool bAddToEnd = true ); + void Mount( RageFileDriver *pDriver, CString sMountPoint, bool bAddToEnd = true ); void Unmount( CString Type, CString Root, CString MountPoint ); /* Change the root of a filesystem. Only a couple drivers support this; it's