CString -> RString for files used by smpackage
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include <map>
|
||||
|
||||
/* Map from "&foo;" to a UTF-8 string. */
|
||||
typedef map<CString, wchar_t, StdStringLessNoCase> aliasmap;
|
||||
typedef map<CString, wchar_t, StdString::StdStringLessNoCase> aliasmap;
|
||||
static aliasmap CharAliases;
|
||||
static map<CString,CString> CharAliasRepl;
|
||||
|
||||
|
||||
+15
-15
@@ -10,7 +10,7 @@ IniFile::IniFile()
|
||||
m_sName = "IniFile";
|
||||
}
|
||||
|
||||
bool IniFile::ReadFile( const CString &sPath )
|
||||
bool IniFile::ReadFile( const RString &sPath )
|
||||
{
|
||||
m_sPath = sPath;
|
||||
CHECKPOINT_M( ssprintf("Reading '%s'",m_sPath.c_str()) );
|
||||
@@ -28,10 +28,10 @@ bool IniFile::ReadFile( const CString &sPath )
|
||||
|
||||
bool IniFile::ReadFile( RageFileBasic &f )
|
||||
{
|
||||
CString keyname;
|
||||
RString keyname;
|
||||
while( 1 )
|
||||
{
|
||||
CString line;
|
||||
RString line;
|
||||
switch( f.GetLine(line) )
|
||||
{
|
||||
case -1:
|
||||
@@ -61,8 +61,8 @@ bool IniFile::ReadFile( RageFileBasic &f )
|
||||
int iEqualIndex = line.Find("=");
|
||||
if( iEqualIndex != -1 )
|
||||
{
|
||||
CString valuename = line.Left(iEqualIndex);
|
||||
CString value = line.Right(line.GetLength()-valuename.GetLength()-1);
|
||||
RString valuename = line.Left(iEqualIndex);
|
||||
RString value = line.Right(line.GetLength()-valuename.GetLength()-1);
|
||||
if( keyname.size() && valuename.size() )
|
||||
SetValue(keyname,valuename,value);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ bool IniFile::ReadFile( RageFileBasic &f )
|
||||
}
|
||||
}
|
||||
|
||||
bool IniFile::WriteFile( const CString &sPath ) const
|
||||
bool IniFile::WriteFile( const RString &sPath ) const
|
||||
{
|
||||
RageFile f;
|
||||
if( !f.Open( sPath, RageFile::WRITE ) )
|
||||
@@ -111,7 +111,7 @@ bool IniFile::WriteFile( RageFileBasic &f ) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IniFile::GetValue( const CString &keyname, const CString &valuename, CString& value ) const
|
||||
bool IniFile::GetValue( const RString &keyname, const RString &valuename, RString& value ) const
|
||||
{
|
||||
const XNode* pNode = GetChild( keyname );
|
||||
if( pNode == NULL )
|
||||
@@ -119,7 +119,7 @@ bool IniFile::GetValue( const CString &keyname, const CString &valuename, CStrin
|
||||
return pNode->GetAttrValue( valuename, value );
|
||||
}
|
||||
|
||||
void IniFile::SetValue( const CString &keyname, const CString &valuename, const CString &value )
|
||||
void IniFile::SetValue( const RString &keyname, const RString &valuename, const RString &value )
|
||||
{
|
||||
XNode* pNode = GetChild( keyname );
|
||||
if( pNode == NULL )
|
||||
@@ -127,7 +127,7 @@ void IniFile::SetValue( const CString &keyname, const CString &valuename, const
|
||||
pNode->AppendAttr( valuename, value );
|
||||
}
|
||||
|
||||
bool IniFile::DeleteValue(const CString &keyname, const CString &valuename)
|
||||
bool IniFile::DeleteValue(const RString &keyname, const RString &valuename)
|
||||
{
|
||||
XNode* pNode = GetChild( keyname );
|
||||
if( pNode == NULL )
|
||||
@@ -137,14 +137,14 @@ bool IniFile::DeleteValue(const CString &keyname, const CString &valuename)
|
||||
|
||||
|
||||
#define TYPE(T) \
|
||||
bool IniFile::GetValue( const CString &keyname, const CString &valuename, T &value ) const \
|
||||
bool IniFile::GetValue( const RString &keyname, const RString &valuename, T &value ) const \
|
||||
{ \
|
||||
CString sValue; \
|
||||
RString sValue; \
|
||||
if( !GetValue(keyname,valuename,sValue) ) \
|
||||
return false; \
|
||||
return FromString( sValue, value ); \
|
||||
} \
|
||||
void IniFile::SetValue( const CString &keyname, const CString &valuename, T value ) \
|
||||
void IniFile::SetValue( const RString &keyname, const RString &valuename, T value ) \
|
||||
{ \
|
||||
SetValue( keyname, valuename, ToString(value) ); \
|
||||
}
|
||||
@@ -155,7 +155,7 @@ TYPE(float);
|
||||
TYPE(bool);
|
||||
|
||||
|
||||
bool IniFile::DeleteKey(const CString &keyname)
|
||||
bool IniFile::DeleteKey(const RString &keyname)
|
||||
{
|
||||
XNode* pNode = GetChild( keyname );
|
||||
if( pNode == NULL )
|
||||
@@ -163,14 +163,14 @@ bool IniFile::DeleteKey(const CString &keyname)
|
||||
return RemoveChild( pNode );
|
||||
}
|
||||
|
||||
bool IniFile::RenameKey(const CString &from, const CString &to)
|
||||
bool IniFile::RenameKey(const RString &from, const RString &to)
|
||||
{
|
||||
/* If to already exists, do nothing. */
|
||||
XNode* pTo = GetChild( to );
|
||||
if( pTo )
|
||||
return false;
|
||||
|
||||
multimap<CString, XNode*>::iterator it = m_childs.find( from );
|
||||
multimap<RString, XNode*>::iterator it = m_childs.find( from );
|
||||
if( it == m_childs.end() )
|
||||
return false;
|
||||
|
||||
|
||||
+19
-19
@@ -14,38 +14,38 @@ public:
|
||||
IniFile();
|
||||
|
||||
/* Retrieve the filename of the last file loaded. */
|
||||
CString GetPath() const { return m_sPath; }
|
||||
const CString &GetError() const { return m_sError; }
|
||||
RString GetPath() const { return m_sPath; }
|
||||
const RString &GetError() const { return m_sError; }
|
||||
|
||||
bool ReadFile( const CString &sPath );
|
||||
bool ReadFile( const RString &sPath );
|
||||
bool ReadFile( RageFileBasic &sFile );
|
||||
bool WriteFile( const CString &sPath ) const;
|
||||
bool WriteFile( const RString &sPath ) const;
|
||||
bool WriteFile( RageFileBasic &sFile ) const;
|
||||
|
||||
bool GetValue( const CString &key, const CString &valuename, CString& value ) const;
|
||||
bool GetValue( const CString &key, const CString &valuename, int& value ) const;
|
||||
bool GetValue( const CString &key, const CString &valuename, unsigned& value ) const;
|
||||
bool GetValue( const CString &key, const CString &valuename, float& value ) const;
|
||||
bool GetValue( const CString &key, const CString &valuename, bool& value ) const;
|
||||
bool GetValue( const RString &key, const RString &valuename, RString& value ) const;
|
||||
bool GetValue( const RString &key, const RString &valuename, int& value ) const;
|
||||
bool GetValue( const RString &key, const RString &valuename, unsigned& value ) const;
|
||||
bool GetValue( const RString &key, const RString &valuename, float& value ) const;
|
||||
bool GetValue( const RString &key, const RString &valuename, bool& value ) const;
|
||||
|
||||
void SetValue( const CString &key, const CString &valuename, const CString &value );
|
||||
void SetValue( const CString &key, const CString &valuename, int value );
|
||||
void SetValue( const CString &key, const CString &valuename, unsigned value );
|
||||
void SetValue( const CString &key, const CString &valuename, float value );
|
||||
void SetValue( const CString &key, const CString &valuename, bool value );
|
||||
void SetValue( const RString &key, const RString &valuename, const RString &value );
|
||||
void SetValue( const RString &key, const RString &valuename, int value );
|
||||
void SetValue( const RString &key, const RString &valuename, unsigned value );
|
||||
void SetValue( const RString &key, const RString &valuename, float value );
|
||||
void SetValue( const RString &key, const RString &valuename, bool value );
|
||||
|
||||
bool DeleteKey( const CString &keyname );
|
||||
bool DeleteValue( const CString &keyname, const CString &valuename );
|
||||
bool DeleteKey( const RString &keyname );
|
||||
bool DeleteValue( const RString &keyname, const RString &valuename );
|
||||
|
||||
/* Rename a key. For example, call RenameKey("foo", "main") after
|
||||
* reading an INI where [foo] is an alias to [main]. If to already
|
||||
* exists, nothing happens. */
|
||||
bool RenameKey( const CString &from, const CString &to );
|
||||
bool RenameKey( const RString &from, const RString &to );
|
||||
|
||||
private:
|
||||
CString m_sPath;
|
||||
RString m_sPath;
|
||||
|
||||
mutable CString m_sError;
|
||||
mutable RString m_sError;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,11 +11,10 @@
|
||||
#include "Game.h"
|
||||
#include "Style.h"
|
||||
|
||||
const RString KEYMAPS_PATH = "Save/Keymaps.ini";
|
||||
|
||||
InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program
|
||||
|
||||
#define KEYMAPS_PATH "Save/Keymaps.ini"
|
||||
|
||||
InputMapper::InputMapper()
|
||||
{
|
||||
ReadMappingsFromDisk();
|
||||
|
||||
@@ -9,11 +9,8 @@
|
||||
#include "StyleInput.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
|
||||
|
||||
|
||||
const int NUM_GAME_TO_DEVICE_SLOTS = 5; // five device inputs may map to one game input
|
||||
|
||||
|
||||
class InputMapper
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include "RageLog.h"
|
||||
|
||||
const CString DEFAULTS_INI_PATH = "Data/Defaults.ini"; // these can be overridden
|
||||
const CString PREFERENCES_INI_PATH = "Save/Preferences.ini"; // overlay on Defaults.ini, contains the user's choices
|
||||
//PREFERENCES_INI_PATH // overlay on Defaults.ini, contains the user's choices
|
||||
#include "SpecialFiles.h"
|
||||
const CString STATIC_INI_PATH = "Data/Static.ini"; // overlay on the 2 above, can't be overridden
|
||||
const CString TYPE_TXT_FILE = "Data/Type.txt";
|
||||
|
||||
@@ -463,8 +464,8 @@ void PrefsManager::RestoreGamePrefs()
|
||||
void PrefsManager::ReadPrefsFromDisk()
|
||||
{
|
||||
ReadPrefsFromFile( DEFAULTS_INI_PATH, GetPreferencesSection() );
|
||||
ReadPrefsFromFile( PREFERENCES_INI_PATH, "Options" );
|
||||
ReadGamePrefsFromIni( PREFERENCES_INI_PATH );
|
||||
ReadPrefsFromFile( SpecialFiles::PREFERENCES_INI_PATH, "Options" );
|
||||
ReadGamePrefsFromIni( SpecialFiles::PREFERENCES_INI_PATH );
|
||||
ReadPrefsFromFile( STATIC_INI_PATH, GetPreferencesSection() );
|
||||
|
||||
if( !m_sCurrentGame.Get().empty() )
|
||||
@@ -542,7 +543,7 @@ void PrefsManager::SavePrefsToDisk()
|
||||
{
|
||||
IniFile ini;
|
||||
SavePrefsToIni( ini );
|
||||
ini.WriteFile( PREFERENCES_INI_PATH );
|
||||
ini.WriteFile( SpecialFiles::PREFERENCES_INI_PATH );
|
||||
}
|
||||
|
||||
void PrefsManager::SavePrefsToIni( IniFile &ini )
|
||||
|
||||
@@ -134,7 +134,7 @@ int RageFileObj::Read( void *pBuffer, size_t iBytes )
|
||||
return ret;
|
||||
}
|
||||
|
||||
int RageFileObj::Read( CString &sBuffer, int iBytes )
|
||||
int RageFileObj::Read( RString &sBuffer, int iBytes )
|
||||
{
|
||||
sBuffer.reserve( iBytes != -1? iBytes: this->GetFileSize() );
|
||||
|
||||
@@ -232,7 +232,7 @@ bool RageFileObj::GetCRC32( uint32_t *iRet )
|
||||
|
||||
/* Read up to the next \n, and return it in out. Strip the \n. If the \n is
|
||||
* preceded by a \r (DOS newline), strip that, too. */
|
||||
int RageFileObj::GetLine( CString &out )
|
||||
int RageFileObj::GetLine( RString &out )
|
||||
{
|
||||
out = "";
|
||||
|
||||
@@ -324,11 +324,11 @@ int RageFileObj::GetLine( CString &out )
|
||||
//#define NEWLINE "\n"
|
||||
//#endif
|
||||
|
||||
int RageFileObj::PutLine( const CString &str )
|
||||
int RageFileObj::PutLine( const RString &str )
|
||||
{
|
||||
if( Write(str) == -1 )
|
||||
return -1;
|
||||
return Write( CString(NEWLINE) );
|
||||
return Write( RString(NEWLINE) );
|
||||
}
|
||||
|
||||
/* Fill the internal buffer. This never marks EOF, since this is an internal, hidden
|
||||
|
||||
@@ -11,7 +11,7 @@ class RageFileBasic
|
||||
public:
|
||||
virtual ~RageFileBasic() { }
|
||||
|
||||
virtual CString GetError() const = 0;
|
||||
virtual RString GetError() const = 0;
|
||||
virtual void ClearError() = 0;
|
||||
virtual bool AtEOF() const = 0;
|
||||
|
||||
@@ -27,12 +27,12 @@ public:
|
||||
* does not necessarily mean that the end of the stream has been reached;
|
||||
* keep reading until 0 is returned. */
|
||||
virtual int Read( void *pBuffer, size_t iBytes ) = 0;
|
||||
virtual int Read( CString &buffer, int bytes = -1 ) = 0;
|
||||
virtual int Read( RString &buffer, int bytes = -1 ) = 0;
|
||||
virtual int Read( void *buffer, size_t bytes, int nmemb ) = 0;
|
||||
|
||||
/* Write iSize bytes of data from pBuf. Return 0 on success, -1 on error. */
|
||||
virtual int Write( const void *pBuffer, size_t iBytes ) = 0;
|
||||
virtual int Write( const CString &sString ) = 0;
|
||||
virtual int Write( const RString &sString ) = 0;
|
||||
virtual int Write( const void *buffer, size_t bytes, int nmemb ) = 0;
|
||||
|
||||
/* Due to buffering, writing may not happen by the end of a Write() call, so not
|
||||
@@ -42,12 +42,12 @@ public:
|
||||
virtual int Flush() = 0;
|
||||
|
||||
/* This returns a descriptive path for the file, or "". */
|
||||
virtual CString GetDisplayPath() const { return CString(); }
|
||||
virtual RString GetDisplayPath() const { return RString(); }
|
||||
|
||||
virtual RageFileBasic *Copy() const = 0;
|
||||
|
||||
virtual int GetLine( CString &out ) = 0;
|
||||
virtual int PutLine( const CString &str ) = 0;
|
||||
virtual int GetLine( RString &out ) = 0;
|
||||
virtual int PutLine( const RString &str ) = 0;
|
||||
|
||||
virtual void EnableCRC32( bool on=true ) = 0;
|
||||
virtual bool GetCRC32( uint32_t *iRet ) = 0;
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
RageFileObj( const RageFileObj &cpy );
|
||||
virtual ~RageFileObj();
|
||||
|
||||
virtual CString GetError() const { return m_sError; }
|
||||
virtual RString GetError() const { return m_sError; }
|
||||
virtual void ClearError() { SetError(""); }
|
||||
|
||||
bool AtEOF() const { return m_bEOF; }
|
||||
@@ -72,23 +72,23 @@ public:
|
||||
int Tell() const { return m_iFilePos; }
|
||||
|
||||
int Read( void *pBuffer, size_t iBytes );
|
||||
int Read( CString &buffer, int bytes = -1 );
|
||||
int Read( RString &buffer, int bytes = -1 );
|
||||
int Read( void *buffer, size_t bytes, int nmemb );
|
||||
|
||||
int Write( const void *pBuffer, size_t iBytes );
|
||||
int Write( const CString &sString ) { return Write( sString.data(), sString.size() ); }
|
||||
int Write( const RString &sString ) { return Write( sString.data(), sString.size() ); }
|
||||
int Write( const void *buffer, size_t bytes, int nmemb );
|
||||
|
||||
int Flush();
|
||||
|
||||
int GetLine( CString &out );
|
||||
int PutLine( const CString &str );
|
||||
int GetLine( RString &out );
|
||||
int PutLine( const RString &str );
|
||||
|
||||
void EnableCRC32( bool on=true );
|
||||
bool GetCRC32( uint32_t *iRet );
|
||||
|
||||
virtual int GetFileSize() const = 0;
|
||||
virtual CString GetDisplayPath() const { return CString(); }
|
||||
virtual RString GetDisplayPath() const { return RString(); }
|
||||
virtual RageFileBasic *Copy() const { FAIL_M( "Copying unimplemented" ); }
|
||||
|
||||
protected:
|
||||
@@ -99,8 +99,8 @@ protected:
|
||||
|
||||
void EnableBuffering();
|
||||
|
||||
void SetError( const CString &sError ) { m_sError = sError; }
|
||||
CString m_sError;
|
||||
void SetError( const RString &sError ) { m_sError = sError; }
|
||||
RString m_sError;
|
||||
|
||||
private:
|
||||
int FillBuf();
|
||||
|
||||
@@ -8,12 +8,12 @@ RageFileDriver::~RageFileDriver()
|
||||
delete FDB;
|
||||
}
|
||||
|
||||
int RageFileDriver::GetPathValue( const CString &path )
|
||||
int RageFileDriver::GetPathValue( const RString &path )
|
||||
{
|
||||
vector<CString> parts;
|
||||
vector<RString> parts;
|
||||
split( path, "/", parts, true );
|
||||
|
||||
CString PartialPath;
|
||||
RString PartialPath;
|
||||
|
||||
for( unsigned i = 0; i < parts.size(); ++i )
|
||||
{
|
||||
@@ -42,27 +42,27 @@ int RageFileDriver::GetPathValue( const CString &path )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RageFileDriver::GetDirListing( const CString &sPath, vector<CString> &AddTo, bool bOnlyDirs, bool bReturnPathToo )
|
||||
void RageFileDriver::GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo )
|
||||
{
|
||||
FDB->GetDirListing( sPath, AddTo, bOnlyDirs, bReturnPathToo );
|
||||
}
|
||||
|
||||
RageFileManager::FileType RageFileDriver::GetFileType( const CString &sPath )
|
||||
RageFileManager::FileType RageFileDriver::GetFileType( const RString &sPath )
|
||||
{
|
||||
return FDB->GetFileType( sPath );
|
||||
}
|
||||
|
||||
int RageFileDriver::GetFileSizeInBytes( const CString &sPath )
|
||||
int RageFileDriver::GetFileSizeInBytes( const RString &sPath )
|
||||
{
|
||||
return FDB->GetFileSize( sPath );
|
||||
}
|
||||
|
||||
int RageFileDriver::GetFileHash( const CString &sPath )
|
||||
int RageFileDriver::GetFileHash( const RString &sPath )
|
||||
{
|
||||
return FDB->GetFileHash( sPath );
|
||||
}
|
||||
|
||||
void RageFileDriver::FlushDirCache( const CString &sPath )
|
||||
void RageFileDriver::FlushDirCache( const RString &sPath )
|
||||
{
|
||||
FDB->FlushDirCache();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ void RageFileDriver::FlushDirCache( const CString &sPath )
|
||||
|
||||
const struct FileDriverEntry *g_FileDriverList = NULL;
|
||||
|
||||
FileDriverEntry::FileDriverEntry( CString Type )
|
||||
FileDriverEntry::FileDriverEntry( RString Type )
|
||||
{
|
||||
m_Link = g_FileDriverList;
|
||||
g_FileDriverList = this;
|
||||
@@ -82,7 +82,7 @@ FileDriverEntry::~FileDriverEntry()
|
||||
g_FileDriverList = NULL; /* invalidate */
|
||||
}
|
||||
|
||||
RageFileDriver *MakeFileDriver( CString Type, CString Root )
|
||||
RageFileDriver *MakeFileDriver( RString Type, RString Root )
|
||||
{
|
||||
for( const FileDriverEntry *p = g_FileDriverList; p; p = p->m_Link )
|
||||
if( !p->m_Type.CompareNoCase(Type) )
|
||||
|
||||
@@ -12,18 +12,18 @@ class RageFileDriver
|
||||
public:
|
||||
RageFileDriver( FilenameDB *db ) { FDB = db; }
|
||||
virtual ~RageFileDriver();
|
||||
virtual RageFileBasic *Open( const CString &path, int mode, int &err ) = 0;
|
||||
virtual void GetDirListing( const CString &sPath, vector<CString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
|
||||
virtual RageFileManager::FileType GetFileType( const CString &sPath );
|
||||
virtual int GetFileSizeInBytes( const CString &sFilePath );
|
||||
virtual int GetFileHash( const CString &sPath );
|
||||
virtual int GetPathValue( const CString &path );
|
||||
virtual void FlushDirCache( const CString &sPath );
|
||||
virtual bool Move( const CString &sOldPath, const CString &sNewPath ) { return false; }
|
||||
virtual bool Remove( const CString &sPath ) { return false; }
|
||||
virtual RageFileBasic *Open( const RString &path, int mode, int &err ) = 0;
|
||||
virtual void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
|
||||
virtual RageFileManager::FileType GetFileType( const RString &sPath );
|
||||
virtual int GetFileSizeInBytes( const RString &sFilePath );
|
||||
virtual int GetFileHash( const RString &sPath );
|
||||
virtual int GetPathValue( const RString &path );
|
||||
virtual void FlushDirCache( const RString &sPath );
|
||||
virtual bool Move( const RString &sOldPath, const RString &sNewPath ) { return false; }
|
||||
virtual bool Remove( const RString &sPath ) { return false; }
|
||||
|
||||
/* Optional: Move to a different place, as if reconstructed with a different path. */
|
||||
virtual bool Remount( const CString &sPath ) { return false; }
|
||||
virtual bool Remount( const RString &sPath ) { return false; }
|
||||
|
||||
/* Possible error returns from Open, in addition to standard errno.h values: */
|
||||
enum { ERROR_WRITING_NOT_SUPPORTED = -1 };
|
||||
@@ -34,14 +34,14 @@ public:
|
||||
/* This is used to register the driver, so RageFileManager can see it. */
|
||||
struct FileDriverEntry
|
||||
{
|
||||
FileDriverEntry( CString Type );
|
||||
FileDriverEntry( RString Type );
|
||||
virtual ~FileDriverEntry();
|
||||
virtual RageFileDriver *Create( CString Root ) const = 0;
|
||||
virtual RageFileDriver *Create( RString Root ) const = 0;
|
||||
|
||||
CString m_Type;
|
||||
RString m_Type;
|
||||
const FileDriverEntry *m_Link;
|
||||
};
|
||||
RageFileDriver *MakeFileDriver( CString Type, CString Root );
|
||||
RageFileDriver *MakeFileDriver( RString Type, RString Root );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ struct RageFileObjMemFile
|
||||
RageFileObjMemFile():
|
||||
m_iRefs(0),
|
||||
m_Mutex("RageFileObjMemFile") { }
|
||||
CString m_sBuf;
|
||||
RString m_sBuf;
|
||||
int m_iRefs;
|
||||
RageMutex m_Mutex;
|
||||
|
||||
@@ -98,12 +98,12 @@ RageFileBasic *RageFileObjMem::Copy() const
|
||||
return pRet;
|
||||
}
|
||||
|
||||
const CString &RageFileObjMem::GetString() const
|
||||
const RString &RageFileObjMem::GetString() const
|
||||
{
|
||||
return m_pFile->m_sBuf;
|
||||
}
|
||||
|
||||
void RageFileObjMem::PutString( const CString &sBuf )
|
||||
void RageFileObjMem::PutString( const RString &sBuf )
|
||||
{
|
||||
m_pFile->m_Mutex.Lock();
|
||||
m_pFile->m_sBuf = sBuf;
|
||||
@@ -125,7 +125,7 @@ RageFileDriverMem::~RageFileDriverMem()
|
||||
}
|
||||
}
|
||||
|
||||
RageFileBasic *RageFileDriverMem::Open( const CString &sPath, int mode, int &err )
|
||||
RageFileBasic *RageFileDriverMem::Open( const RString &sPath, int mode, int &err )
|
||||
{
|
||||
LockMut(m_Mutex);
|
||||
|
||||
@@ -155,7 +155,7 @@ RageFileBasic *RageFileDriverMem::Open( const CString &sPath, int mode, int &err
|
||||
return new RageFileObjMem( pFile );
|
||||
}
|
||||
|
||||
bool RageFileDriverMem::Remove( const CString &sPath )
|
||||
bool RageFileDriverMem::Remove( const RString &sPath )
|
||||
{
|
||||
LockMut(m_Mutex);
|
||||
|
||||
@@ -177,7 +177,7 @@ bool RageFileDriverMem::Remove( const CString &sPath )
|
||||
static struct FileDriverEntry_MEM: public FileDriverEntry
|
||||
{
|
||||
FileDriverEntry_MEM(): FileDriverEntry( "MEM" ) { }
|
||||
RageFileDriver *Create( CString Root ) const { return new RageFileDriverMem(); }
|
||||
RageFileDriver *Create( RString Root ) const { return new RageFileDriverMem(); }
|
||||
} const g_RegisterDriver;
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* RageFileDriverMem: Simple memory-based "filesystem". */
|
||||
/* RageFileDriverMemory: Simple memory-based "filesystem". */
|
||||
|
||||
#ifndef RAGE_FILE_DRIVER_MEMORY_H
|
||||
#define RAGE_FILE_DRIVER_MEMORY_H
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
RageFileBasic *Copy() const;
|
||||
|
||||
/* Retrieve the contents of this file. */
|
||||
const CString &GetString() const;
|
||||
void PutString( const CString &sBuf );
|
||||
const RString &GetString() const;
|
||||
void PutString( const RString &sBuf );
|
||||
|
||||
private:
|
||||
RageFileObjMemFile *m_pFile;
|
||||
@@ -36,10 +36,10 @@ public:
|
||||
RageFileDriverMem();
|
||||
~RageFileDriverMem();
|
||||
|
||||
RageFileBasic *Open( const CString &sPath, int mode, int &err );
|
||||
void FlushDirCache( const CString &sPath ) { }
|
||||
RageFileBasic *Open( const RString &sPath, int mode, int &err );
|
||||
void FlushDirCache( const RString &sPath ) { }
|
||||
|
||||
bool Remove( const CString &sPath );
|
||||
bool Remove( const RString &sPath );
|
||||
|
||||
private:
|
||||
RageMutex m_Mutex;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
static struct FileDriverEntry_ZIP: public FileDriverEntry
|
||||
{
|
||||
FileDriverEntry_ZIP(): FileDriverEntry( "ZIP" ) { }
|
||||
RageFileDriver *Create( CString Root ) const { return new RageFileDriverZip( Root ); }
|
||||
RageFileDriver *Create( RString Root ) const { return new RageFileDriverZip( Root ); }
|
||||
} const g_RegisterDriver;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ RageFileDriverZip::RageFileDriverZip():
|
||||
m_pZip = NULL;
|
||||
}
|
||||
|
||||
RageFileDriverZip::RageFileDriverZip( CString sPath ):
|
||||
RageFileDriverZip::RageFileDriverZip( RString sPath ):
|
||||
RageFileDriver( new NullFilenameDB ),
|
||||
m_Mutex( "RageFileDriverZip" )
|
||||
{
|
||||
@@ -46,7 +46,7 @@ RageFileDriverZip::RageFileDriverZip( RageFileBasic *pFile ):
|
||||
Load( pFile );
|
||||
}
|
||||
|
||||
bool RageFileDriverZip::Load( const CString &sPath )
|
||||
bool RageFileDriverZip::Load( const RString &sPath )
|
||||
{
|
||||
ASSERT( m_pZip == NULL ); /* don't load twice */
|
||||
|
||||
@@ -82,8 +82,8 @@ bool RageFileDriverZip::Load( RageFileBasic *pFile )
|
||||
|
||||
bool RageFileDriverZip::ReadEndCentralRecord( int &iTotalEntries, int &iCentralDirectoryOffset )
|
||||
{
|
||||
CString sError;
|
||||
CString sSig = FileReading::ReadString( *m_pZip, 4, sError );
|
||||
RString sError;
|
||||
RString sSig = FileReading::ReadString( *m_pZip, 4, sError );
|
||||
FileReading::read_16_le( *m_pZip, sError ); /* skip number of this disk */
|
||||
FileReading::read_16_le( *m_pZip, sError ); /* skip disk with central directory */
|
||||
FileReading::read_16_le( *m_pZip, sError ); /* skip number of entries on this disk */
|
||||
@@ -176,8 +176,8 @@ bool RageFileDriverZip::ParseZipfile()
|
||||
|
||||
int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
||||
{
|
||||
CString sError;
|
||||
CString sSig = FileReading::ReadString( *m_pZip, 4, sError );
|
||||
RString sError;
|
||||
RString sSig = FileReading::ReadString( *m_pZip, 4, sError );
|
||||
if( sSig != "\x50\x4B\x01\x02" )
|
||||
{
|
||||
LOG->Warn( "%s: central directory record signature not found", m_sPath.c_str() );
|
||||
@@ -256,8 +256,8 @@ bool RageFileDriverZip::ReadLocalFileHeader( FileInfo &info )
|
||||
/* Seek to and read the local file header. */
|
||||
m_pZip->Seek( info.m_iOffset );
|
||||
|
||||
CString sError;
|
||||
CString sSig = FileReading::ReadString( *m_pZip, 4, sError );
|
||||
RString sError;
|
||||
RString sSig = FileReading::ReadString( *m_pZip, 4, sError );
|
||||
|
||||
if( sError != "" )
|
||||
{
|
||||
@@ -295,12 +295,12 @@ RageFileDriverZip::~RageFileDriverZip()
|
||||
delete m_pZip;
|
||||
}
|
||||
|
||||
const RageFileDriverZip::FileInfo *RageFileDriverZip::GetFileInfo( const CString &sPath ) const
|
||||
const RageFileDriverZip::FileInfo *RageFileDriverZip::GetFileInfo( const RString &sPath ) const
|
||||
{
|
||||
return (const FileInfo *) FDB->GetFilePriv( sPath );
|
||||
}
|
||||
|
||||
RageFileBasic *RageFileDriverZip::Open( const CString &sPath, int iMode, int &iErr )
|
||||
RageFileBasic *RageFileDriverZip::Open( const RString &sPath, int iMode, int &iErr )
|
||||
{
|
||||
if( iMode & RageFile::WRITE )
|
||||
{
|
||||
@@ -352,11 +352,16 @@ RageFileBasic *RageFileDriverZip::Open( const CString &sPath, int iMode, int &iE
|
||||
}
|
||||
|
||||
/* NOP for now. This could check to see if the ZIP's mtime has changed, and reload. */
|
||||
void RageFileDriverZip::FlushDirCache( const CString &sPath )
|
||||
void RageFileDriverZip::FlushDirCache( const RString &sPath )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RString RageFileDriverZip::GetGlobalComment() const
|
||||
{
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003-2005 Glenn Maynard. All rights reserved.
|
||||
* All rights reserved.
|
||||
|
||||
@@ -11,15 +11,15 @@ class RageFileDriverZip: public RageFileDriver
|
||||
{
|
||||
public:
|
||||
RageFileDriverZip();
|
||||
RageFileDriverZip( CString sPath );
|
||||
RageFileDriverZip( RString sPath );
|
||||
RageFileDriverZip( RageFileBasic *pFile );
|
||||
bool Load( const CString &sPath );
|
||||
bool Load( const RString &sPath );
|
||||
bool Load( RageFileBasic *pFile );
|
||||
|
||||
virtual ~RageFileDriverZip();
|
||||
|
||||
RageFileBasic *Open( const CString &sPath, int iMode, int &iErr );
|
||||
void FlushDirCache( const CString &sPath );
|
||||
RageFileBasic *Open( const RString &sPath, int iMode, int &iErr );
|
||||
void FlushDirCache( const RString &sPath );
|
||||
|
||||
void DeleteFileWhenFinished() { m_bFileOwned = true; }
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
enum ZipCompressionMethod { STORED = 0, DEFLATED = 8 };
|
||||
struct FileInfo
|
||||
{
|
||||
CString m_sName;
|
||||
RString m_sName;
|
||||
int m_iOffset;
|
||||
int m_iDataOffset;
|
||||
|
||||
@@ -38,7 +38,9 @@ public:
|
||||
/* If 0, unknown. */
|
||||
int m_iFilePermissions;
|
||||
};
|
||||
const FileInfo *GetFileInfo( const CString &sPath ) const;
|
||||
const FileInfo *GetFileInfo( const RString &sPath ) const;
|
||||
|
||||
RString GetGlobalComment() const;
|
||||
|
||||
private:
|
||||
bool m_bFileOwned;
|
||||
@@ -46,7 +48,7 @@ private:
|
||||
RageFileBasic *m_pZip;
|
||||
vector<FileInfo *> m_pFiles;
|
||||
|
||||
CString m_sPath;
|
||||
RString m_sPath;
|
||||
|
||||
/* Open() must be threadsafe. Mutex access to "zip", since we seek
|
||||
* around in it when reading files. */
|
||||
|
||||
@@ -23,8 +23,8 @@ RageFileManager *FILEMAN = NULL;
|
||||
/* Lock this before touching any of these globals (except FILEMAN itself). */
|
||||
static RageEvent *g_Mutex;
|
||||
|
||||
CString RageFileManagerUtil::sInitialWorkingDirectory;
|
||||
CString RageFileManagerUtil::sDirOfExecutable;
|
||||
RString RageFileManagerUtil::sInitialWorkingDirectory;
|
||||
RString RageFileManagerUtil::sDirOfExecutable;
|
||||
|
||||
struct LoadedDriver
|
||||
{
|
||||
@@ -34,12 +34,12 @@ struct LoadedDriver
|
||||
* only send "Foo/Bar". The path "Themes/Foo" is out of the scope
|
||||
* of the driver, and GetPath returns false. */
|
||||
RageFileDriver *m_pDriver;
|
||||
CString m_sType, m_sRoot, m_sMountPoint;
|
||||
RString m_sType, m_sRoot, m_sMountPoint;
|
||||
|
||||
int m_iRefs;
|
||||
|
||||
LoadedDriver() { m_pDriver = NULL; m_iRefs = 0; }
|
||||
CString GetPath( const CString &sPath ) const;
|
||||
RString GetPath( const RString &sPath ) const;
|
||||
};
|
||||
|
||||
static vector<LoadedDriver *> g_pDrivers;
|
||||
@@ -65,7 +65,7 @@ static void UnreferenceAllDrivers( vector<LoadedDriver *> &apDriverList )
|
||||
apDriverList.clear();
|
||||
}
|
||||
|
||||
RageFileDriver *RageFileManager::GetFileDriver( CString sMountpoint )
|
||||
RageFileDriver *RageFileManager::GetFileDriver( RString sMountpoint )
|
||||
{
|
||||
FixSlashesInPlace( sMountpoint );
|
||||
if( sMountpoint.size() && sMountpoint.Right(1) != "/" )
|
||||
@@ -148,13 +148,13 @@ class RageFileDriverMountpoints: public RageFileDriver
|
||||
{
|
||||
public:
|
||||
RageFileDriverMountpoints(): RageFileDriver( new FilenameDB ) { }
|
||||
RageFileBasic *Open( const CString &sPath, int iMode, int &iError )
|
||||
RageFileBasic *Open( const RString &sPath, int iMode, int &iError )
|
||||
{
|
||||
iError = (iMode == RageFile::WRITE)? ERROR_WRITING_NOT_SUPPORTED:ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
/* Never flush FDB, except in LoadFromDrivers. */
|
||||
void FlushDirCache( const CString &sPath ) { }
|
||||
void FlushDirCache( const RString &sPath ) { }
|
||||
|
||||
void LoadFromDrivers( const vector<LoadedDriver *> &apDrivers )
|
||||
{
|
||||
@@ -169,14 +169,14 @@ public:
|
||||
};
|
||||
static RageFileDriverMountpoints *g_Mountpoints = NULL;
|
||||
|
||||
static CString GetDirOfExecutable( CString argv0 )
|
||||
static RString GetDirOfExecutable( RString argv0 )
|
||||
{
|
||||
#ifdef _XBOX
|
||||
return "D:\\";
|
||||
#else
|
||||
/* argv[0] can be wrong in most OS's; try to avoid using it. */
|
||||
|
||||
CString sPath;
|
||||
RString sPath;
|
||||
#if defined(WIN32)
|
||||
char szBuf[MAX_PATH];
|
||||
GetModuleFileName( NULL, szBuf, sizeof(szBuf) );
|
||||
@@ -212,7 +212,7 @@ static CString GetDirOfExecutable( CString argv0 )
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ChangeToDirOfExecutable( CString argv0 )
|
||||
static void ChangeToDirOfExecutable( RString argv0 )
|
||||
{
|
||||
RageFileManagerUtil::sInitialWorkingDirectory = GetCwd();
|
||||
RageFileManagerUtil::sDirOfExecutable = GetDirOfExecutable( argv0 );
|
||||
@@ -226,7 +226,7 @@ static void ChangeToDirOfExecutable( CString argv0 )
|
||||
#endif
|
||||
}
|
||||
|
||||
RageFileManager::RageFileManager( CString argv0 )
|
||||
RageFileManager::RageFileManager( RString argv0 )
|
||||
{
|
||||
CHECKPOINT_M( argv0 );
|
||||
ChangeToDirOfExecutable( argv0 );
|
||||
@@ -267,24 +267,24 @@ RageFileManager::~RageFileManager()
|
||||
}
|
||||
|
||||
/* path must be normalized (FixSlashesInPlace, CollapsePath). */
|
||||
CString LoadedDriver::GetPath( const CString &sPath ) const
|
||||
RString LoadedDriver::GetPath( const RString &sPath ) const
|
||||
{
|
||||
/* If the path begins with /@, only match mountpoints that begin with /@. */
|
||||
if( sPath.size() >= 2 && sPath[1] == '@' )
|
||||
{
|
||||
if( m_sMountPoint.size() < 2 || m_sMountPoint[1] != '@' )
|
||||
return CString();
|
||||
return RString();
|
||||
}
|
||||
|
||||
if( sPath.Left(m_sMountPoint.size()).CompareNoCase(m_sMountPoint) )
|
||||
return CString(); /* no match */
|
||||
return RString(); /* no match */
|
||||
|
||||
/* Add one, so we don't cut off the leading slash. */
|
||||
CString sRet = sPath.Right( sPath.size() - m_sMountPoint.size() + 1 );
|
||||
RString sRet = sPath.Right( sPath.size() - m_sMountPoint.size() + 1 );
|
||||
return sRet;
|
||||
}
|
||||
|
||||
static void NormalizePath( CString &sPath )
|
||||
static void NormalizePath( RString &sPath )
|
||||
{
|
||||
FixSlashesInPlace( sPath );
|
||||
CollapsePath( sPath, true );
|
||||
@@ -292,9 +292,9 @@ static void NormalizePath( CString &sPath )
|
||||
sPath.insert( sPath.begin(), '/' );
|
||||
}
|
||||
|
||||
bool ilt( const CString &a, const CString &b ) { return a.CompareNoCase(b) < 0; }
|
||||
bool ieq( const CString &a, const CString &b ) { return a.CompareNoCase(b) == 0; }
|
||||
void RageFileManager::GetDirListing( CString sPath, vector<CString> &AddTo, bool bOnlyDirs, bool bReturnPathToo )
|
||||
bool ilt( const RString &a, const RString &b ) { return a.CompareNoCase(b) < 0; }
|
||||
bool ieq( const RString &a, const RString &b ) { return a.CompareNoCase(b) == 0; }
|
||||
void RageFileManager::GetDirListing( RString sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo )
|
||||
{
|
||||
NormalizePath( sPath );
|
||||
|
||||
@@ -306,7 +306,7 @@ void RageFileManager::GetDirListing( CString sPath, vector<CString> &AddTo, bool
|
||||
for( unsigned i = 0; i < apDriverList.size(); ++i )
|
||||
{
|
||||
LoadedDriver *pLoadedDriver = apDriverList[i];
|
||||
const CString p = pLoadedDriver->GetPath( sPath );
|
||||
const RString p = pLoadedDriver->GetPath( sPath );
|
||||
if( p.size() == 0 )
|
||||
continue;
|
||||
|
||||
@@ -322,7 +322,7 @@ void RageFileManager::GetDirListing( CString sPath, vector<CString> &AddTo, bool
|
||||
for( unsigned j = OldStart; j < AddTo.size(); ++j )
|
||||
{
|
||||
/* Skip the trailing slash on the mountpoint; there's already a slash there. */
|
||||
CString &sPath = AddTo[j];
|
||||
RString &sPath = AddTo[j];
|
||||
sPath.insert( 0, pLoadedDriver->m_sMountPoint, pLoadedDriver->m_sMountPoint.size()-1 );
|
||||
}
|
||||
}
|
||||
@@ -334,13 +334,13 @@ void RageFileManager::GetDirListing( CString sPath, vector<CString> &AddTo, bool
|
||||
{
|
||||
/* More than one driver returned files. Remove duplicates (case-insensitively). */
|
||||
sort( AddTo.begin()+iOldSize, AddTo.end(), ilt );
|
||||
vector<CString>::iterator it = unique( AddTo.begin()+iOldSize, AddTo.end(), ieq );
|
||||
vector<RString>::iterator it = unique( AddTo.begin()+iOldSize, AddTo.end(), ieq );
|
||||
AddTo.erase( it, AddTo.end() );
|
||||
}
|
||||
}
|
||||
|
||||
/* Files may only be moved within the same file driver. */
|
||||
bool RageFileManager::Move( CString sOldPath, CString sNewPath )
|
||||
bool RageFileManager::Move( RString sOldPath, RString sNewPath )
|
||||
{
|
||||
vector<LoadedDriver *> aDriverList;
|
||||
ReferenceAllDrivers( aDriverList );
|
||||
@@ -352,8 +352,8 @@ bool RageFileManager::Move( CString sOldPath, CString sNewPath )
|
||||
bool Deleted = false;
|
||||
for( unsigned i = 0; i < aDriverList.size(); ++i )
|
||||
{
|
||||
const CString sOldDriverPath = aDriverList[i]->GetPath( sOldPath );
|
||||
const CString sNewDriverPath = aDriverList[i]->GetPath( sNewPath );
|
||||
const RString sOldDriverPath = aDriverList[i]->GetPath( sOldPath );
|
||||
const RString sNewDriverPath = aDriverList[i]->GetPath( sNewPath );
|
||||
if( sOldDriverPath.size() == 0 || sNewDriverPath.size() == 0 )
|
||||
continue;
|
||||
|
||||
@@ -367,7 +367,7 @@ bool RageFileManager::Move( CString sOldPath, CString sNewPath )
|
||||
return Deleted;
|
||||
}
|
||||
|
||||
bool RageFileManager::Remove( CString sPath )
|
||||
bool RageFileManager::Remove( RString sPath )
|
||||
{
|
||||
vector<LoadedDriver *> apDriverList;
|
||||
ReferenceAllDrivers( apDriverList );
|
||||
@@ -378,7 +378,7 @@ bool RageFileManager::Remove( CString sPath )
|
||||
bool bDeleted = false;
|
||||
for( unsigned i = 0; i < apDriverList.size(); ++i )
|
||||
{
|
||||
const CString p = apDriverList[i]->GetPath( sPath );
|
||||
const RString p = apDriverList[i]->GetPath( sPath );
|
||||
if( p.size() == 0 )
|
||||
continue;
|
||||
|
||||
@@ -392,9 +392,9 @@ bool RageFileManager::Remove( CString sPath )
|
||||
return bDeleted;
|
||||
}
|
||||
|
||||
void RageFileManager::CreateDir( CString sDir )
|
||||
void RageFileManager::CreateDir( RString sDir )
|
||||
{
|
||||
CString sTempFile = sDir + "temp";
|
||||
RString sTempFile = sDir + "temp";
|
||||
RageFile f;
|
||||
f.Open( sTempFile, RageFile::WRITE );
|
||||
f.Close();
|
||||
@@ -406,7 +406,7 @@ void RageFileManager::CreateDir( CString sDir )
|
||||
FILEMAN->Remove( sTempFile );
|
||||
}
|
||||
|
||||
static void AdjustMountpoint( CString &sMountPoint )
|
||||
static void AdjustMountpoint( RString &sMountPoint )
|
||||
{
|
||||
FixSlashesInPlace( sMountPoint );
|
||||
|
||||
@@ -428,7 +428,7 @@ static void AddFilesystemDriver( LoadedDriver *pLoadedDriver, bool bAddToEnd )
|
||||
g_Mutex->Unlock();
|
||||
}
|
||||
|
||||
void RageFileManager::Mount( CString sType, CString sRoot, CString sMountPoint, bool bAddToEnd )
|
||||
bool RageFileManager::Mount( RString sType, RString sRoot, RString sMountPoint, bool bAddToEnd )
|
||||
{
|
||||
FixSlashesInPlace( sRoot );
|
||||
AdjustMountpoint( sMountPoint );
|
||||
@@ -450,7 +450,7 @@ void RageFileManager::Mount( CString sType, CString sRoot, CString sMountPoint,
|
||||
LOG->Warn("Can't mount unknown VFS type \"%s\", root \"%s\"", sType.c_str(), sRoot.c_str() );
|
||||
else
|
||||
fprintf( stderr, "Can't mount unknown VFS type \"%s\", root \"%s\"\n", sType.c_str(), sRoot.c_str() );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
@@ -462,10 +462,11 @@ void RageFileManager::Mount( CString sType, CString sRoot, CString sMountPoint,
|
||||
pLoadedDriver->m_sMountPoint = sMountPoint;
|
||||
|
||||
AddFilesystemDriver( pLoadedDriver, bAddToEnd );
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Mount a custom filesystem. */
|
||||
void RageFileManager::Mount( RageFileDriver *pDriver, CString sMountPoint, bool bAddToEnd )
|
||||
void RageFileManager::Mount( RageFileDriver *pDriver, RString sMountPoint, bool bAddToEnd )
|
||||
{
|
||||
AdjustMountpoint( sMountPoint );
|
||||
|
||||
@@ -478,7 +479,7 @@ void RageFileManager::Mount( RageFileDriver *pDriver, CString sMountPoint, bool
|
||||
AddFilesystemDriver( pLoadedDriver, bAddToEnd );
|
||||
}
|
||||
|
||||
void RageFileManager::Unmount( CString sType, CString sRoot, CString sMountPoint )
|
||||
void RageFileManager::Unmount( RString sType, RString sRoot, RString sMountPoint )
|
||||
{
|
||||
FixSlashesInPlace( sRoot );
|
||||
FixSlashesInPlace( sMountPoint );
|
||||
@@ -526,7 +527,7 @@ void RageFileManager::Unmount( CString sType, CString sRoot, CString sMountPoint
|
||||
}
|
||||
}
|
||||
|
||||
void RageFileManager::Remount( CString sMountpoint, CString sPath )
|
||||
void RageFileManager::Remount( RString sMountpoint, RString sPath )
|
||||
{
|
||||
RageFileDriver *pDriver = FILEMAN->GetFileDriver( sMountpoint );
|
||||
if( pDriver == NULL )
|
||||
@@ -544,7 +545,7 @@ void RageFileManager::Remount( CString sMountpoint, CString sPath )
|
||||
FILEMAN->ReleaseFileDriver( pDriver );
|
||||
}
|
||||
|
||||
bool RageFileManager::IsMounted( CString MountPoint )
|
||||
bool RageFileManager::IsMounted( RString MountPoint )
|
||||
{
|
||||
LockMut( *g_Mutex );
|
||||
|
||||
@@ -569,7 +570,7 @@ void RageFileManager::GetLoadedDrivers( vector<DriverLocation> &asMounts )
|
||||
}
|
||||
}
|
||||
|
||||
void RageFileManager::FlushDirCache( CString sPath )
|
||||
void RageFileManager::FlushDirCache( RString sPath )
|
||||
{
|
||||
LockMut( *g_Mutex );
|
||||
|
||||
@@ -584,14 +585,14 @@ void RageFileManager::FlushDirCache( CString sPath )
|
||||
NormalizePath( sPath );
|
||||
for( unsigned i = 0; i < g_pDrivers.size(); ++i )
|
||||
{
|
||||
const CString &path = g_pDrivers[i]->GetPath( sPath );
|
||||
const RString &path = g_pDrivers[i]->GetPath( sPath );
|
||||
if( path.size() == 0 )
|
||||
continue;
|
||||
g_pDrivers[i]->m_pDriver->FlushDirCache( path );
|
||||
}
|
||||
}
|
||||
|
||||
RageFileManager::FileType RageFileManager::GetFileType( CString sPath )
|
||||
RageFileManager::FileType RageFileManager::GetFileType( RString sPath )
|
||||
{
|
||||
NormalizePath( sPath );
|
||||
|
||||
@@ -601,7 +602,7 @@ RageFileManager::FileType RageFileManager::GetFileType( CString sPath )
|
||||
RageFileManager::FileType ret = TYPE_NONE;
|
||||
for( unsigned i = 0; i < apDriverList.size(); ++i )
|
||||
{
|
||||
const CString p = apDriverList[i]->GetPath( sPath );
|
||||
const RString p = apDriverList[i]->GetPath( sPath );
|
||||
if( p.size() == 0 )
|
||||
continue;
|
||||
ret = apDriverList[i]->m_pDriver->GetFileType( p );
|
||||
@@ -615,7 +616,7 @@ RageFileManager::FileType RageFileManager::GetFileType( CString sPath )
|
||||
}
|
||||
|
||||
|
||||
int RageFileManager::GetFileSizeInBytes( CString sPath )
|
||||
int RageFileManager::GetFileSizeInBytes( RString sPath )
|
||||
{
|
||||
NormalizePath( sPath );
|
||||
|
||||
@@ -625,7 +626,7 @@ int RageFileManager::GetFileSizeInBytes( CString sPath )
|
||||
int iRet = -1;
|
||||
for( unsigned i = 0; i < apDriverList.size(); ++i )
|
||||
{
|
||||
const CString p = apDriverList[i]->GetPath( sPath );
|
||||
const RString p = apDriverList[i]->GetPath( sPath );
|
||||
if( p.size() == 0 )
|
||||
continue;
|
||||
iRet = apDriverList[i]->m_pDriver->GetFileSizeInBytes( p );
|
||||
@@ -637,7 +638,7 @@ int RageFileManager::GetFileSizeInBytes( CString sPath )
|
||||
return iRet;
|
||||
}
|
||||
|
||||
int RageFileManager::GetFileHash( CString sPath )
|
||||
int RageFileManager::GetFileHash( RString sPath )
|
||||
{
|
||||
NormalizePath( sPath );
|
||||
|
||||
@@ -647,7 +648,7 @@ int RageFileManager::GetFileHash( CString sPath )
|
||||
int iRet = -1;
|
||||
for( unsigned i = 0; i < apDriverList.size(); ++i )
|
||||
{
|
||||
const CString p = apDriverList[i]->GetPath( sPath );
|
||||
const RString p = apDriverList[i]->GetPath( sPath );
|
||||
if( p.size() == 0 )
|
||||
continue;
|
||||
iRet = apDriverList[i]->m_pDriver->GetFileHash( p );
|
||||
@@ -672,7 +673,7 @@ static bool SortBySecond( const pair<int,int> &a, const pair<int,int> &b )
|
||||
* somewhere and not notice), and easier (don't have to pass flags down to IniFile::Write,
|
||||
* etc).
|
||||
*/
|
||||
static bool PathUsesSlowFlush( const CString &sPath )
|
||||
static bool PathUsesSlowFlush( const RString &sPath )
|
||||
{
|
||||
static const char *FlushPaths[] =
|
||||
{
|
||||
@@ -686,7 +687,7 @@ static bool PathUsesSlowFlush( const CString &sPath )
|
||||
}
|
||||
|
||||
/* Used only by RageFile: */
|
||||
RageFileBasic *RageFileManager::Open( CString sPath, int mode, int &err )
|
||||
RageFileBasic *RageFileManager::Open( RString sPath, int mode, int &err )
|
||||
{
|
||||
err = ENOENT;
|
||||
|
||||
@@ -703,7 +704,7 @@ RageFileBasic *RageFileManager::Open( CString sPath, int mode, int &err )
|
||||
return OpenForReading( sPath, mode, err );
|
||||
}
|
||||
|
||||
RageFileBasic *RageFileManager::OpenForReading( CString sPath, int mode, int &err )
|
||||
RageFileBasic *RageFileManager::OpenForReading( RString sPath, int mode, int &err )
|
||||
{
|
||||
vector<LoadedDriver *> apDriverList;
|
||||
ReferenceAllDrivers( apDriverList );
|
||||
@@ -711,7 +712,7 @@ RageFileBasic *RageFileManager::OpenForReading( CString sPath, int mode, int &er
|
||||
for( unsigned i = 0; i < apDriverList.size(); ++i )
|
||||
{
|
||||
LoadedDriver &ld = *apDriverList[i];
|
||||
const CString path = ld.GetPath( sPath );
|
||||
const RString path = ld.GetPath( sPath );
|
||||
if( path.size() == 0 )
|
||||
continue;
|
||||
int error;
|
||||
@@ -732,7 +733,7 @@ RageFileBasic *RageFileManager::OpenForReading( CString sPath, int mode, int &er
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RageFileBasic *RageFileManager::OpenForWriting( CString sPath, int mode, int &iError )
|
||||
RageFileBasic *RageFileManager::OpenForWriting( RString sPath, int mode, int &iError )
|
||||
{
|
||||
/*
|
||||
* The value for a driver to open a file is the number of directories and/or files
|
||||
@@ -760,7 +761,7 @@ RageFileBasic *RageFileManager::OpenForWriting( CString sPath, int mode, int &iE
|
||||
for( unsigned i = 0; i < apDriverList.size(); ++i )
|
||||
{
|
||||
LoadedDriver &ld = *apDriverList[i];
|
||||
const CString path = ld.GetPath( sPath );
|
||||
const RString path = ld.GetPath( sPath );
|
||||
if( path.size() == 0 )
|
||||
continue;
|
||||
|
||||
@@ -778,7 +779,7 @@ RageFileBasic *RageFileManager::OpenForWriting( CString sPath, int mode, int &iE
|
||||
{
|
||||
const int iDriver = Values[i].first;
|
||||
LoadedDriver &ld = *apDriverList[iDriver];
|
||||
const CString sDriverPath = ld.GetPath( sPath );
|
||||
const RString sDriverPath = ld.GetPath( sPath );
|
||||
ASSERT( !sDriverPath.empty() );
|
||||
|
||||
int iThisError;
|
||||
@@ -803,36 +804,36 @@ RageFileBasic *RageFileManager::OpenForWriting( CString sPath, int mode, int &iE
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool RageFileManager::IsAFile( const CString &sPath ) { return GetFileType(sPath) == TYPE_FILE; }
|
||||
bool RageFileManager::IsADirectory( const CString &sPath ) { return GetFileType(sPath) == TYPE_DIR; }
|
||||
bool RageFileManager::DoesFileExist( const CString &sPath ) { return GetFileType(sPath) != TYPE_NONE; }
|
||||
bool RageFileManager::IsAFile( const RString &sPath ) { return GetFileType(sPath) == TYPE_FILE; }
|
||||
bool RageFileManager::IsADirectory( const RString &sPath ) { return GetFileType(sPath) == TYPE_DIR; }
|
||||
bool RageFileManager::DoesFileExist( const RString &sPath ) { return GetFileType(sPath) != TYPE_NONE; }
|
||||
|
||||
bool DoesFileExist( const CString &sPath )
|
||||
bool DoesFileExist( const RString &sPath )
|
||||
{
|
||||
return FILEMAN->DoesFileExist( sPath );
|
||||
}
|
||||
|
||||
bool IsAFile( const CString &sPath )
|
||||
bool IsAFile( const RString &sPath )
|
||||
{
|
||||
return FILEMAN->IsAFile( sPath );
|
||||
}
|
||||
|
||||
bool IsADirectory( const CString &sPath )
|
||||
bool IsADirectory( const RString &sPath )
|
||||
{
|
||||
return FILEMAN->IsADirectory( sPath );
|
||||
}
|
||||
|
||||
unsigned GetFileSizeInBytes( const CString &sPath )
|
||||
unsigned GetFileSizeInBytes( const RString &sPath )
|
||||
{
|
||||
return FILEMAN->GetFileSizeInBytes( sPath );
|
||||
}
|
||||
|
||||
void GetDirListing( const CString &sPath, vector<CString> &AddTo, bool bOnlyDirs, bool bReturnPathToo )
|
||||
void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo )
|
||||
{
|
||||
FILEMAN->GetDirListing( sPath, AddTo, bOnlyDirs, bReturnPathToo );
|
||||
}
|
||||
|
||||
void GetDirListingRecursive( const CString &sDir, const CString &sMatch, vector<CString> &AddTo )
|
||||
void GetDirListingRecursive( const RString &sDir, const RString &sMatch, vector<RString> &AddTo )
|
||||
{
|
||||
ASSERT( sDir.Right(1) == "/" );
|
||||
GetDirListing( sDir+sMatch, AddTo, false, true );
|
||||
@@ -849,13 +850,13 @@ void GetDirListingRecursive( const CString &sDir, const CString &sMatch, vector<
|
||||
}
|
||||
}
|
||||
|
||||
bool DeleteRecursive( const CString &sDir )
|
||||
bool DeleteRecursive( const RString &sDir )
|
||||
{
|
||||
ASSERT( sDir.Right(1) == "/" );
|
||||
|
||||
vector<CString> vsFiles;
|
||||
vector<RString> vsFiles;
|
||||
GetDirListing( sDir+"*", vsFiles, false, true );
|
||||
FOREACH_CONST( CString, vsFiles, s )
|
||||
FOREACH_CONST( RString, vsFiles, s )
|
||||
{
|
||||
if( IsADirectory(*s) )
|
||||
DeleteRecursive( *s+"/" );
|
||||
@@ -872,22 +873,22 @@ void FlushDirCache()
|
||||
}
|
||||
|
||||
|
||||
unsigned int GetHashForFile( const CString &sPath )
|
||||
unsigned int GetHashForFile( const RString &sPath )
|
||||
{
|
||||
return FILEMAN->GetFileHash( sPath );
|
||||
}
|
||||
|
||||
unsigned int GetHashForDirectory( const CString &sDir )
|
||||
unsigned int GetHashForDirectory( const RString &sDir )
|
||||
{
|
||||
unsigned int hash = 0;
|
||||
|
||||
hash += GetHashForString( sDir );
|
||||
|
||||
vector<CString> arrayFiles;
|
||||
vector<RString> arrayFiles;
|
||||
GetDirListing( sDir+"*", arrayFiles, false );
|
||||
for( unsigned i=0; i<arrayFiles.size(); i++ )
|
||||
{
|
||||
const CString sFilePath = sDir + arrayFiles[i];
|
||||
const RString sFilePath = sDir + arrayFiles[i];
|
||||
hash += GetHashForFile( sFilePath );
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
namespace RageFileManagerUtil
|
||||
{
|
||||
extern CString sInitialWorkingDirectory;
|
||||
extern CString sDirOfExecutable;
|
||||
extern RString sInitialWorkingDirectory;
|
||||
extern RString sDirOfExecutable;
|
||||
}
|
||||
|
||||
class RageFileDriver;
|
||||
@@ -15,52 +15,52 @@ class RageFileBasic;
|
||||
class RageFileManager
|
||||
{
|
||||
public:
|
||||
RageFileManager( CString argv0 );
|
||||
RageFileManager( RString argv0 );
|
||||
~RageFileManager();
|
||||
void MountInitialFilesystems();
|
||||
|
||||
void GetDirListing( CString sPath, vector<CString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
|
||||
bool Move( CString sOldPath, CString sNewPath );
|
||||
bool Remove( CString sPath );
|
||||
void CreateDir( CString sDir );
|
||||
void GetDirListing( RString sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
|
||||
bool Move( RString sOldPath, RString sNewPath );
|
||||
bool Remove( RString sPath );
|
||||
void CreateDir( RString sDir );
|
||||
|
||||
enum FileType { TYPE_FILE, TYPE_DIR, TYPE_NONE };
|
||||
FileType GetFileType( CString sPath );
|
||||
FileType GetFileType( RString sPath );
|
||||
|
||||
bool IsAFile( const CString &sPath );
|
||||
bool IsADirectory( const CString &sPath );
|
||||
bool DoesFileExist( const CString &sPath );
|
||||
bool IsAFile( const RString &sPath );
|
||||
bool IsADirectory( const RString &sPath );
|
||||
bool DoesFileExist( const RString &sPath );
|
||||
|
||||
int GetFileSizeInBytes( CString sPath );
|
||||
int GetFileHash( CString sPath );
|
||||
int GetFileSizeInBytes( RString sPath );
|
||||
int GetFileHash( RString sPath );
|
||||
|
||||
void Mount( CString sType, CString sRealPath, CString sMountPoint, bool bAddToEnd = true );
|
||||
void Mount( RageFileDriver *pDriver, CString sMountPoint, bool bAddToEnd = true );
|
||||
void Unmount( CString sType, CString sRoot, CString sMountPoint );
|
||||
bool Mount( RString sType, RString sRealPath, RString sMountPoint, bool bAddToEnd = true );
|
||||
void Mount( RageFileDriver *pDriver, RString sMountPoint, bool bAddToEnd = true );
|
||||
void Unmount( RString sType, RString sRoot, RString sMountPoint );
|
||||
|
||||
/* Change the root of a filesystem. Only a couple drivers support this; it's
|
||||
* used to change memory card mountpoints without having to actually unmount
|
||||
* the driver. */
|
||||
static void Remount( CString sMountpoint, CString sPath );
|
||||
bool IsMounted( CString MountPoint );
|
||||
static void Remount( RString sMountpoint, RString sPath );
|
||||
bool IsMounted( RString MountPoint );
|
||||
struct DriverLocation
|
||||
{
|
||||
CString Type, Root, MountPoint;
|
||||
RString Type, Root, MountPoint;
|
||||
};
|
||||
void GetLoadedDrivers( vector<DriverLocation> &asMounts );
|
||||
|
||||
void FlushDirCache( CString sPath );
|
||||
void FlushDirCache( RString sPath );
|
||||
|
||||
/* Used only by RageFile: */
|
||||
RageFileBasic *Open( CString sPath, int iMode, int &iError );
|
||||
RageFileBasic *Open( RString sPath, int iMode, int &iError );
|
||||
|
||||
/* Retrieve or release a reference to the low-level driver for a mountpoint. */
|
||||
RageFileDriver *GetFileDriver( CString sMountpoint );
|
||||
RageFileDriver *GetFileDriver( RString sMountpoint );
|
||||
void ReleaseFileDriver( RageFileDriver *pDriver );
|
||||
|
||||
private:
|
||||
RageFileBasic *OpenForReading( CString sPath, int iMode, int &iError );
|
||||
RageFileBasic *OpenForWriting( CString sPath, int iMode, int &iError );
|
||||
RageFileBasic *OpenForReading( RString sPath, int iMode, int &iError );
|
||||
RageFileBasic *OpenForWriting( RString sPath, int iMode, int &iError );
|
||||
};
|
||||
|
||||
extern RageFileManager *FILEMAN;
|
||||
|
||||
@@ -148,10 +148,6 @@ CString SecondsToMSSMsMs( float fSecs )
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
#include "LuaFunctions.h"
|
||||
#include "LuaManager.h"
|
||||
LuaFunction( SecondsToMSSMsMs, SecondsToMSSMsMs( FArg(1) ) )
|
||||
|
||||
CString SecondsToMMSSMsMsMs( float fSecs )
|
||||
{
|
||||
const int iMinsDisplay = (int)fSecs/60;
|
||||
@@ -180,8 +176,6 @@ CString Commify( int iNum )
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
LuaFunction( FormatNumberAndSuffix, FormatNumberAndSuffix( IArg(1) ) )
|
||||
|
||||
CString FormatNumberAndSuffix( int i )
|
||||
{
|
||||
CString sSuffix;
|
||||
@@ -1596,8 +1590,6 @@ CString Basename( const CString &dir )
|
||||
return dir.substr( start, end-start+1 );
|
||||
}
|
||||
|
||||
LuaFunction( Basename, Basename( SArg(1) ) )
|
||||
|
||||
/* Return all but the last named component of dir:
|
||||
* a/b/c -> a/b/
|
||||
* a/b/c/ -> a/b/
|
||||
|
||||
+92
-92
@@ -227,29 +227,29 @@ void fapproach( float& val, float other_val, float to_move );
|
||||
float fmodfp( float x, float y );
|
||||
|
||||
int power_of_two( int input );
|
||||
bool IsAnInt( const CString &s );
|
||||
bool IsHexVal( const CString &s );
|
||||
float HHMMSSToSeconds( const CString &sHMS );
|
||||
CString SecondsToHHMMSS( float fSecs );
|
||||
CString SecondsToMSSMsMs( float fSecs );
|
||||
CString SecondsToMMSSMsMs( float fSecs );
|
||||
CString SecondsToMMSSMsMsMs( float fSecs );
|
||||
CString PrettyPercent( float fNumerator, float fDenominator );
|
||||
inline CString PrettyPercent( int fNumerator, int fDenominator ) { return PrettyPercent( float(fNumerator), float(fDenominator) ); }
|
||||
CString Commify( int iNum );
|
||||
CString FormatNumberAndSuffix( int i );
|
||||
bool IsAnInt( const RString &s );
|
||||
bool IsHexVal( const RString &s );
|
||||
float HHMMSSToSeconds( const RString &sHMS );
|
||||
RString SecondsToHHMMSS( float fSecs );
|
||||
RString SecondsToMSSMsMs( float fSecs );
|
||||
RString SecondsToMMSSMsMs( float fSecs );
|
||||
RString SecondsToMMSSMsMsMs( float fSecs );
|
||||
RString PrettyPercent( float fNumerator, float fDenominator );
|
||||
inline RString PrettyPercent( int fNumerator, int fDenominator ) { return PrettyPercent( float(fNumerator), float(fDenominator) ); }
|
||||
RString Commify( int iNum );
|
||||
RString FormatNumberAndSuffix( int i );
|
||||
|
||||
|
||||
struct tm GetLocalTime();
|
||||
|
||||
CString ssprintf( const char *fmt, ...) PRINTF(1,2);
|
||||
CString vssprintf( const char *fmt, va_list argList );
|
||||
RString ssprintf( const char *fmt, ...) PRINTF(1,2);
|
||||
RString vssprintf( const char *fmt, va_list argList );
|
||||
|
||||
#ifdef WIN32
|
||||
CString hr_ssprintf( int hr, const char *fmt, ...);
|
||||
CString werr_ssprintf( int err, const char *fmt, ...);
|
||||
CString ConvertWstringToACP( wstring s );
|
||||
CString ConvertUTF8ToACP( CString s );
|
||||
RString hr_ssprintf( int hr, const char *fmt, ...);
|
||||
RString werr_ssprintf( int err, const char *fmt, ...);
|
||||
RString ConvertWstringToACP( wstring s );
|
||||
RString ConvertUTF8ToACP( RString s );
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -257,61 +257,61 @@ CString ConvertUTF8ToACP( CString s );
|
||||
* If Path is a directory (eg. c:\games\stepmania"), append a slash so the last
|
||||
* element will end up in Dir, not FName: "c:\games\stepmania\".
|
||||
* */
|
||||
void splitpath( const CString &Path, CString &Dir, CString &Filename, CString &Ext );
|
||||
void splitpath( const RString &Path, RString &Dir, RString &Filename, RString &Ext );
|
||||
|
||||
CString SetExtension( const CString &path, const CString &ext );
|
||||
CString GetExtension( const CString &sPath );
|
||||
CString GetFileNameWithoutExtension( const CString &sPath );
|
||||
RString SetExtension( const RString &path, const RString &ext );
|
||||
RString GetExtension( const RString &sPath );
|
||||
RString GetFileNameWithoutExtension( const RString &sPath );
|
||||
|
||||
typedef int longchar;
|
||||
extern const wchar_t INVALID_CHAR;
|
||||
|
||||
int utf8_get_char_len( char p );
|
||||
bool utf8_to_wchar( const CString &s, unsigned &start, wchar_t &ch );
|
||||
bool utf8_to_wchar_ec( const CString &s, unsigned &start, wchar_t &ch );
|
||||
void wchar_to_utf8( wchar_t ch, CString &out );
|
||||
wchar_t utf8_get_char( const CString &s );
|
||||
bool utf8_is_valid( const CString &s );
|
||||
void utf8_remove_bom( CString &s );
|
||||
bool utf8_to_wchar( const RString &s, unsigned &start, wchar_t &ch );
|
||||
bool utf8_to_wchar_ec( const RString &s, unsigned &start, wchar_t &ch );
|
||||
void wchar_to_utf8( wchar_t ch, RString &out );
|
||||
wchar_t utf8_get_char( const RString &s );
|
||||
bool utf8_is_valid( const RString &s );
|
||||
void utf8_remove_bom( RString &s );
|
||||
|
||||
CString WStringToCString( const wstring &sString );
|
||||
CString WcharToUTF8( wchar_t c );
|
||||
wstring CStringToWstring( const CString &sString );
|
||||
RString WStringToCString( const wstring &sString );
|
||||
RString WcharToUTF8( wchar_t c );
|
||||
wstring CStringToWstring( const RString &sString );
|
||||
|
||||
CString GetLanguageNameFromISO639Code( CString sName );
|
||||
RString GetLanguageNameFromISO639Code( RString sName );
|
||||
|
||||
// Splits a CString into an vector<CString> according the Delimitor.
|
||||
void split( const CString &sSource, const CString &sDelimitor, vector<CString>& asAddIt, const bool bIgnoreEmpty = true );
|
||||
// Splits a RString into an vector<RString> according the Delimitor.
|
||||
void split( const RString &sSource, const RString &sDelimitor, vector<RString>& asAddIt, const bool bIgnoreEmpty = true );
|
||||
void split( const wstring &sSource, const wstring &sDelimitor, vector<wstring> &asAddIt, const bool bIgnoreEmpty = true );
|
||||
|
||||
/* In-place split. */
|
||||
void split( const CString &sSource, const CString &sDelimitor, int &iBegin, int &iSize, const bool bIgnoreEmpty = true );
|
||||
void split( const RString &sSource, const RString &sDelimitor, int &iBegin, int &iSize, const bool bIgnoreEmpty = true );
|
||||
void split( const wstring &sSource, const wstring &sDelimitor, int &iBegin, int &iSize, const bool bIgnoreEmpty = true );
|
||||
|
||||
/* In-place split of partial string. */
|
||||
void split( const CString &sSource, const CString &sDelimitor, int &iBegin, int &iSize, int iLen, const bool bIgnoreEmpty ); /* no default to avoid ambiguity */
|
||||
void split( const RString &sSource, const RString &sDelimitor, int &iBegin, int &iSize, int iLen, const bool bIgnoreEmpty ); /* no default to avoid ambiguity */
|
||||
void split( const wstring &sSource, const wstring &sDelimitor, int &iBegin, int &iSize, int iLen, const bool bIgnoreEmpty );
|
||||
|
||||
// Joins a vector<CString> to create a CString according the Deliminator.
|
||||
CString join( const CString &sDelimitor, const vector<CString>& sSource );
|
||||
CString join( const CString &sDelimitor, vector<CString>::const_iterator begin, vector<CString>::const_iterator end );
|
||||
// Joins a vector<RString> to create a RString according the Deliminator.
|
||||
RString join( const RString &sDelimitor, const vector<RString>& sSource );
|
||||
RString join( const RString &sDelimitor, vector<RString>::const_iterator begin, vector<RString>::const_iterator end );
|
||||
|
||||
CString GetCwd();
|
||||
RString GetCwd();
|
||||
|
||||
void SetCommandlineArguments( int argc, char **argv );
|
||||
bool GetCommandlineArgument( const CString &option, CString *argument=NULL, int iIndex=0 );
|
||||
bool GetCommandlineArgument( const RString &option, RString *argument=NULL, int iIndex=0 );
|
||||
extern int g_argc;
|
||||
extern char **g_argv;
|
||||
|
||||
void CRC32( unsigned int &iCRC, const void *pBuffer, size_t iSize );
|
||||
unsigned int GetHashForString( const CString &s );
|
||||
unsigned int GetHashForFile( const CString &sPath );
|
||||
unsigned int GetHashForDirectory( const CString &sDir ); // a hash value that remains the same as long as nothing in the directory has changed
|
||||
bool DirectoryIsEmpty( const CString &sPath );
|
||||
unsigned int GetHashForString( const RString &s );
|
||||
unsigned int GetHashForFile( const RString &sPath );
|
||||
unsigned int GetHashForDirectory( const RString &sDir ); // a hash value that remains the same as long as nothing in the directory has changed
|
||||
bool DirectoryIsEmpty( const RString &sPath );
|
||||
|
||||
bool CompareCStringsAsc( const CString &sStr1, const CString &sStr2 );
|
||||
bool CompareCStringsDesc( const CString &sStr1, const CString &sStr2 );
|
||||
void SortCStringArray( vector<CString> &asAddTo, const bool bSortAscending = true );
|
||||
bool CompareCStringsAsc( const RString &sStr1, const RString &sStr2 );
|
||||
bool CompareCStringsDesc( const RString &sStr1, const RString &sStr2 );
|
||||
void SortCStringArray( vector<RString> &asAddTo, const bool bSortAscending = true );
|
||||
|
||||
/* Find the mean and standard deviation of all numbers in [start,end). */
|
||||
float calc_mean( const float *pStart, const float *pEnd );
|
||||
@@ -332,47 +332,47 @@ inline T Increment( T a ) { ++a; return a; }
|
||||
template<class T>
|
||||
inline T Decrement( T a ) { --a; return a; }
|
||||
|
||||
void TrimLeft( CString &sStr, const char *szTrim = "\r\n\t " );
|
||||
void TrimRight( CString &sStr, const char *szTrim = "\r\n\t " );
|
||||
void StripCrnl( CString &sStr );
|
||||
bool BeginsWith( const CString &sTestThis, const CString &sBeginning );
|
||||
bool EndsWith( const CString &sTestThis, const CString &sEnding );
|
||||
void TrimLeft( RString &sStr, const char *szTrim = "\r\n\t " );
|
||||
void TrimRight( RString &sStr, const char *szTrim = "\r\n\t " );
|
||||
void StripCrnl( RString &sStr );
|
||||
bool BeginsWith( const RString &sTestThis, const RString &sBeginning );
|
||||
bool EndsWith( const RString &sTestThis, const RString &sEnding );
|
||||
|
||||
void StripCvs( vector<CString> &vs ); // remove all items that end in "cvs"
|
||||
void StripCvs( vector<RString> &vs ); // remove all items that end in "cvs"
|
||||
|
||||
CString DerefRedir( const CString &sPath );
|
||||
bool GetFileContents( const CString &sPath, CString &sOut, bool bOneLine = false );
|
||||
RString DerefRedir( const RString &sPath );
|
||||
bool GetFileContents( const RString &sPath, RString &sOut, bool bOneLine = false );
|
||||
|
||||
class Regex
|
||||
{
|
||||
public:
|
||||
Regex( const CString &sPat = "" );
|
||||
Regex( const RString &sPat = "" );
|
||||
Regex( const Regex &rhs );
|
||||
Regex &operator=( const Regex &rhs );
|
||||
~Regex();
|
||||
bool IsSet() const { return !pattern.empty(); }
|
||||
void Set( const CString &str );
|
||||
bool Compare( const CString &sStr );
|
||||
bool Compare( const CString &sStr, vector<CString> &asMatches );
|
||||
bool Replace( const CString &sReplacement, const CString &sSubject, CString &sOut );
|
||||
void Set( const RString &str );
|
||||
bool Compare( const RString &sStr );
|
||||
bool Compare( const RString &sStr, vector<RString> &asMatches );
|
||||
bool Replace( const RString &sReplacement, const RString &sSubject, RString &sOut );
|
||||
|
||||
private:
|
||||
void *reg;
|
||||
unsigned backrefs;
|
||||
CString pattern;
|
||||
RString pattern;
|
||||
void Compile();
|
||||
void Release();
|
||||
};
|
||||
|
||||
|
||||
void ReplaceEntityText( CString &sText, const map<CString,CString> &m );
|
||||
void ReplaceEntityText( CString &sText, const map<char,CString> &m );
|
||||
void Replace_Unicode_Markers( CString &Text );
|
||||
CString WcharDisplayText( wchar_t c );
|
||||
void ReplaceEntityText( RString &sText, const map<RString,RString> &m );
|
||||
void ReplaceEntityText( RString &sText, const map<char,RString> &m );
|
||||
void Replace_Unicode_Markers( RString &Text );
|
||||
RString WcharDisplayText( wchar_t c );
|
||||
|
||||
CString Basename( const CString &dir );
|
||||
CString Dirname( const CString &dir );
|
||||
CString Capitalize( const CString &s );
|
||||
RString Basename( const RString &dir );
|
||||
RString Dirname( const RString &dir );
|
||||
RString Capitalize( const RString &s );
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h> /* correct place with correct definitions */
|
||||
@@ -424,45 +424,45 @@ typedef basic_string<char,char_traits_char_nocase> istring;
|
||||
|
||||
/* Compatibility/convenience shortcuts. These are actually defined in RageFileManager.h, but
|
||||
* declared here since they're used in many places. */
|
||||
void GetDirListing( const CString &sPath, vector<CString> &AddTo, bool bOnlyDirs=false, bool bReturnPathToo=false );
|
||||
void GetDirListingRecursive( const CString &sDir, const CString &sMatch, vector<CString> &AddTo ); /* returns path too */
|
||||
bool DeleteRecursive( const CString &sDir ); /* delete the dir and all files/subdirs inside it */
|
||||
bool DoesFileExist( const CString &sPath );
|
||||
bool IsAFile( const CString &sPath );
|
||||
bool IsADirectory( const CString &sPath );
|
||||
unsigned GetFileSizeInBytes( const CString &sFilePath );
|
||||
void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs=false, bool bReturnPathToo=false );
|
||||
void GetDirListingRecursive( const RString &sDir, const RString &sMatch, vector<RString> &AddTo ); /* returns path too */
|
||||
bool DeleteRecursive( const RString &sDir ); /* delete the dir and all files/subdirs inside it */
|
||||
bool DoesFileExist( const RString &sPath );
|
||||
bool IsAFile( const RString &sPath );
|
||||
bool IsADirectory( const RString &sPath );
|
||||
unsigned GetFileSizeInBytes( const RString &sFilePath );
|
||||
void FlushDirCache();
|
||||
|
||||
// call FixSlashes on any path that came from the user
|
||||
void FixSlashesInPlace( CString &sPath );
|
||||
CString FixSlashes( CString sPath );
|
||||
void CollapsePath( CString &sPath, bool bRemoveLeadingDot=false );
|
||||
void FixSlashesInPlace( RString &sPath );
|
||||
RString FixSlashes( RString sPath );
|
||||
void CollapsePath( RString &sPath, bool bRemoveLeadingDot=false );
|
||||
|
||||
bool FromString( const CString &sValue, int &out );
|
||||
bool FromString( const CString &sValue, unsigned &out );
|
||||
bool FromString( const CString &sValue, float &out );
|
||||
bool FromString( const CString &sValue, bool &out );
|
||||
inline bool FromString( const CString &sValue, CString &out ) { out = sValue; return true; }
|
||||
bool FromString( const RString &sValue, int &out );
|
||||
bool FromString( const RString &sValue, unsigned &out );
|
||||
bool FromString( const RString &sValue, float &out );
|
||||
bool FromString( const RString &sValue, bool &out );
|
||||
inline bool FromString( const RString &sValue, RString &out ) { out = sValue; return true; }
|
||||
|
||||
CString ToString( int value );
|
||||
CString ToString( unsigned value );
|
||||
CString ToString( float value );
|
||||
CString ToString( bool value );
|
||||
inline CString ToString( const CString &value ) { return value; }
|
||||
RString ToString( int value );
|
||||
RString ToString( unsigned value );
|
||||
RString ToString( float value );
|
||||
RString ToString( bool value );
|
||||
inline RString ToString( const RString &value ) { return value; }
|
||||
|
||||
// helper file functions used by Bookkeeper and ProfileManager
|
||||
class RageFileBasic;
|
||||
bool FileRead( RageFileBasic& f, CString& sOut );
|
||||
bool FileRead( RageFileBasic& f, RString& sOut );
|
||||
bool FileRead( RageFileBasic& f, int& iOut );
|
||||
bool FileRead( RageFileBasic& f, unsigned& uOut );
|
||||
bool FileRead( RageFileBasic& f, float& fOut );
|
||||
void FileWrite( RageFileBasic& f, const CString& sWrite );
|
||||
void FileWrite( RageFileBasic& f, const RString& sWrite );
|
||||
void FileWrite( RageFileBasic& f, int iWrite );
|
||||
void FileWrite( RageFileBasic& f, size_t uWrite );
|
||||
void FileWrite( RageFileBasic& f, float fWrite );
|
||||
|
||||
bool FileCopy( CString sSrcFile, CString sDstFile );
|
||||
bool FileCopy( RageFileBasic &in, RageFileBasic &out, CString &sError, bool *bReadError = NULL );
|
||||
bool FileCopy( RString sSrcFile, RString sDstFile );
|
||||
bool FileCopy( RageFileBasic &in, RageFileBasic &out, RString &sError, bool *bReadError = NULL );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -101,7 +101,9 @@ void NORETURN sm_crash( const char *reason = "Internal error" );
|
||||
* we do expect, such as DSound init failure.) */
|
||||
#define FAIL_M(MESSAGE) { CHECKPOINT_M(MESSAGE); sm_crash(MESSAGE); }
|
||||
#define ASSERT_M(COND, MESSAGE) { if(unlikely(!(COND))) { FAIL_M(MESSAGE); } }
|
||||
#if !defined(CO_EXIST_WITH_MFC)
|
||||
#define ASSERT(COND) ASSERT_M((COND), "Assertion '" #COND "' failed")
|
||||
#endif
|
||||
|
||||
void ShowWarning( const char *file, int line, const char *message ); // don't pull in LOG here
|
||||
#define WARN(MESSAGE) (ShowWarning(__FILE__, __LINE__, MESSAGE))
|
||||
@@ -134,9 +136,10 @@ void ShowWarning( const char *file, int line, const char *message ); // don't pu
|
||||
|
||||
/* Use CStdString: */
|
||||
#include "StdString.h"
|
||||
using namespace StdString;
|
||||
//#define CString CStdString
|
||||
typedef StdString::CStdString RString;
|
||||
#if !defined(CO_EXIST_WITH_MFC)
|
||||
typedef StdString::CStdString CString;
|
||||
#endif
|
||||
|
||||
/* Include this here to make sure our assertion handler is always
|
||||
* used. (This file is a dependency of most everything anyway,
|
||||
|
||||
Reference in New Issue
Block a user