CString -> RString

const string params where possible for easier debug stepping
This commit is contained in:
Chris Danford
2005-12-28 03:59:52 +00:00
parent 1c209efd19
commit 1fcfc22981
11 changed files with 116 additions and 116 deletions
+2 -2
View File
@@ -70,7 +70,7 @@ void RageFileDriver::FlushDirCache( const RString &sPath )
const struct FileDriverEntry *g_pFileDriverList = NULL; const struct FileDriverEntry *g_pFileDriverList = NULL;
FileDriverEntry::FileDriverEntry( RString sType ) FileDriverEntry::FileDriverEntry( const RString &sType )
{ {
m_pLink = g_pFileDriverList; m_pLink = g_pFileDriverList;
g_pFileDriverList = this; g_pFileDriverList = this;
@@ -82,7 +82,7 @@ FileDriverEntry::~FileDriverEntry()
g_pFileDriverList = NULL; /* invalidate */ g_pFileDriverList = NULL; /* invalidate */
} }
RageFileDriver *MakeFileDriver( RString sType, RString sRoot ) RageFileDriver *MakeFileDriver( const RString &sType, const RString &sRoot )
{ {
for( const FileDriverEntry *p = g_pFileDriverList; p; p = p->m_pLink ) for( const FileDriverEntry *p = g_pFileDriverList; p; p = p->m_pLink )
if( !p->m_sType.CompareNoCase(sType) ) if( !p->m_sType.CompareNoCase(sType) )
+3 -3
View File
@@ -34,14 +34,14 @@ public:
/* This is used to register the driver, so RageFileManager can see it. */ /* This is used to register the driver, so RageFileManager can see it. */
struct FileDriverEntry struct FileDriverEntry
{ {
FileDriverEntry( RString sType ); FileDriverEntry( const RString &sType );
virtual ~FileDriverEntry(); virtual ~FileDriverEntry();
virtual RageFileDriver *Create( RString sRoot ) const = 0; virtual RageFileDriver *Create( const RString &sRoot ) const = 0;
RString m_sType; RString m_sType;
const FileDriverEntry *m_pLink; const FileDriverEntry *m_pLink;
}; };
RageFileDriver *MakeFileDriver( RString Type, RString Root ); RageFileDriver *MakeFileDriver( const RString &Type, const RString &Root );
#endif #endif
+23 -23
View File
@@ -24,7 +24,7 @@
static struct FileDriverEntry_DIR: public FileDriverEntry static struct FileDriverEntry_DIR: public FileDriverEntry
{ {
FileDriverEntry_DIR(): FileDriverEntry( "DIR" ) { } FileDriverEntry_DIR(): FileDriverEntry( "DIR" ) { }
RageFileDriver *Create( CString Root ) const { return new RageFileDriverDirect( Root ); } RageFileDriver *Create( const RString &sRoot ) const { return new RageFileDriverDirect( sRoot ); }
} const g_RegisterDriver; } const g_RegisterDriver;
/* This driver handles direct file access. */ /* This driver handles direct file access. */
@@ -32,14 +32,14 @@ static struct FileDriverEntry_DIR: public FileDriverEntry
class RageFileObjDirect: public RageFileObj class RageFileObjDirect: public RageFileObj
{ {
public: public:
RageFileObjDirect( const CString &sPath, int iFD, int iMode ); RageFileObjDirect( const RString &sPath, int iFD, int iMode );
virtual ~RageFileObjDirect(); virtual ~RageFileObjDirect();
virtual int ReadInternal( void *pBuffer, size_t iBytes ); virtual int ReadInternal( void *pBuffer, size_t iBytes );
virtual int WriteInternal( const void *pBuffer, size_t iBytes ); virtual int WriteInternal( const void *pBuffer, size_t iBytes );
virtual int FlushInternal(); virtual int FlushInternal();
virtual int SeekInternal( int offset ); virtual int SeekInternal( int offset );
virtual RageFileBasic *Copy() const; virtual RageFileBasic *Copy() const;
virtual CString GetDisplayPath() const { return m_sPath; } virtual RString GetDisplayPath() const { return m_sPath; }
virtual int GetFileSize() const; virtual int GetFileSize() const;
private: private:
@@ -47,8 +47,8 @@ private:
int m_iFD; int m_iFD;
int m_iMode; int m_iMode;
CString m_sPath; /* for Copy */ RString m_sPath; /* for Copy */
CString m_sWriteBuf; RString m_sWriteBuf;
/* /*
* When not streaming to disk, we write to a temporary file, and rename to the * When not streaming to disk, we write to a temporary file, and rename to the
@@ -60,14 +60,14 @@ private:
}; };
RageFileDriverDirect::RageFileDriverDirect( CString sRoot ): RageFileDriverDirect::RageFileDriverDirect( const RString &sRoot ):
RageFileDriver( new DirectFilenameDB(sRoot) ) RageFileDriver( new DirectFilenameDB(sRoot) )
{ {
Remount( sRoot ); Remount( sRoot );
} }
static CString MakeTempFilename( const CString &sPath ) static RString MakeTempFilename( const RString &sPath )
{ {
/* "Foo/bar/baz" -> "Foo/bar/new.baz.new". Both prepend and append: we don't /* "Foo/bar/baz" -> "Foo/bar/new.baz.new". Both prepend and append: we don't
* want a wildcard search for the filename to match (foo.txt.new matches foo.txt*), * want a wildcard search for the filename to match (foo.txt.new matches foo.txt*),
@@ -76,7 +76,7 @@ static CString MakeTempFilename( const CString &sPath )
return Dirname(sPath) + "new." + Basename(sPath) + ".new"; return Dirname(sPath) + "new." + Basename(sPath) + ".new";
} }
RageFileObj *MakeFileObjDirect( CString sPath, int iMode, int &iError ) RageFileObj *MakeFileObjDirect( RString sPath, int iMode, int &iError )
{ {
int iFD; int iFD;
if( iMode & RageFile::READ ) if( iMode & RageFile::READ )
@@ -89,7 +89,7 @@ RageFileObj *MakeFileObjDirect( CString sPath, int iMode, int &iError )
} }
else else
{ {
CString sOut; RString sOut;
if( iMode & RageFile::STREAMED ) if( iMode & RageFile::STREAMED )
sOut = sPath; sOut = sPath;
else else
@@ -108,9 +108,9 @@ RageFileObj *MakeFileObjDirect( CString sPath, int iMode, int &iError )
return new RageFileObjDirect( sPath, iFD, iMode ); return new RageFileObjDirect( sPath, iFD, iMode );
} }
RageFileBasic *RageFileDriverDirect::Open( const CString &sPath_, int iMode, int &iError ) RageFileBasic *RageFileDriverDirect::Open( const RString &sPath_, int iMode, int &iError )
{ {
CString sPath = sPath_; RString sPath = sPath_;
ASSERT( sPath.size() && sPath[0] == '/' ); ASSERT( sPath.size() && sPath[0] == '/' );
/* 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
@@ -120,7 +120,7 @@ RageFileBasic *RageFileDriverDirect::Open( const CString &sPath_, int iMode, int
if( iMode & RageFile::WRITE ) if( iMode & RageFile::WRITE )
{ {
const CString dir = Dirname(sPath); const RString dir = Dirname(sPath);
if( this->GetFileType(dir) != RageFileManager::TYPE_DIR ) if( this->GetFileType(dir) != RageFileManager::TYPE_DIR )
CreateDirectories( m_sRoot + dir ); CreateDirectories( m_sRoot + dir );
} }
@@ -128,10 +128,10 @@ RageFileBasic *RageFileDriverDirect::Open( const CString &sPath_, int iMode, int
return MakeFileObjDirect( m_sRoot + sPath, iMode, iError ); return MakeFileObjDirect( m_sRoot + sPath, iMode, iError );
} }
bool RageFileDriverDirect::Move( const CString &sOldPath_, const CString &sNewPath_ ) bool RageFileDriverDirect::Move( const RString &sOldPath_, const RString &sNewPath_ )
{ {
CString sOldPath = sOldPath_; RString sOldPath = sOldPath_;
CString sNewPath = sNewPath_; RString sNewPath = sNewPath_;
FDB->ResolvePath( sOldPath ); FDB->ResolvePath( sOldPath );
FDB->ResolvePath( sNewPath ); FDB->ResolvePath( sNewPath );
@@ -139,7 +139,7 @@ bool RageFileDriverDirect::Move( const CString &sOldPath_, const CString &sNewPa
return false; return false;
{ {
const CString sDir = Dirname(sNewPath); const RString sDir = Dirname(sNewPath);
CreateDirectories( m_sRoot + sDir ); CreateDirectories( m_sRoot + sDir );
} }
@@ -153,9 +153,9 @@ bool RageFileDriverDirect::Move( const CString &sOldPath_, const CString &sNewPa
return true; return true;
} }
bool RageFileDriverDirect::Remove( const CString &sPath_ ) bool RageFileDriverDirect::Remove( const RString &sPath_ )
{ {
CString sPath = sPath_; RString sPath = sPath_;
FDB->ResolvePath( sPath ); FDB->ResolvePath( sPath );
switch( this->GetFileType(sPath) ) switch( this->GetFileType(sPath) )
{ {
@@ -197,7 +197,7 @@ RageFileBasic *RageFileObjDirect::Copy() const
return ret; return ret;
} }
bool RageFileDriverDirect::Remount( const CString &sPath ) bool RageFileDriverDirect::Remount( const RString &sPath )
{ {
m_sRoot = sPath; m_sRoot = sPath;
((DirectFilenameDB *) FDB)->SetRoot( sPath ); ((DirectFilenameDB *) FDB)->SetRoot( sPath );
@@ -209,7 +209,7 @@ bool RageFileDriverDirect::Remount( const CString &sPath )
} }
static const unsigned int BUFSIZE = 1024*64; static const unsigned int BUFSIZE = 1024*64;
RageFileObjDirect::RageFileObjDirect( const CString &sPath, int iFD, int iMode ) RageFileObjDirect::RageFileObjDirect( const RString &sPath, int iFD, int iMode )
{ {
m_sPath = sPath; m_sPath = sPath;
m_iFD = iFD; m_iFD = iFD;
@@ -299,8 +299,8 @@ RageFileObjDirect::~RageFileObjDirect()
* file. * file.
*/ */
CString sOldPath = MakeTempFilename(m_sPath); RString sOldPath = MakeTempFilename(m_sPath);
CString sNewPath = m_sPath; RString sNewPath = m_sPath;
#if defined(WIN32) #if defined(WIN32)
if( WinMoveFile(DoPathReplace(sOldPath), DoPathReplace(sNewPath)) ) if( WinMoveFile(DoPathReplace(sOldPath), DoPathReplace(sNewPath)) )
@@ -308,7 +308,7 @@ RageFileObjDirect::~RageFileObjDirect()
/* We failed. */ /* We failed. */
int err = GetLastError(); int err = GetLastError();
const CString error = werr_ssprintf( err, "Error renaming \"%s\" to \"%s\"", sOldPath.c_str(), sNewPath.c_str() ); const RString error = werr_ssprintf( err, "Error renaming \"%s\" to \"%s\"", sOldPath.c_str(), sNewPath.c_str() );
LOG->Warn( "%s", error.c_str() ); LOG->Warn( "%s", error.c_str() );
SetError( error ); SetError( error );
break; break;
+6 -6
View File
@@ -8,15 +8,15 @@
class RageFileDriverDirect: public RageFileDriver class RageFileDriverDirect: public RageFileDriver
{ {
public: public:
RageFileDriverDirect( CString sRoot ); RageFileDriverDirect( const RString &sRoot );
RageFileBasic *Open( const CString &sPath, int iMode, int &iError ); RageFileBasic *Open( const RString &sPath, int iMode, int &iError );
bool Move( const CString &sOldPath, const CString &sNewPath ); bool Move( const RString &sOldPath, const RString &sNewPath );
bool Remove( const CString &sPath ); bool Remove( const RString &sPath );
bool Remount( const CString &sPath ); bool Remount( const RString &sPath );
private: private:
CString m_sRoot; RString m_sRoot;
}; };
#endif #endif
+22 -22
View File
@@ -20,45 +20,45 @@
#if defined(_XBOX) #if defined(_XBOX)
/* Wrappers for low-level file functions, to work around Xbox issues: */ /* Wrappers for low-level file functions, to work around Xbox issues: */
int DoMkdir( const CString &sPath, int perm ) int DoMkdir( const RString &sPath, int perm )
{ {
return mkdir( DoPathReplace(sPath), perm ); return mkdir( DoPathReplace(sPath), perm );
} }
int DoOpen( const CString &sPath, int flags, int perm ) int DoOpen( const RString &sPath, int flags, int perm )
{ {
return open( DoPathReplace(sPath), flags, perm ); return open( DoPathReplace(sPath), flags, perm );
} }
int DoStat( const CString &sPath, struct stat *st ) int DoStat( const RString &sPath, struct stat *st )
{ {
return stat( DoPathReplace(sPath), st ); return stat( DoPathReplace(sPath), st );
} }
int DoRename( const CString &sOldPath, const CString &sNewPath ) int DoRename( const RString &sOldPath, const RString &sNewPath )
{ {
return rename( DoPathReplace(sOldPath), DoPathReplace(sNewPath) ); return rename( DoPathReplace(sOldPath), DoPathReplace(sNewPath) );
} }
int DoRemove( const CString &sPath ) int DoRemove( const RString &sPath )
{ {
return remove( DoPathReplace(sPath) ); return remove( DoPathReplace(sPath) );
} }
int DoRmdir( const CString &sPath ) int DoRmdir( const RString &sPath )
{ {
return rmdir( DoPathReplace(sPath) ); return rmdir( DoPathReplace(sPath) );
} }
HANDLE DoFindFirstFile( const CString &sPath, WIN32_FIND_DATA *fd ) HANDLE DoFindFirstFile( const RString &sPath, WIN32_FIND_DATA *fd )
{ {
return FindFirstFile( DoPathReplace(sPath), fd ); return FindFirstFile( DoPathReplace(sPath), fd );
} }
#endif #endif
CString DoPathReplace(const CString &sPath) RString DoPathReplace(const RString &sPath)
{ {
CString TempPath = sPath; RString TempPath = sPath;
#if defined(XBOX) #if defined(XBOX)
TempPath.Replace( "//", "\\" ); TempPath.Replace( "//", "\\" );
TempPath.Replace( "/", "\\" ); TempPath.Replace( "/", "\\" );
@@ -68,7 +68,7 @@ CString DoPathReplace(const CString &sPath)
#if defined(WIN32) #if defined(WIN32)
static bool WinMoveFileInternal( const CString &sOldPath, const CString &sNewPath ) static bool WinMoveFileInternal( const RString &sOldPath, const RString &sNewPath )
{ {
static bool Win9x = false; static bool Win9x = false;
@@ -102,7 +102,7 @@ static bool WinMoveFileInternal( const CString &sOldPath, const CString &sNewPat
return !!MoveFile( sOldPath, sNewPath ); return !!MoveFile( sOldPath, sNewPath );
} }
bool WinMoveFile( CString sOldPath, CString sNewPath ) bool WinMoveFile( RString sOldPath, RString sNewPath )
{ {
if( WinMoveFileInternal( DoPathReplace(sOldPath), DoPathReplace(sNewPath) ) ) if( WinMoveFileInternal( DoPathReplace(sOldPath), DoPathReplace(sNewPath) ) )
return true; return true;
@@ -116,11 +116,11 @@ bool WinMoveFile( CString sOldPath, CString sNewPath )
#endif #endif
/* mkdir -p. Doesn't fail if Path already exists and is a directory. */ /* mkdir -p. Doesn't fail if Path already exists and is a directory. */
bool CreateDirectories( CString Path ) bool CreateDirectories( RString Path )
{ {
/* XXX: handle "//foo/bar" paths in Windows */ /* XXX: handle "//foo/bar" paths in Windows */
vector<CString> parts; vector<RString> parts;
CString curpath; RString curpath;
/* If Path is absolute, add the initial slash ("ignore empty" will remove it). */ /* If Path is absolute, add the initial slash ("ignore empty" will remove it). */
if( Path.Left(1) == "/" ) if( Path.Left(1) == "/" )
@@ -176,14 +176,14 @@ bool CreateDirectories( CString Path )
return true; return true;
} }
DirectFilenameDB::DirectFilenameDB( CString root_ ) DirectFilenameDB::DirectFilenameDB( RString root_ )
{ {
ExpireSeconds = 30; ExpireSeconds = 30;
SetRoot( root_ ); SetRoot( root_ );
} }
void DirectFilenameDB::SetRoot( CString root_ ) void DirectFilenameDB::SetRoot( RString root_ )
{ {
root = root_; root = root_;
@@ -196,9 +196,9 @@ void DirectFilenameDB::SetRoot( CString root_ )
} }
void DirectFilenameDB::PopulateFileSet( FileSet &fs, const CString &path ) void DirectFilenameDB::PopulateFileSet( FileSet &fs, const RString &path )
{ {
CString sPath = path; RString sPath = path;
#if defined(XBOX) #if defined(XBOX)
/* Xbox doesn't handle path names which end with ".", which are used when using an /* Xbox doesn't handle path names which end with ".", which are used when using an
@@ -293,21 +293,21 @@ void DirectFilenameDB::PopulateFileSet( FileSet &fs, const CString &path )
* performance-critical situations. To avoid incurring some of the overheard * performance-critical situations. To avoid incurring some of the overheard
* due to ignore markers, delete the file instead instead of using an ignore marker. * due to ignore markers, delete the file instead instead of using an ignore marker.
*/ */
static const CString IGNORE_MARKER_BEGINNING = "ignore-"; static const RString IGNORE_MARKER_BEGINNING = "ignore-";
vector<CString> vsFilesToRemove; vector<RString> vsFilesToRemove;
for( set<File>::iterator iter = fs.files.lower_bound(IGNORE_MARKER_BEGINNING); for( set<File>::iterator iter = fs.files.lower_bound(IGNORE_MARKER_BEGINNING);
iter != fs.files.end(); iter != fs.files.end();
iter++ ) iter++ )
{ {
if( !BeginsWith( iter->lname, IGNORE_MARKER_BEGINNING ) ) if( !BeginsWith( iter->lname, IGNORE_MARKER_BEGINNING ) )
break; break;
CString sFileLNameToIgnore = iter->lname.Right( iter->lname.length() - IGNORE_MARKER_BEGINNING.length() ); RString sFileLNameToIgnore = iter->lname.Right( iter->lname.length() - IGNORE_MARKER_BEGINNING.length() );
vsFilesToRemove.push_back( iter->name ); vsFilesToRemove.push_back( iter->name );
vsFilesToRemove.push_back( sFileLNameToIgnore ); vsFilesToRemove.push_back( sFileLNameToIgnore );
} }
FOREACH_CONST( CString, vsFilesToRemove, iter ) FOREACH_CONST( RString, vsFilesToRemove, iter )
{ {
// Erase the file corresponding to the ignore marker // Erase the file corresponding to the ignore marker
File fileToDelete; File fileToDelete;
+14 -14
View File
@@ -6,13 +6,13 @@
#include <fcntl.h> #include <fcntl.h>
#if defined(_XBOX) #if defined(_XBOX)
int DoMkdir( const CString &sPath, int perm ); int DoMkdir( const RString &sPath, int perm );
int DoOpen( const CString &sPath, int flags, int perm ); int DoOpen( const RString &sPath, int flags, int perm );
int DoStat( const CString &sPath, struct stat *st ); int DoStat( const RString &sPath, struct stat *st );
int DoRename( const CString &sOldPath, const CString &sNewPath ); int DoRename( const RString &sOldPath, const RString &sNewPath );
int DoRemove( const CString &sPath ); int DoRemove( const RString &sPath );
int DoRmdir( const CString &sPath ); int DoRmdir( const RString &sPath );
HANDLE DoFindFirstFile( const CString &sPath, WIN32_FIND_DATA *fd ); HANDLE DoFindFirstFile( const RString &sPath, WIN32_FIND_DATA *fd );
#else #else
#define DoOpen open #define DoOpen open
#define DoStat stat #define DoStat stat
@@ -22,28 +22,28 @@ HANDLE DoFindFirstFile( const CString &sPath, WIN32_FIND_DATA *fd );
#define DoRemove remove #define DoRemove remove
#define DoRmdir rmdir #define DoRmdir rmdir
#endif #endif
CString DoPathReplace( const CString &sPath ); RString DoPathReplace( const RString &sPath );
#if defined(WIN32) #if defined(WIN32)
bool WinMoveFile( CString sOldPath, CString sNewPath ); bool WinMoveFile( RString sOldPath, RString sNewPath );
#endif #endif
#if !defined(O_BINARY) #if !defined(O_BINARY)
#define O_BINARY 0 #define O_BINARY 0
#endif #endif
bool CreateDirectories( CString sPath ); bool CreateDirectories( RString sPath );
#include "RageUtil_FileDB.h" #include "RageUtil_FileDB.h"
class DirectFilenameDB: public FilenameDB class DirectFilenameDB: public FilenameDB
{ {
public: public:
DirectFilenameDB( CString root ); DirectFilenameDB( RString root );
void SetRoot( CString root ); void SetRoot( RString root );
protected: protected:
virtual void PopulateFileSet( FileSet &fs, const CString &sPath ); virtual void PopulateFileSet( FileSet &fs, const RString &sPath );
CString root; RString root;
}; };
#endif #endif
+1 -1
View File
@@ -177,7 +177,7 @@ bool RageFileDriverMem::Remove( const RString &sPath )
static struct FileDriverEntry_MEM: public FileDriverEntry static struct FileDriverEntry_MEM: public FileDriverEntry
{ {
FileDriverEntry_MEM(): FileDriverEntry( "MEM" ) { } FileDriverEntry_MEM(): FileDriverEntry( "MEM" ) { }
RageFileDriver *Create( RString Root ) const { return new RageFileDriverMem(); } RageFileDriver *Create( const RString &sRoot ) const { return new RageFileDriverMem(); }
} const g_RegisterDriver; } const g_RegisterDriver;
/* /*
+37 -37
View File
@@ -69,25 +69,25 @@ enum ThreadRequest
class ThreadedFileWorker: public RageWorkerThread class ThreadedFileWorker: public RageWorkerThread
{ {
public: public:
ThreadedFileWorker( CString sPath ); ThreadedFileWorker( RString sPath );
~ThreadedFileWorker(); ~ThreadedFileWorker();
/* Threaded operations. If a file operation times out, the caller loses all access /* Threaded operations. If a file operation times out, the caller loses all access
* to the file and should fail all future operations; this is because the thread * to the file and should fail all future operations; this is because the thread
* is still trying to finish the operation. The thread will clean up afterwards. */ * is still trying to finish the operation. The thread will clean up afterwards. */
RageFileBasic *Open( const CString &sPath, int iMode, int &iErr ); RageFileBasic *Open( const RString &sPath, int iMode, int &iErr );
void Close( RageFileBasic *pFile ); void Close( RageFileBasic *pFile );
int GetFileSize( RageFileBasic *&pFile ); int GetFileSize( RageFileBasic *&pFile );
int Seek( RageFileBasic *&pFile, int iPos, CString &sError ); int Seek( RageFileBasic *&pFile, int iPos, RString &sError );
int Read( RageFileBasic *&pFile, void *pBuf, int iSize, CString &sError ); int Read( RageFileBasic *&pFile, void *pBuf, int iSize, RString &sError );
int Write( RageFileBasic *&pFile, const void *pBuf, int iSize, CString &sError ); int Write( RageFileBasic *&pFile, const void *pBuf, int iSize, RString &sError );
int Flush( RageFileBasic *&pFile, CString &sError ); int Flush( RageFileBasic *&pFile, RString &sError );
RageFileBasic *Copy( RageFileBasic *&pFile, CString &sError ); RageFileBasic *Copy( RageFileBasic *&pFile, RString &sError );
bool FlushDirCache( const CString &sPath ); bool FlushDirCache( const RString &sPath );
int Move( const CString &sOldPath, const CString &sNewPath ); int Move( const RString &sOldPath, const RString &sNewPath );
int Remove( const CString &sPath ); int Remove( const RString &sPath );
bool PopulateFileSet( FileSet &fs, const CString &sPath ); bool PopulateFileSet( FileSet &fs, const RString &sPath );
protected: protected:
void HandleRequest( int iRequest ); void HandleRequest( int iRequest );
@@ -103,10 +103,10 @@ private:
RageMutex m_DeletedFilesLock; RageMutex m_DeletedFilesLock;
/* REQ_OPEN, REQ_POPULATE_FILE_SET, REQ_FLUSH_DIR_CACHE, REQ_REMOVE, REQ_MOVE: */ /* REQ_OPEN, REQ_POPULATE_FILE_SET, REQ_FLUSH_DIR_CACHE, REQ_REMOVE, REQ_MOVE: */
CString m_sRequestPath; /* in */ RString m_sRequestPath; /* in */
/* REQ_MOVE: */ /* REQ_MOVE: */
CString m_sRequestPath2; /* in */ RString m_sRequestPath2; /* in */
/* REQ_OPEN, REQ_COPY: */ /* REQ_OPEN, REQ_COPY: */
RageFileBasic *m_pResultFile; /* out */ RageFileBasic *m_pResultFile; /* out */
@@ -125,7 +125,7 @@ private:
/* REQ_READ, REQ_WRITE */ /* REQ_READ, REQ_WRITE */
int m_iRequestSize; /* in */ int m_iRequestSize; /* in */
CString m_sResultError; /* out */ RString m_sResultError; /* out */
/* REQ_SEEK */ /* REQ_SEEK */
int m_iRequestPos; /* in */ int m_iRequestPos; /* in */
@@ -150,7 +150,7 @@ void RageFileDriverTimeout::SetTimeout( float fSeconds )
} }
ThreadedFileWorker::ThreadedFileWorker( CString sPath ): ThreadedFileWorker::ThreadedFileWorker( RString sPath ):
RageWorkerThread( sPath ), RageWorkerThread( sPath ),
m_DeletedFilesLock( sPath + "DeletedFilesLock" ) m_DeletedFilesLock( sPath + "DeletedFilesLock" )
{ {
@@ -292,7 +292,7 @@ void ThreadedFileWorker::RequestTimedOut()
SAFE_DELETE_ARRAY( m_pResultBuffer ); SAFE_DELETE_ARRAY( m_pResultBuffer );
} }
RageFileBasic *ThreadedFileWorker::Open( const CString &sPath, int iMode, int &iErr ) RageFileBasic *ThreadedFileWorker::Open( const RString &sPath, int iMode, int &iErr )
{ {
if( m_pChildDriver == NULL ) if( m_pChildDriver == NULL )
{ {
@@ -377,7 +377,7 @@ int ThreadedFileWorker::GetFileSize( RageFileBasic *&pFile )
return m_iResultRequest; return m_iResultRequest;
} }
int ThreadedFileWorker::Seek( RageFileBasic *&pFile, int iPos, CString &sError ) int ThreadedFileWorker::Seek( RageFileBasic *&pFile, int iPos, RString &sError )
{ {
ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */ ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */
@@ -412,7 +412,7 @@ int ThreadedFileWorker::Seek( RageFileBasic *&pFile, int iPos, CString &sError )
return m_iResultRequest; return m_iResultRequest;
} }
int ThreadedFileWorker::Read( RageFileBasic *&pFile, void *pBuf, int iSize, CString &sError ) int ThreadedFileWorker::Read( RageFileBasic *&pFile, void *pBuf, int iSize, RString &sError )
{ {
ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */ ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */
@@ -454,7 +454,7 @@ int ThreadedFileWorker::Read( RageFileBasic *&pFile, void *pBuf, int iSize, CStr
return iGot; return iGot;
} }
int ThreadedFileWorker::Write( RageFileBasic *&pFile, const void *pBuf, int iSize, CString &sError ) int ThreadedFileWorker::Write( RageFileBasic *&pFile, const void *pBuf, int iSize, RString &sError )
{ {
ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */ ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */
@@ -495,7 +495,7 @@ int ThreadedFileWorker::Write( RageFileBasic *&pFile, const void *pBuf, int iSiz
return iGot; return iGot;
} }
int ThreadedFileWorker::Flush( RageFileBasic *&pFile, CString &sError ) int ThreadedFileWorker::Flush( RageFileBasic *&pFile, RString &sError )
{ {
ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */ ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */
@@ -530,7 +530,7 @@ int ThreadedFileWorker::Flush( RageFileBasic *&pFile, CString &sError )
return m_iResultRequest; return m_iResultRequest;
} }
RageFileBasic *ThreadedFileWorker::Copy( RageFileBasic *&pFile, CString &sError ) RageFileBasic *ThreadedFileWorker::Copy( RageFileBasic *&pFile, RString &sError )
{ {
ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */ ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */
@@ -564,7 +564,7 @@ RageFileBasic *ThreadedFileWorker::Copy( RageFileBasic *&pFile, CString &sError
} }
bool ThreadedFileWorker::PopulateFileSet( FileSet &fs, const CString &sPath ) bool ThreadedFileWorker::PopulateFileSet( FileSet &fs, const RString &sPath )
{ {
if( m_pChildDriver == NULL ) if( m_pChildDriver == NULL )
return false; return false;
@@ -587,7 +587,7 @@ bool ThreadedFileWorker::PopulateFileSet( FileSet &fs, const CString &sPath )
return true; return true;
} }
int ThreadedFileWorker::Move( const CString &sOldPath, const CString &sNewPath ) int ThreadedFileWorker::Move( const RString &sOldPath, const RString &sNewPath )
{ {
ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */ ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */
@@ -607,7 +607,7 @@ int ThreadedFileWorker::Move( const CString &sOldPath, const CString &sNewPath )
return m_iResultRequest; return m_iResultRequest;
} }
int ThreadedFileWorker::Remove( const CString &sPath ) int ThreadedFileWorker::Remove( const RString &sPath )
{ {
ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */ ASSERT( m_pChildDriver != NULL ); /* how did you get a file to begin with? */
@@ -626,7 +626,7 @@ int ThreadedFileWorker::Remove( const CString &sPath )
return m_iResultRequest; return m_iResultRequest;
} }
bool ThreadedFileWorker::FlushDirCache( const CString &sPath ) bool ThreadedFileWorker::FlushDirCache( const RString &sPath )
{ {
/* FlushDirCache() is often called globally, on all drivers, which means it's called with /* FlushDirCache() is often called globally, on all drivers, which means it's called with
* no timeout. Temporarily enable a timeout if needed. */ * no timeout. Temporarily enable a timeout if needed. */
@@ -684,7 +684,7 @@ public:
RageFileBasic *Copy() const RageFileBasic *Copy() const
{ {
CString sError; RString sError;
RageFileBasic *pCopy = m_pWorker->Copy( m_pFile, sError ); RageFileBasic *pCopy = m_pWorker->Copy( m_pFile, sError );
if( m_pFile == NULL ) if( m_pFile == NULL )
@@ -705,7 +705,7 @@ public:
protected: protected:
int SeekInternal( int iPos ) int SeekInternal( int iPos )
{ {
CString sError; RString sError;
int iRet = m_pWorker->Seek( m_pFile, iPos, sError ); int iRet = m_pWorker->Seek( m_pFile, iPos, sError );
if( m_pFile == NULL ) if( m_pFile == NULL )
@@ -723,7 +723,7 @@ protected:
int ReadInternal( void *pBuffer, size_t iBytes ) int ReadInternal( void *pBuffer, size_t iBytes )
{ {
CString sError; RString sError;
int iRet = m_pWorker->Read( m_pFile, pBuffer, iBytes, sError ); int iRet = m_pWorker->Read( m_pFile, pBuffer, iBytes, sError );
if( m_pFile == NULL ) if( m_pFile == NULL )
@@ -740,7 +740,7 @@ protected:
int WriteInternal( const void *pBuffer, size_t iBytes ) int WriteInternal( const void *pBuffer, size_t iBytes )
{ {
CString sError; RString sError;
int iRet = m_pWorker->Write( m_pFile, pBuffer, iBytes, sError ); int iRet = m_pWorker->Write( m_pFile, pBuffer, iBytes, sError );
if( m_pFile == NULL ) if( m_pFile == NULL )
@@ -757,7 +757,7 @@ protected:
int FlushInternal() int FlushInternal()
{ {
CString sError; RString sError;
int iRet = m_pWorker->Flush( m_pFile, sError ); int iRet = m_pWorker->Flush( m_pFile, sError );
if( m_pFile == NULL ) if( m_pFile == NULL )
@@ -798,7 +798,7 @@ public:
m_pWorker = pWorker; m_pWorker = pWorker;
} }
void PopulateFileSet( FileSet &fs, const CString &sPath ) void PopulateFileSet( FileSet &fs, const RString &sPath )
{ {
ASSERT( m_pWorker != NULL ); ASSERT( m_pWorker != NULL );
m_pWorker->PopulateFileSet( fs, sPath ); m_pWorker->PopulateFileSet( fs, sPath );
@@ -808,7 +808,7 @@ private:
ThreadedFileWorker *m_pWorker; ThreadedFileWorker *m_pWorker;
}; };
RageFileDriverTimeout::RageFileDriverTimeout( CString sPath ): RageFileDriverTimeout::RageFileDriverTimeout( const RString &sPath ):
RageFileDriver( new TimedFilenameDB() ) RageFileDriver( new TimedFilenameDB() )
{ {
m_pWorker = new ThreadedFileWorker( sPath ); m_pWorker = new ThreadedFileWorker( sPath );
@@ -816,7 +816,7 @@ RageFileDriverTimeout::RageFileDriverTimeout( CString sPath ):
((TimedFilenameDB *) FDB)->SetWorker( m_pWorker ); ((TimedFilenameDB *) FDB)->SetWorker( m_pWorker );
} }
RageFileBasic *RageFileDriverTimeout::Open( const CString &sPath, int iMode, int &iErr ) RageFileBasic *RageFileDriverTimeout::Open( const RString &sPath, int iMode, int &iErr )
{ {
RageFileBasic *pChildFile = m_pWorker->Open( sPath, iMode, iErr ); RageFileBasic *pChildFile = m_pWorker->Open( sPath, iMode, iErr );
if( pChildFile == NULL ) if( pChildFile == NULL )
@@ -840,13 +840,13 @@ RageFileBasic *RageFileDriverTimeout::Open( const CString &sPath, int iMode, int
return new RageFileObjTimeout( m_pWorker, pChildFile, iSize ); return new RageFileObjTimeout( m_pWorker, pChildFile, iSize );
} }
void RageFileDriverTimeout::FlushDirCache( const CString &sPath ) void RageFileDriverTimeout::FlushDirCache( const RString &sPath )
{ {
RageFileDriver::FlushDirCache( sPath ); RageFileDriver::FlushDirCache( sPath );
m_pWorker->FlushDirCache( sPath ); m_pWorker->FlushDirCache( sPath );
} }
bool RageFileDriverTimeout::Move( const CString &sOldPath, const CString &sNewPath ) bool RageFileDriverTimeout::Move( const RString &sOldPath, const RString &sNewPath )
{ {
int iRet = m_pWorker->Move( sOldPath, sNewPath ); int iRet = m_pWorker->Move( sOldPath, sNewPath );
if( iRet == -1 ) if( iRet == -1 )
@@ -858,7 +858,7 @@ bool RageFileDriverTimeout::Move( const CString &sOldPath, const CString &sNewPa
return true; return true;
} }
bool RageFileDriverTimeout::Remove( const CString &sPath ) bool RageFileDriverTimeout::Remove( const RString &sPath )
{ {
int iRet = m_pWorker->Remove( sPath ); int iRet = m_pWorker->Remove( sPath );
if( iRet == -1 ) if( iRet == -1 )
@@ -878,7 +878,7 @@ RageFileDriverTimeout::~RageFileDriverTimeout()
static struct FileDriverEntry_Timeout: public FileDriverEntry static struct FileDriverEntry_Timeout: public FileDriverEntry
{ {
FileDriverEntry_Timeout(): FileDriverEntry( "TIMEOUT" ) { } FileDriverEntry_Timeout(): FileDriverEntry( "TIMEOUT" ) { }
RageFileDriver *Create( CString Root ) const { return new RageFileDriverTimeout( Root ); } RageFileDriver *Create( const RString &sRoot ) const { return new RageFileDriverTimeout( sRoot ); }
} const g_RegisterDriver; } const g_RegisterDriver;
/* /*
+5 -5
View File
@@ -10,13 +10,13 @@ class ThreadedFileWorker;
class RageFileDriverTimeout: public RageFileDriver class RageFileDriverTimeout: public RageFileDriver
{ {
public: public:
RageFileDriverTimeout( CString path ); RageFileDriverTimeout( const RString &path );
virtual ~RageFileDriverTimeout(); virtual ~RageFileDriverTimeout();
RageFileBasic *Open( const CString &path, int mode, int &err ); RageFileBasic *Open( const RString &path, int mode, int &err );
void FlushDirCache( const CString &sPath ); void FlushDirCache( const RString &sPath );
bool Move( const CString &sOldPath, const CString &sNewPath ); bool Move( const RString &sOldPath, const RString &sNewPath );
bool Remove( const CString &sPath ); bool Remove( const RString &sPath );
static void SetTimeout( float fSeconds ); static void SetTimeout( float fSeconds );
static void ResetTimeout() { SetTimeout( -1 ); } static void ResetTimeout() { SetTimeout( -1 ); }
+2 -2
View File
@@ -15,7 +15,7 @@
static struct FileDriverEntry_ZIP: public FileDriverEntry static struct FileDriverEntry_ZIP: public FileDriverEntry
{ {
FileDriverEntry_ZIP(): FileDriverEntry( "ZIP" ) { } FileDriverEntry_ZIP(): FileDriverEntry( "ZIP" ) { }
RageFileDriver *Create( RString Root ) const { return new RageFileDriverZip( Root ); } RageFileDriver *Create( const RString &sRoot ) const { return new RageFileDriverZip( sRoot ); }
} const g_RegisterDriver; } const g_RegisterDriver;
@@ -27,7 +27,7 @@ RageFileDriverZip::RageFileDriverZip():
m_pZip = NULL; m_pZip = NULL;
} }
RageFileDriverZip::RageFileDriverZip( RString sPath ): RageFileDriverZip::RageFileDriverZip( const RString &sPath ):
RageFileDriver( new NullFilenameDB ), RageFileDriver( new NullFilenameDB ),
m_Mutex( "RageFileDriverZip" ) m_Mutex( "RageFileDriverZip" )
{ {
+1 -1
View File
@@ -10,7 +10,7 @@ class RageFileDriverZip: public RageFileDriver
{ {
public: public:
RageFileDriverZip(); RageFileDriverZip();
RageFileDriverZip( RString sPath ); RageFileDriverZip( const RString &sPath );
bool Load( const RString &sPath ); bool Load( const RString &sPath );
bool Load( RageFileBasic *pFile ); bool Load( RageFileBasic *pFile );