diff --git a/stepmania/src/RageFileDriverDirect.cpp b/stepmania/src/RageFileDriverDirect.cpp index d5d9a1bc8c..27056f32e9 100644 --- a/stepmania/src/RageFileDriverDirect.cpp +++ b/stepmania/src/RageFileDriverDirect.cpp @@ -103,6 +103,7 @@ RageFileObj *MakeFileObjDirect( CString sPath, int mode, int &err ) RageFileBasic *RageFileDriverDirect::Open( const CString &path, int mode, int &err ) { + ASSERT( path.size() && path[0] == '/' ); CString sPath = path; /* 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 ) { root = sPath; - if( root.Right(1) != "/" ) - root += '/'; ((DirectFilenameDB *) FDB)->SetRoot( sPath ); /* If the root path doesn't exist, create it. */ diff --git a/stepmania/src/RageFileDriverZip.cpp b/stepmania/src/RageFileDriverZip.cpp index d6fba969d0..05b92e0f0d 100644 --- a/stepmania/src/RageFileDriverZip.cpp +++ b/stepmania/src/RageFileDriverZip.cpp @@ -147,7 +147,7 @@ void RageFileDriverZip::ParseZipfile() FileInfo *pInfo = new FileInfo( info ); 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 ) diff --git a/stepmania/src/RageFileManager.cpp b/stepmania/src/RageFileManager.cpp index e8a0af43e8..466378d954 100644 --- a/stepmania/src/RageFileManager.cpp +++ b/stepmania/src/RageFileManager.cpp @@ -313,25 +313,27 @@ RageFileManager::~RageFileManager() /* path must be normalized (FixSlashesInPlace, CollapsePath). */ CString LoadedDriver::GetPath( const CString &path ) { - /* Default mountpoints: */ - if( MountPoint.size() == 0 ) + /* If the path begins with /@, only match mountpoints that begin with /@. */ + if( path.size() >= 2 && path[1] == '@' ) { - /* If the path begins with @, default mount points don't count. */ - if( path.size() && path[0] == '@' ) + if( MountPoint.size() < 2 || MountPoint[1] != '@' ) return ""; - return path; } if( path.Left( MountPoint.size() ).CompareNoCase( MountPoint ) ) 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 ) { FixSlashesInPlace( sPath ); 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; } @@ -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( bReturnPathToo ) + { 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 ); @@ -415,6 +423,9 @@ void RageFileManager::Mount( CString Type, CString Root, CString MountPoint ) if( MountPoint.size() && MountPoint.Right(1) != "/" ) MountPoint += '/'; + /* XXX: Backwards compatibility; */ + if( MountPoint.Left(1) != "/" ) + MountPoint = "/" + MountPoint; ASSERT( Root != "" ); CHECKPOINT_M( ssprintf("\"%s\", \"%s\", \"%s\"", diff --git a/stepmania/src/RageUtil_BackgroundLoader.cpp b/stepmania/src/RageUtil_BackgroundLoader.cpp index e03e3b2073..e12584e984 100644 --- a/stepmania/src/RageUtil_BackgroundLoader.cpp +++ b/stepmania/src/RageUtil_BackgroundLoader.cpp @@ -83,7 +83,7 @@ CString BackgroundLoader::GetRequest() CString BackgroundLoader::GetCachePath( CString sPath ) const { - return m_sCachePathPrefix + "/" + sPath; + return m_sCachePathPrefix + sPath; } void BackgroundLoader::LoadThread() diff --git a/stepmania/src/RageUtil_FileDB.cpp b/stepmania/src/RageUtil_FileDB.cpp index 8aaefd9d9a..3d74a06969 100644 --- a/stepmania/src/RageUtil_FileDB.cpp +++ b/stepmania/src/RageUtil_FileDB.cpp @@ -113,7 +113,7 @@ RageFileManager::FileType FilenameDB::GetFileType( const CString &sPath ) CString Dir, Name; SplitPath( sPath, Dir, Name ); - if( Name == "." ) + if( Name == "/" ) return RageFileManager::TYPE_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 .. */ bool FilenameDB::ResolvePath(CString &path) { - if( path == "." || path == "" ) + if( path == "/" || path == "" ) return true; /* Split path into components. */ @@ -186,9 +186,7 @@ bool FilenameDB::ResolvePath(CString &path) return false; } - if( ret.size() != 0 ) - ret += "/"; - ret += it->name; + ret += "/" + it->name; fs = it->dirp; @@ -264,7 +262,7 @@ FileSet *FilenameDB::GetFileSet( CString dir, bool create ) dir.Replace("//", "/"); /* foo//bar -> foo/bar */ if( dir == "" ) - dir = "."; + dir = "/"; CString lower = dir; 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 * previously are no longer valid. */ FileSet **parent_dirp = NULL; - if( dir != "." && dir != "/" ) + if( dir != "/" ) { CString sParent = Dirname( dir ); if( sParent == "./" ) @@ -530,7 +528,6 @@ void FilenameDB::GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDi { // LOG->Trace( "GetDirListing( %s )", sPath.c_str() ); - /* If you want the CWD, use ".". */ ASSERT(!sPath.empty()); /* Strip off the last path element and use it as a mask. */