clean up file drivers: drivers now always receive paths with trailing slashes;
this makes handling the relative "root" directory not a special case (".").
mountpoints now always begin with a slash. before, "/foo" and "foo" were
in two separate namespaces, which was weird and confusing; the two now
mean the same thing. there are no more special "default mountpoints"; just
mount to "/". "@path" mounts are now "/@path", and they do show up in
GetDirListing("/") (but, as before, opening "/@foo/bar" will never create
a "@foo/bar" path in a non-"@foo" mountpoint)
This commit is contained in:
@@ -103,6 +103,7 @@ RageFileObj *MakeFileObjDirect( CString sPath, int mode, int &err )
|
|||||||
|
|
||||||
RageFileBasic *RageFileDriverDirect::Open( const CString &path, int mode, int &err )
|
RageFileBasic *RageFileDriverDirect::Open( const CString &path, int mode, int &err )
|
||||||
{
|
{
|
||||||
|
ASSERT( path.size() && path[0] == '/' );
|
||||||
CString sPath = path;
|
CString sPath = path;
|
||||||
|
|
||||||
/* This partially resolves. For example, if "abc/def" exists, and we're opening
|
/* This partially resolves. For example, if "abc/def" exists, and we're opening
|
||||||
@@ -174,8 +175,6 @@ bool RageFileDriverDirect::Ready()
|
|||||||
bool RageFileDriverDirect::Remount( const CString &sPath )
|
bool RageFileDriverDirect::Remount( const CString &sPath )
|
||||||
{
|
{
|
||||||
root = sPath;
|
root = sPath;
|
||||||
if( root.Right(1) != "/" )
|
|
||||||
root += '/';
|
|
||||||
((DirectFilenameDB *) FDB)->SetRoot( sPath );
|
((DirectFilenameDB *) FDB)->SetRoot( sPath );
|
||||||
|
|
||||||
/* If the root path doesn't exist, create it. */
|
/* If the root path doesn't exist, create it. */
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ void RageFileDriverZip::ParseZipfile()
|
|||||||
|
|
||||||
FileInfo *pInfo = new FileInfo( info );
|
FileInfo *pInfo = new FileInfo( info );
|
||||||
m_pFiles.push_back( pInfo );
|
m_pFiles.push_back( pInfo );
|
||||||
FDB->AddFile( pInfo->m_sName, pInfo->m_iUncompressedSize, pInfo->m_iCRC32, pInfo );
|
FDB->AddFile( "/" + pInfo->m_sName, pInfo->m_iUncompressedSize, pInfo->m_iCRC32, pInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_pFiles.size() == 0 )
|
if( m_pFiles.size() == 0 )
|
||||||
|
|||||||
@@ -313,25 +313,27 @@ RageFileManager::~RageFileManager()
|
|||||||
/* path must be normalized (FixSlashesInPlace, CollapsePath). */
|
/* path must be normalized (FixSlashesInPlace, CollapsePath). */
|
||||||
CString LoadedDriver::GetPath( const CString &path )
|
CString LoadedDriver::GetPath( const CString &path )
|
||||||
{
|
{
|
||||||
/* Default mountpoints: */
|
/* If the path begins with /@, only match mountpoints that begin with /@. */
|
||||||
if( MountPoint.size() == 0 )
|
if( path.size() >= 2 && path[1] == '@' )
|
||||||
{
|
{
|
||||||
/* If the path begins with @, default mount points don't count. */
|
if( MountPoint.size() < 2 || MountPoint[1] != '@' )
|
||||||
if( path.size() && path[0] == '@' )
|
|
||||||
return "";
|
return "";
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( path.Left( MountPoint.size() ).CompareNoCase( MountPoint ) )
|
if( path.Left( MountPoint.size() ).CompareNoCase( MountPoint ) )
|
||||||
return ""; /* no match */
|
return ""; /* no match */
|
||||||
|
|
||||||
return path.Right( path.size() - MountPoint.size() );
|
/* Add one, so we don't cut off the leading slash. */
|
||||||
|
CString sRet = path.Right( path.size() - MountPoint.size() + 1 );
|
||||||
|
return sRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NormalizePath( CString &sPath )
|
static void NormalizePath( CString &sPath )
|
||||||
{
|
{
|
||||||
FixSlashesInPlace( sPath );
|
FixSlashesInPlace( sPath );
|
||||||
CollapsePath( sPath, true );
|
CollapsePath( sPath, true );
|
||||||
|
if( sPath.size() == 0 || sPath[0] != '/' )
|
||||||
|
sPath.insert( sPath.begin(), '/' );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ilt( const CString &a, const CString &b ) { return a.CompareNoCase(b) < 0; }
|
bool ilt( const CString &a, const CString &b ) { return a.CompareNoCase(b) < 0; }
|
||||||
@@ -356,8 +358,14 @@ void RageFileManager::GetDirListing( CString sPath, CStringArray &AddTo, bool bO
|
|||||||
|
|
||||||
/* If returning the path, prepend the mountpoint name to the files this driver returned. */
|
/* If returning the path, prepend the mountpoint name to the files this driver returned. */
|
||||||
if( bReturnPathToo )
|
if( bReturnPathToo )
|
||||||
|
{
|
||||||
for( unsigned j = OldStart; j < AddTo.size(); ++j )
|
for( unsigned j = OldStart; j < AddTo.size(); ++j )
|
||||||
AddTo[j] = ld.MountPoint + AddTo[j];
|
{
|
||||||
|
/* Skip the trailing slash on the mountpoint; there's already a slash there. */
|
||||||
|
CString &sPath = AddTo[j];
|
||||||
|
sPath.insert( 0, ld.MountPoint, ld.MountPoint.size()-1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UnreferenceAllDrivers( aDriverList );
|
UnreferenceAllDrivers( aDriverList );
|
||||||
@@ -415,6 +423,9 @@ void RageFileManager::Mount( CString Type, CString Root, CString MountPoint )
|
|||||||
|
|
||||||
if( MountPoint.size() && MountPoint.Right(1) != "/" )
|
if( MountPoint.size() && MountPoint.Right(1) != "/" )
|
||||||
MountPoint += '/';
|
MountPoint += '/';
|
||||||
|
/* XXX: Backwards compatibility; */
|
||||||
|
if( MountPoint.Left(1) != "/" )
|
||||||
|
MountPoint = "/" + MountPoint;
|
||||||
ASSERT( Root != "" );
|
ASSERT( Root != "" );
|
||||||
|
|
||||||
CHECKPOINT_M( ssprintf("\"%s\", \"%s\", \"%s\"",
|
CHECKPOINT_M( ssprintf("\"%s\", \"%s\", \"%s\"",
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ CString BackgroundLoader::GetRequest()
|
|||||||
|
|
||||||
CString BackgroundLoader::GetCachePath( CString sPath ) const
|
CString BackgroundLoader::GetCachePath( CString sPath ) const
|
||||||
{
|
{
|
||||||
return m_sCachePathPrefix + "/" + sPath;
|
return m_sCachePathPrefix + sPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundLoader::LoadThread()
|
void BackgroundLoader::LoadThread()
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ RageFileManager::FileType FilenameDB::GetFileType( const CString &sPath )
|
|||||||
CString Dir, Name;
|
CString Dir, Name;
|
||||||
SplitPath( sPath, Dir, Name );
|
SplitPath( sPath, Dir, Name );
|
||||||
|
|
||||||
if( Name == "." )
|
if( Name == "/" )
|
||||||
return RageFileManager::TYPE_DIR;
|
return RageFileManager::TYPE_DIR;
|
||||||
|
|
||||||
const FileSet *fs = GetFileSet( Dir );
|
const FileSet *fs = GetFileSet( Dir );
|
||||||
@@ -152,7 +152,7 @@ int FilenameDB::GetFileHash( const CString &sPath )
|
|||||||
/* path should be fully collapsed, so we can operate in-place: no . or .. */
|
/* path should be fully collapsed, so we can operate in-place: no . or .. */
|
||||||
bool FilenameDB::ResolvePath(CString &path)
|
bool FilenameDB::ResolvePath(CString &path)
|
||||||
{
|
{
|
||||||
if( path == "." || path == "" )
|
if( path == "/" || path == "" )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* Split path into components. */
|
/* Split path into components. */
|
||||||
@@ -186,9 +186,7 @@ bool FilenameDB::ResolvePath(CString &path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ret.size() != 0 )
|
ret += "/" + it->name;
|
||||||
ret += "/";
|
|
||||||
ret += it->name;
|
|
||||||
|
|
||||||
fs = it->dirp;
|
fs = it->dirp;
|
||||||
|
|
||||||
@@ -264,7 +262,7 @@ FileSet *FilenameDB::GetFileSet( CString dir, bool create )
|
|||||||
dir.Replace("//", "/"); /* foo//bar -> foo/bar */
|
dir.Replace("//", "/"); /* foo//bar -> foo/bar */
|
||||||
|
|
||||||
if( dir == "" )
|
if( dir == "" )
|
||||||
dir = ".";
|
dir = "/";
|
||||||
|
|
||||||
CString lower = dir;
|
CString lower = dir;
|
||||||
lower.MakeLower();
|
lower.MakeLower();
|
||||||
@@ -328,7 +326,7 @@ FileSet *FilenameDB::GetFileSet( CString dir, bool create )
|
|||||||
* order of operations, here: since we just unlocked, any this->dirs searches we did
|
* order of operations, here: since we just unlocked, any this->dirs searches we did
|
||||||
* previously are no longer valid. */
|
* previously are no longer valid. */
|
||||||
FileSet **parent_dirp = NULL;
|
FileSet **parent_dirp = NULL;
|
||||||
if( dir != "." && dir != "/" )
|
if( dir != "/" )
|
||||||
{
|
{
|
||||||
CString sParent = Dirname( dir );
|
CString sParent = Dirname( dir );
|
||||||
if( sParent == "./" )
|
if( sParent == "./" )
|
||||||
@@ -530,7 +528,6 @@ void FilenameDB::GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDi
|
|||||||
{
|
{
|
||||||
// LOG->Trace( "GetDirListing( %s )", sPath.c_str() );
|
// LOG->Trace( "GetDirListing( %s )", sPath.c_str() );
|
||||||
|
|
||||||
/* If you want the CWD, use ".". */
|
|
||||||
ASSERT(!sPath.empty());
|
ASSERT(!sPath.empty());
|
||||||
|
|
||||||
/* Strip off the last path element and use it as a mask. */
|
/* Strip off the last path element and use it as a mask. */
|
||||||
|
|||||||
Reference in New Issue
Block a user