Integrate C++11 branch into 5_1-new
This commit is contained in:
+24
-25
@@ -6,7 +6,6 @@
|
||||
#include "RageUtil_FileDB.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageThreads.h"
|
||||
#include "Foreach.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
#include "LuaManager.h"
|
||||
|
||||
@@ -18,7 +17,7 @@
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
RageFileManager *FILEMAN = NULL;
|
||||
RageFileManager *FILEMAN = nullptr;
|
||||
|
||||
/* Lock this before touching any of these globals (except FILEMAN itself). */
|
||||
static RageEvent *g_Mutex;
|
||||
@@ -38,7 +37,7 @@ struct LoadedDriver
|
||||
|
||||
int m_iRefs;
|
||||
|
||||
LoadedDriver() { m_pDriver = NULL; m_iRefs = 0; }
|
||||
LoadedDriver() { m_pDriver = nullptr; m_iRefs = 0; }
|
||||
RString GetPath( const RString &sPath ) const;
|
||||
};
|
||||
|
||||
@@ -73,7 +72,7 @@ RageFileDriver *RageFileManager::GetFileDriver( RString sMountpoint )
|
||||
sMountpoint += '/';
|
||||
|
||||
g_Mutex->Lock();
|
||||
RageFileDriver *pRet = NULL;
|
||||
RageFileDriver *pRet = nullptr;
|
||||
for( unsigned i = 0; i < g_pDrivers.size(); ++i )
|
||||
{
|
||||
if( g_pDrivers[i]->m_sType == "mountpoints" )
|
||||
@@ -92,7 +91,7 @@ RageFileDriver *RageFileManager::GetFileDriver( RString sMountpoint )
|
||||
|
||||
void RageFileManager::ReleaseFileDriver( RageFileDriver *pDriver )
|
||||
{
|
||||
ASSERT( pDriver != NULL );
|
||||
ASSERT( pDriver != nullptr );
|
||||
|
||||
g_Mutex->Lock();
|
||||
unsigned i;
|
||||
@@ -157,7 +156,7 @@ public:
|
||||
RageFileBasic *Open( const RString &sPath, int iMode, int &iError )
|
||||
{
|
||||
iError = (iMode == RageFile::WRITE)? ERROR_WRITING_NOT_SUPPORTED:ENOENT;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
/* Never flush FDB, except in LoadFromDrivers. */
|
||||
void FlushDirCache( const RString &sPath ) { }
|
||||
@@ -173,7 +172,7 @@ public:
|
||||
FDB->AddFile( apDrivers[i]->m_sMountPoint, 0, 0 );
|
||||
}
|
||||
};
|
||||
static RageFileDriverMountpoints *g_Mountpoints = NULL;
|
||||
static RageFileDriverMountpoints *g_Mountpoints = nullptr;
|
||||
|
||||
static RString ExtractDirectory( RString sPath )
|
||||
{
|
||||
@@ -218,7 +217,7 @@ static RString GetDirOfExecutable( RString argv0 )
|
||||
RString sPath;
|
||||
#if defined(WIN32)
|
||||
char szBuf[MAX_PATH];
|
||||
GetModuleFileName( NULL, szBuf, sizeof(szBuf) );
|
||||
GetModuleFileName( nullptr, szBuf, sizeof(szBuf) );
|
||||
sPath = szBuf;
|
||||
#else
|
||||
sPath = argv0;
|
||||
@@ -250,11 +249,11 @@ static RString GetDirOfExecutable( RString argv0 )
|
||||
|
||||
vector<RString> vPath;
|
||||
split( path, ":", vPath );
|
||||
FOREACH( RString, vPath, i )
|
||||
for (RString &i : vPath)
|
||||
{
|
||||
if( access(*i + "/" + argv0, X_OK|R_OK) )
|
||||
if( access(i + "/" + argv0, X_OK|R_OK) )
|
||||
continue;
|
||||
sPath = ExtractDirectory(ReadlinkRecursive(*i + "/" + argv0));
|
||||
sPath = ExtractDirectory(ReadlinkRecursive(i + "/" + argv0));
|
||||
break;
|
||||
}
|
||||
if( sPath.empty() )
|
||||
@@ -351,10 +350,10 @@ RageFileManager::~RageFileManager()
|
||||
g_pDrivers.clear();
|
||||
|
||||
// delete g_Mountpoints; // g_Mountpoints was in g_pDrivers
|
||||
g_Mountpoints = NULL;
|
||||
g_Mountpoints = nullptr;
|
||||
|
||||
delete g_Mutex;
|
||||
g_Mutex = NULL;
|
||||
g_Mutex = nullptr;
|
||||
}
|
||||
|
||||
/* path must be normalized (FixSlashesInPlace, CollapsePath). */
|
||||
@@ -575,7 +574,7 @@ bool RageFileManager::Mount( const RString &sType, const RString &sRoot_, const
|
||||
|
||||
CHECKPOINT_M( ssprintf("About to make a driver with \"%s\", \"%s\"", sType.c_str(), sRoot.c_str()));
|
||||
RageFileDriver *pDriver = MakeFileDriver( sType, sRoot );
|
||||
if( pDriver == NULL )
|
||||
if( pDriver == nullptr )
|
||||
{
|
||||
CHECKPOINT_M( ssprintf("Can't mount unknown VFS type \"%s\", root \"%s\"", sType.c_str(), sRoot.c_str() ) );
|
||||
|
||||
@@ -668,7 +667,7 @@ void RageFileManager::Unmount( const RString &sType, const RString &sRoot_, cons
|
||||
void RageFileManager::Remount( RString sMountpoint, RString sPath )
|
||||
{
|
||||
RageFileDriver *pDriver = GetFileDriver( sMountpoint );
|
||||
if( pDriver == NULL )
|
||||
if( pDriver == nullptr )
|
||||
{
|
||||
if( LOG )
|
||||
LOG->Warn( "Remount(%s,%s): mountpoint not found", sMountpoint.c_str(), sPath.c_str() );
|
||||
@@ -928,7 +927,7 @@ RageFileBasic *RageFileManager::OpenForReading( const RString &sPath, int mode,
|
||||
}
|
||||
UnreferenceAllDrivers( apDriverList );
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RageFileBasic *RageFileManager::OpenForWriting( const RString &sPath, int mode, int &iError )
|
||||
@@ -1009,7 +1008,7 @@ RageFileBasic *RageFileManager::OpenForWriting( const RString &sPath, int mode,
|
||||
|
||||
UnreferenceAllDrivers( apDriverList );
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool RageFileManager::IsAFile( const RString &sPath ) { return GetFileType(sPath) == TYPE_FILE; }
|
||||
@@ -1089,12 +1088,12 @@ bool DeleteRecursive( RageFileDriver *prfd, const RString &sDir )
|
||||
|
||||
vector<RString> vsFiles;
|
||||
prfd->GetDirListing( sDir+"*", vsFiles, false, true );
|
||||
FOREACH_CONST( RString, vsFiles, s )
|
||||
for (RString const &s : vsFiles)
|
||||
{
|
||||
if( IsADirectory(*s) )
|
||||
DeleteRecursive( *s+"/" );
|
||||
if( IsADirectory(s) )
|
||||
DeleteRecursive( s+"/" );
|
||||
else
|
||||
FILEMAN->Remove( *s );
|
||||
FILEMAN->Remove( s );
|
||||
}
|
||||
|
||||
return FILEMAN->Remove( sDir );
|
||||
@@ -1106,12 +1105,12 @@ bool DeleteRecursive( const RString &sDir )
|
||||
|
||||
vector<RString> vsFiles;
|
||||
GetDirListing( sDir+"*", vsFiles, false, true );
|
||||
FOREACH_CONST( RString, vsFiles, s )
|
||||
for (RString const &s : vsFiles)
|
||||
{
|
||||
if( IsADirectory(*s) )
|
||||
DeleteRecursive( *s+"/" );
|
||||
if( IsADirectory(s) )
|
||||
DeleteRecursive( s+"/" );
|
||||
else
|
||||
FILEMAN->Remove( *s );
|
||||
FILEMAN->Remove( s );
|
||||
}
|
||||
|
||||
return FILEMAN->Remove( sDir );
|
||||
|
||||
Reference in New Issue
Block a user