allow mounting RageFileDrivers directly
This commit is contained in:
@@ -430,22 +430,36 @@ void RageFileManager::CreateDir( CString sDir )
|
|||||||
FILEMAN->Remove( sTempFile );
|
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 )
|
void RageFileManager::Mount( CString Type, CString Root, CString MountPoint, bool bAddToEnd )
|
||||||
{
|
{
|
||||||
FixSlashesInPlace( Root );
|
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 != "" );
|
ASSERT( Root != "" );
|
||||||
|
|
||||||
CHECKPOINT_M( ssprintf("\"%s\", \"%s\", \"%s\"",
|
CHECKPOINT_M( ssprintf("\"%s\", \"%s\", \"%s\"", Type.c_str(), Root.c_str(), MountPoint.c_str() ) );
|
||||||
Type.c_str(), Root.c_str(), MountPoint.c_str() ) );
|
|
||||||
|
|
||||||
// Unmount anything that was previously mounted here.
|
// Unmount anything that was previously mounted here.
|
||||||
Unmount( Type, Root, MountPoint );
|
Unmount( Type, Root, MountPoint );
|
||||||
@@ -471,12 +485,21 @@ void RageFileManager::Mount( CString Type, CString Root, CString MountPoint, boo
|
|||||||
ld.Root = Root;
|
ld.Root = Root;
|
||||||
ld.MountPoint = MountPoint;
|
ld.MountPoint = MountPoint;
|
||||||
|
|
||||||
g_Mutex->Lock();
|
AddFilesystemDriver( &ld, bAddToEnd );
|
||||||
g_Drivers.insert( bAddToEnd? g_Drivers.end():g_Drivers.begin(), ld );
|
}
|
||||||
CHECKPOINT;
|
|
||||||
g_Mountpoints->LoadFromDrivers( g_Drivers );
|
/* Mount a custom filesystem. */
|
||||||
CHECKPOINT;
|
void RageFileManager::Mount( RageFileDriver *pDriver, CString sMountPoint, bool bAddToEnd )
|
||||||
g_Mutex->Unlock();
|
{
|
||||||
|
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 )
|
void RageFileManager::Unmount( CString Type, CString Root, CString MountPoint )
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
int GetFileHash( CString sPath );
|
int GetFileHash( CString sPath );
|
||||||
|
|
||||||
void Mount( CString Type, CString RealPath, CString MountPoint, bool bAddToEnd = true );
|
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 );
|
void Unmount( CString Type, CString Root, CString MountPoint );
|
||||||
|
|
||||||
/* Change the root of a filesystem. Only a couple drivers support this; it's
|
/* Change the root of a filesystem. Only a couple drivers support this; it's
|
||||||
|
|||||||
Reference in New Issue
Block a user