CString -> RString

This commit is contained in:
Chris Danford
2005-12-28 19:17:34 +00:00
parent 1e51ee136d
commit bd0087ae04
3 changed files with 42 additions and 42 deletions
+2 -2
View File
@@ -16,10 +16,10 @@ void RageException::Throw(const char *fmt, ...)
{ {
va_list va; va_list va;
va_start(va, fmt); va_start(va, fmt);
CString error = vssprintf( fmt, va ); RString error = vssprintf( fmt, va );
va_end(va); va_end(va);
CString msg = ssprintf( RString msg = ssprintf(
"\n" "\n"
"//////////////////////////////////////////////////////\n" "//////////////////////////////////////////////////////\n"
"Exception: %s\n" "Exception: %s\n"
+20 -20
View File
@@ -30,19 +30,19 @@ RageFileBasic *RageFile::Copy() const
return new RageFile( *this ); return new RageFile( *this );
} }
CString RageFile::GetPath() const RString RageFile::GetPath() const
{ {
if ( !IsOpen() ) if ( !IsOpen() )
return CString(); return RString();
CString sRet = m_File->GetDisplayPath(); RString sRet = m_File->GetDisplayPath();
if( sRet != "" ) if( sRet != "" )
return sRet; return sRet;
return GetRealPath(); return GetRealPath();
} }
bool RageFile::Open( const CString& path, int mode ) bool RageFile::Open( const RString& path, int mode )
{ {
ASSERT( FILEMAN ); ASSERT( FILEMAN );
Close(); Close();
@@ -84,13 +84,13 @@ void RageFile::Close()
#define ASSERT_OPEN ASSERT_M( IsOpen(), ssprintf("\"%s\" is not open.", m_Path.c_str()) ); #define ASSERT_OPEN ASSERT_M( IsOpen(), ssprintf("\"%s\" is not open.", m_Path.c_str()) );
#define ASSERT_READ ASSERT_OPEN; ASSERT_M( !!(m_Mode&READ), ssprintf("\"%s\" is not open for reading", m_Path.c_str()) ); #define ASSERT_READ ASSERT_OPEN; ASSERT_M( !!(m_Mode&READ), ssprintf("\"%s\" is not open for reading", m_Path.c_str()) );
#define ASSERT_WRITE ASSERT_OPEN; ASSERT_M( !!(m_Mode&WRITE), ssprintf("\"%s\" is not open for writing", m_Path.c_str()) ); #define ASSERT_WRITE ASSERT_OPEN; ASSERT_M( !!(m_Mode&WRITE), ssprintf("\"%s\" is not open for writing", m_Path.c_str()) );
int RageFile::GetLine( CString &out ) int RageFile::GetLine( RString &out )
{ {
ASSERT_READ; ASSERT_READ;
return m_File->GetLine( out ); return m_File->GetLine( out );
} }
int RageFile::PutLine( const CString &str ) int RageFile::PutLine( const RString &str )
{ {
ASSERT_WRITE; ASSERT_WRITE;
return m_File->PutLine( str ); return m_File->PutLine( str );
@@ -122,7 +122,7 @@ void RageFile::ClearError()
m_sError = ""; m_sError = "";
} }
CString RageFile::GetError() const RString RageFile::GetError() const
{ {
if( m_File != NULL && m_File->GetError() != "" ) if( m_File != NULL && m_File->GetError() != "" )
return m_File->GetError(); return m_File->GetError();
@@ -130,7 +130,7 @@ CString RageFile::GetError() const
} }
void RageFile::SetError( const CString &err ) void RageFile::SetError( const RString &err )
{ {
if( m_File != NULL ) if( m_File != NULL )
m_File->ClearError(); m_File->ClearError();
@@ -161,7 +161,7 @@ int RageFile::GetFileSize() const
return m_File->GetFileSize(); return m_File->GetFileSize();
} }
int RageFile::Read( CString &buffer, int bytes ) int RageFile::Read( RString &buffer, int bytes )
{ {
ASSERT_READ; ASSERT_READ;
return m_File->Read( buffer, bytes ); return m_File->Read( buffer, bytes );
@@ -203,7 +203,7 @@ int RageFile::Seek( int offset, int whence )
return m_File->Seek( offset, whence ); return m_File->Seek( offset, whence );
} }
void FileReading::ReadBytes( RageFileBasic &f, void *buf, int size, CString &sError ) void FileReading::ReadBytes( RageFileBasic &f, void *buf, int size, RString &sError )
{ {
if( sError.size() != 0 ) if( sError.size() != 0 )
return; return;
@@ -215,12 +215,12 @@ void FileReading::ReadBytes( RageFileBasic &f, void *buf, int size, CString &sEr
sError = "Unexpected end of file"; sError = "Unexpected end of file";
} }
CString FileReading::ReadString( RageFileBasic &f, int size, CString &sError ) RString FileReading::ReadString( RageFileBasic &f, int size, RString &sError )
{ {
if( sError.size() != 0 ) if( sError.size() != 0 )
return CString(); return RString();
CString sBuf; RString sBuf;
int ret = f.Read( sBuf, size ); int ret = f.Read( sBuf, size );
if( ret == -1 ) if( ret == -1 )
sError = f.GetError(); sError = f.GetError();
@@ -229,7 +229,7 @@ CString FileReading::ReadString( RageFileBasic &f, int size, CString &sError )
return sBuf; return sBuf;
} }
void FileReading::SkipBytes( RageFileBasic &f, int iBytes, CString &sError ) void FileReading::SkipBytes( RageFileBasic &f, int iBytes, RString &sError )
{ {
if( sError.size() != 0 ) if( sError.size() != 0 )
return; return;
@@ -238,7 +238,7 @@ void FileReading::SkipBytes( RageFileBasic &f, int iBytes, CString &sError )
FileReading::Seek( f, iBytes, sError ); FileReading::Seek( f, iBytes, sError );
} }
void FileReading::Seek( RageFileBasic &f, int iOffset, CString &sError ) void FileReading::Seek( RageFileBasic &f, int iOffset, RString &sError )
{ {
if( sError.size() != 0 ) if( sError.size() != 0 )
return; return;
@@ -252,7 +252,7 @@ void FileReading::Seek( RageFileBasic &f, int iOffset, CString &sError )
sError = "Unexpected end of file"; sError = "Unexpected end of file";
} }
uint8_t FileReading::read_8( RageFileBasic &f, CString &sError ) uint8_t FileReading::read_8( RageFileBasic &f, RString &sError )
{ {
uint8_t val; uint8_t val;
ReadBytes( f, &val, sizeof(uint8_t), sError ); ReadBytes( f, &val, sizeof(uint8_t), sError );
@@ -262,7 +262,7 @@ uint8_t FileReading::read_8( RageFileBasic &f, CString &sError )
return 0; return 0;
} }
uint16_t FileReading::read_u16_le( RageFileBasic &f, CString &sError ) uint16_t FileReading::read_u16_le( RageFileBasic &f, RString &sError )
{ {
uint16_t val; uint16_t val;
ReadBytes( f, &val, sizeof(uint16_t), sError ); ReadBytes( f, &val, sizeof(uint16_t), sError );
@@ -272,7 +272,7 @@ uint16_t FileReading::read_u16_le( RageFileBasic &f, CString &sError )
return 0; return 0;
} }
int16_t FileReading::read_16_le( RageFileBasic &f, CString &sError ) int16_t FileReading::read_16_le( RageFileBasic &f, RString &sError )
{ {
int16_t val; int16_t val;
ReadBytes( f, &val, sizeof(int16_t), sError ); ReadBytes( f, &val, sizeof(int16_t), sError );
@@ -282,7 +282,7 @@ int16_t FileReading::read_16_le( RageFileBasic &f, CString &sError )
return 0; return 0;
} }
uint32_t FileReading::read_u32_le( RageFileBasic &f, CString &sError ) uint32_t FileReading::read_u32_le( RageFileBasic &f, RString &sError )
{ {
uint32_t val; uint32_t val;
ReadBytes( f, &val, sizeof(uint32_t), sError ); ReadBytes( f, &val, sizeof(uint32_t), sError );
@@ -292,7 +292,7 @@ uint32_t FileReading::read_u32_le( RageFileBasic &f, CString &sError )
return 0; return 0;
} }
int32_t FileReading::read_32_le( RageFileBasic &f, CString &sError ) int32_t FileReading::read_32_le( RageFileBasic &f, RString &sError )
{ {
int32_t val; int32_t val;
ReadBytes( f, &val, sizeof(int32_t), sError ); ReadBytes( f, &val, sizeof(int32_t), sError );
+20 -20
View File
@@ -34,15 +34,15 @@ public:
* GetPath can be overridden by drivers. Use it to get a path for display; * GetPath can be overridden by drivers. Use it to get a path for display;
* it may give more information, such as the name of the archive the file * it may give more information, such as the name of the archive the file
* is in. It has no parsable meaning. */ * is in. It has no parsable meaning. */
const CString &GetRealPath() const { return m_Path; } const RString &GetRealPath() const { return m_Path; }
CString GetPath() const; RString GetPath() const;
bool Open( const CString& path, int mode = READ ); bool Open( const RString& path, int mode = READ );
void Close(); void Close();
bool IsOpen() const { return m_File != NULL; } bool IsOpen() const { return m_File != NULL; }
bool AtEOF() const; bool AtEOF() const;
CString GetError() const; RString GetError() const;
void ClearError(); void ClearError();
int Tell() const; int Tell() const;
@@ -51,9 +51,9 @@ public:
/* Raw I/O: */ /* Raw I/O: */
int Read( void *buffer, size_t bytes ); int Read( void *buffer, size_t bytes );
int Read( CString &buffer, int bytes = -1 ); int Read( RString &buffer, int bytes = -1 );
int Write( const void *buffer, size_t bytes ); int Write( const void *buffer, size_t bytes );
int Write( const CString& string ) { return Write( string.data(), string.size() ); } int Write( const RString& string ) { return Write( string.data(), string.size() ); }
int Flush(); int Flush();
/* These are just here to make wrappers (eg. vorbisfile, SDL_rwops) easier. */ /* These are just here to make wrappers (eg. vorbisfile, SDL_rwops) easier. */
@@ -62,19 +62,19 @@ public:
int Seek( int offset, int whence ); int Seek( int offset, int whence );
/* Line-based I/O: */ /* Line-based I/O: */
int GetLine( CString &out ); int GetLine( RString &out );
int PutLine( const CString &str ); int PutLine( const RString &str );
void EnableCRC32( bool on=true ); void EnableCRC32( bool on=true );
bool GetCRC32( uint32_t *iRet ); bool GetCRC32( uint32_t *iRet );
protected: protected:
void SetError( const CString &err ); void SetError( const RString &err );
private: private:
RageFileBasic *m_File; RageFileBasic *m_File;
CString m_Path; RString m_Path;
CString m_sError; RString m_sError;
int m_Mode; int m_Mode;
}; };
@@ -83,15 +83,15 @@ namespace FileReading
{ {
/* On error, these set sError to the error message. If sError is already /* On error, these set sError to the error message. If sError is already
* non-empty, nothing happens. */ * non-empty, nothing happens. */
void ReadBytes( RageFileBasic &f, void *buf, int size, CString &sError ); void ReadBytes( RageFileBasic &f, void *buf, int size, RString &sError );
void SkipBytes( RageFileBasic &f, int size, CString &sError ); void SkipBytes( RageFileBasic &f, int size, RString &sError );
void Seek( RageFileBasic &f, int iOffset, CString &sError ); void Seek( RageFileBasic &f, int iOffset, RString &sError );
CString ReadString( RageFileBasic &f, int size, CString &sError ); RString ReadString( RageFileBasic &f, int size, RString &sError );
uint8_t read_8( RageFileBasic &f, CString &sError ); uint8_t read_8( RageFileBasic &f, RString &sError );
int16_t read_16_le( RageFileBasic &f, CString &sError ); int16_t read_16_le( RageFileBasic &f, RString &sError );
uint16_t read_u16_le( RageFileBasic &f, CString &sError ); uint16_t read_u16_le( RageFileBasic &f, RString &sError );
int32_t read_32_le( RageFileBasic &f, CString &sError ); int32_t read_32_le( RageFileBasic &f, RString &sError );
uint32_t read_u32_le( RageFileBasic &f, CString &sError ); uint32_t read_u32_le( RageFileBasic &f, RString &sError );
}; };
#endif #endif