don't use macros with variable number of arguments - no version of VC supports it
use existing WARN macro which falls back to printf if LOG isn't yet constructed
This commit is contained in:
@@ -23,8 +23,6 @@
|
|||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TRACE(...) if( LOG ) LOG->Trace( __VA_ARGS__ ); else fprintf( stderr, __VA_ARGS__ )
|
|
||||||
|
|
||||||
RageFileObjInflate::RageFileObjInflate( RageFileBasic *pFile, int iUncompressedSize )
|
RageFileObjInflate::RageFileObjInflate( RageFileBasic *pFile, int iUncompressedSize )
|
||||||
{
|
{
|
||||||
m_bFileOwned = false;
|
m_bFileOwned = false;
|
||||||
@@ -39,7 +37,7 @@ RageFileObjInflate::RageFileObjInflate( RageFileBasic *pFile, int iUncompressedS
|
|||||||
if( err == Z_MEM_ERROR )
|
if( err == Z_MEM_ERROR )
|
||||||
RageException::Throw( "inflateInit2( %i ): out of memory.", -MAX_WBITS );
|
RageException::Throw( "inflateInit2( %i ): out of memory.", -MAX_WBITS );
|
||||||
if( err != Z_OK )
|
if( err != Z_OK )
|
||||||
TRACE( "Huh? inflateInit2() err = %i", err );
|
WARN( ssprintf("Huh? inflateInit2() err = %i", err) );
|
||||||
|
|
||||||
decomp_buf_ptr = decomp_buf;
|
decomp_buf_ptr = decomp_buf;
|
||||||
m_iFilePos = 0;
|
m_iFilePos = 0;
|
||||||
@@ -75,7 +73,7 @@ RageFileObjInflate::~RageFileObjInflate()
|
|||||||
|
|
||||||
int err = inflateEnd( m_pInflate );
|
int err = inflateEnd( m_pInflate );
|
||||||
if( err != Z_OK )
|
if( err != Z_OK )
|
||||||
TRACE( "Huh? inflateEnd() err = %i", err );
|
WARN( ssprintf("Huh? inflateEnd() err = %i", err) );
|
||||||
|
|
||||||
delete m_pInflate;
|
delete m_pInflate;
|
||||||
}
|
}
|
||||||
@@ -130,7 +128,7 @@ int RageFileObjInflate::ReadInternal( void *buf, size_t bytes )
|
|||||||
case Z_OK:
|
case Z_OK:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
TRACE( "Huh? inflate err %i", err );
|
WARN( ssprintf("Huh? inflate err %i", err) );
|
||||||
}
|
}
|
||||||
|
|
||||||
const int used = (char *)m_pInflate->next_in - decomp_buf_ptr;
|
const int used = (char *)m_pInflate->next_in - decomp_buf_ptr;
|
||||||
@@ -207,7 +205,7 @@ RageFileObjDeflate::RageFileObjDeflate( RageFileBasic *pFile )
|
|||||||
if( err == Z_MEM_ERROR )
|
if( err == Z_MEM_ERROR )
|
||||||
RageException::Throw( "inflateInit2( %i ): out of memory.", -MAX_WBITS );
|
RageException::Throw( "inflateInit2( %i ): out of memory.", -MAX_WBITS );
|
||||||
if( err != Z_OK )
|
if( err != Z_OK )
|
||||||
TRACE( "Huh? inflateInit2() err = %i", err );
|
WARN( ssprintf("Huh? inflateInit2() err = %i", err) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +218,7 @@ RageFileObjDeflate::~RageFileObjDeflate()
|
|||||||
|
|
||||||
int err = deflateEnd( m_pDeflate );
|
int err = deflateEnd( m_pDeflate );
|
||||||
if( err != Z_OK )
|
if( err != Z_OK )
|
||||||
TRACE( "Huh? deflateEnd() err = %i", err );
|
WARN( ssprintf("Huh? deflateEnd() err = %i", err) );
|
||||||
|
|
||||||
delete m_pDeflate;
|
delete m_pDeflate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,6 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TRACE(...) if( LOG ) LOG->Trace( __VA_ARGS__ ); else fprintf( stderr, __VA_ARGS__ )
|
|
||||||
#define WARN(...) if( LOG ) LOG->Warn( __VA_ARGS__ ); else fprintf( stderr, __VA_ARGS__ )
|
|
||||||
|
|
||||||
static struct FileDriverEntry_DIR: public FileDriverEntry
|
static struct FileDriverEntry_DIR: public FileDriverEntry
|
||||||
{
|
{
|
||||||
@@ -146,10 +144,10 @@ bool RageFileDriverDirect::Move( const RString &sOldPath_, const RString &sNewPa
|
|||||||
CreateDirectories( m_sRoot + sDir );
|
CreateDirectories( m_sRoot + sDir );
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("rename \"%s\" -> \"%s\"", (m_sRoot + sOldPath).c_str(), (m_sRoot + sNewPath).c_str() );
|
TRACE( ssprintf("rename \"%s\" -> \"%s\"", (m_sRoot + sOldPath).c_str(), (m_sRoot + sNewPath).c_str()) );
|
||||||
if( DoRename(m_sRoot + sOldPath, m_sRoot + sNewPath) == -1 )
|
if( DoRename(m_sRoot + sOldPath, m_sRoot + sNewPath) == -1 )
|
||||||
{
|
{
|
||||||
WARN( "rename(%s,%s) failed: %s", (m_sRoot + sOldPath).c_str(), (m_sRoot + sNewPath).c_str(), strerror(errno) );
|
WARN( ssprintf("rename(%s,%s) failed: %s", (m_sRoot + sOldPath).c_str(), (m_sRoot + sNewPath).c_str(), strerror(errno)) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,20 +161,20 @@ bool RageFileDriverDirect::Remove( const RString &sPath_ )
|
|||||||
switch( this->GetFileType(sPath) )
|
switch( this->GetFileType(sPath) )
|
||||||
{
|
{
|
||||||
case RageFileManager::TYPE_FILE:
|
case RageFileManager::TYPE_FILE:
|
||||||
TRACE("remove '%s'", (m_sRoot + sPath).c_str());
|
TRACE( ssprintf("remove '%s'", (m_sRoot + sPath).c_str()) );
|
||||||
if( DoRemove(m_sRoot + sPath) == -1 )
|
if( DoRemove(m_sRoot + sPath) == -1 )
|
||||||
{
|
{
|
||||||
WARN( "remove(%s) failed: %s", (m_sRoot + sPath).c_str(), strerror(errno) );
|
WARN( ssprintf("remove(%s) failed: %s", (m_sRoot + sPath).c_str(), strerror(errno)) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FDB->DelFile( sPath );
|
FDB->DelFile( sPath );
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case RageFileManager::TYPE_DIR:
|
case RageFileManager::TYPE_DIR:
|
||||||
TRACE("rmdir '%s'", (m_sRoot + sPath).c_str());
|
TRACE( ssprintf("rmdir '%s'", (m_sRoot + sPath).c_str()) );
|
||||||
if( DoRmdir(m_sRoot + sPath) == -1 )
|
if( DoRmdir(m_sRoot + sPath) == -1 )
|
||||||
{
|
{
|
||||||
WARN( "rmdir(%s) failed: %s", (m_sRoot + sPath).c_str(), strerror(errno) );
|
WARN( ssprintf("rmdir(%s) failed: %s", (m_sRoot + sPath).c_str(), strerror(errno)) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FDB->DelFile( sPath );
|
FDB->DelFile( sPath );
|
||||||
@@ -240,7 +238,7 @@ bool RageFileObjDirect::FinalFlush()
|
|||||||
/* Force a kernel buffer flush. */
|
/* Force a kernel buffer flush. */
|
||||||
if( fsync( m_iFD ) == -1 )
|
if( fsync( m_iFD ) == -1 )
|
||||||
{
|
{
|
||||||
WARN( "Error synchronizing %s: %s", this->m_sPath.c_str(), strerror(errno) );
|
WARN( ssprintf("Error synchronizing %s: %s", this->m_sPath.c_str(), strerror(errno)) );
|
||||||
SetError( strerror(errno) );
|
SetError( strerror(errno) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -277,7 +275,7 @@ RageFileObjDirect::~RageFileObjDirect()
|
|||||||
{
|
{
|
||||||
if( close( m_iFD ) == -1 )
|
if( close( m_iFD ) == -1 )
|
||||||
{
|
{
|
||||||
WARN( "Error closing %s: %s", this->m_sPath.c_str(), strerror(errno) );
|
WARN( ssprintf("Error closing %s: %s", this->m_sPath.c_str(), strerror(errno)) );
|
||||||
SetError( strerror(errno) );
|
SetError( strerror(errno) );
|
||||||
bFailed = true;
|
bFailed = true;
|
||||||
}
|
}
|
||||||
@@ -312,7 +310,7 @@ RageFileObjDirect::~RageFileObjDirect()
|
|||||||
/* We failed. */
|
/* We failed. */
|
||||||
int err = GetLastError();
|
int err = GetLastError();
|
||||||
const RString 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() );
|
||||||
WARN( "%s", error.c_str() );
|
WARN( ssprintf("%s", error.c_str()) );
|
||||||
SetError( error );
|
SetError( error );
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WARN(...) if( LOG ) LOG->Warn( __VA_ARGS__ ); else fprintf( stderr, __VA_ARGS__ )
|
|
||||||
|
|
||||||
#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 RString &sPath, int perm )
|
int DoMkdir( const RString &sPath, int perm )
|
||||||
@@ -153,14 +151,14 @@ bool CreateDirectories( RString Path )
|
|||||||
/* I can't reproduce this anymore. If we get ENOENT, log it but keep
|
/* I can't reproduce this anymore. If we get ENOENT, log it but keep
|
||||||
* going. */
|
* going. */
|
||||||
if( errno == ENOENT )
|
if( errno == ENOENT )
|
||||||
WARN( "Couldn't create %s: %s", curpath.c_str(), strerror(errno) );
|
WARN( ssprintf("Couldn't create %s: %s", curpath.c_str(), strerror(errno)) );
|
||||||
if( errno == EEXIST || errno == ENOENT )
|
if( errno == EEXIST || errno == ENOENT )
|
||||||
continue; // we expect to see these errors
|
continue; // we expect to see these errors
|
||||||
|
|
||||||
// XXX: This doesn't make sense. Why do we return if LOG is present here?
|
// XXX: This doesn't make sense. Why do we return if LOG is present here?
|
||||||
if( LOG )
|
if( LOG )
|
||||||
{
|
{
|
||||||
WARN( "Couldn't create %s: %s", curpath.c_str(), strerror(errno) );
|
WARN( ssprintf("Couldn't create %s: %s", curpath.c_str(), strerror(errno)) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +167,7 @@ bool CreateDirectories( RString Path )
|
|||||||
DoStat( curpath, &st );
|
DoStat( curpath, &st );
|
||||||
if( !(st.st_mode & S_IFDIR) )
|
if( !(st.st_mode & S_IFDIR) )
|
||||||
{
|
{
|
||||||
WARN( "Couldn't create %s: path exists and is not a directory", curpath.c_str() );
|
WARN( ssprintf("Couldn't create %s: path exists and is not a directory", curpath.c_str()) );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,6 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#define WARN(...) if( LOG ) LOG->Warn( __VA_ARGS__ ); else fprintf( stderr, __VA_ARGS__ )
|
|
||||||
|
|
||||||
enum ThreadRequest
|
enum ThreadRequest
|
||||||
{
|
{
|
||||||
REQ_OPEN,
|
REQ_OPEN,
|
||||||
@@ -159,7 +157,7 @@ ThreadedFileWorker::ThreadedFileWorker( RString sPath ):
|
|||||||
/* Grab a reference to the child driver. We'll operate on it directly. */
|
/* Grab a reference to the child driver. We'll operate on it directly. */
|
||||||
m_pChildDriver = FILEMAN->GetFileDriver( sPath );
|
m_pChildDriver = FILEMAN->GetFileDriver( sPath );
|
||||||
if( m_pChildDriver == NULL )
|
if( m_pChildDriver == NULL )
|
||||||
WARN( "ThreadedFileWorker: Mountpoint \"%s\" not found", sPath.c_str() );
|
WARN( ssprintf("ThreadedFileWorker: Mountpoint \"%s\" not found", sPath.c_str()) );
|
||||||
|
|
||||||
m_pResultFile = NULL;
|
m_pResultFile = NULL;
|
||||||
m_pRequestFile = NULL;
|
m_pRequestFile = NULL;
|
||||||
@@ -864,7 +862,7 @@ bool RageFileDriverTimeout::Move( const RString &sOldPath, const RString &sNewPa
|
|||||||
int iRet = m_pWorker->Move( sOldPath, sNewPath );
|
int iRet = m_pWorker->Move( sOldPath, sNewPath );
|
||||||
if( iRet == -1 )
|
if( iRet == -1 )
|
||||||
{
|
{
|
||||||
WARN( "RageFileDriverTimeout::Move(%s,%s) failed", sOldPath.c_str(), sNewPath.c_str() );
|
WARN( ssprintf("RageFileDriverTimeout::Move(%s,%s) failed", sOldPath.c_str(), sNewPath.c_str()) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -876,7 +874,7 @@ bool RageFileDriverTimeout::Remove( const RString &sPath )
|
|||||||
int iRet = m_pWorker->Remove( sPath );
|
int iRet = m_pWorker->Remove( sPath );
|
||||||
if( iRet == -1 )
|
if( iRet == -1 )
|
||||||
{
|
{
|
||||||
WARN( "RageFileDriverTimeout::Remove(%s) failed", sPath.c_str() );
|
WARN( ssprintf("RageFileDriverTimeout::Remove(%s) failed", sPath.c_str()) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
#include "RageUtil_FileDB.h"
|
#include "RageUtil_FileDB.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
#define WARN(...) if( LOG ) LOG->Warn( __VA_ARGS__ ); else fprintf( stderr, __VA_ARGS__ )
|
|
||||||
|
|
||||||
static struct FileDriverEntry_ZIP: public FileDriverEntry
|
static struct FileDriverEntry_ZIP: public FileDriverEntry
|
||||||
{
|
{
|
||||||
FileDriverEntry_ZIP(): FileDriverEntry( "ZIP" ) { }
|
FileDriverEntry_ZIP(): FileDriverEntry( "ZIP" ) { }
|
||||||
@@ -50,7 +48,7 @@ bool RageFileDriverZip::Load( const RString &sPath )
|
|||||||
|
|
||||||
if( !pFile->Open(sPath) )
|
if( !pFile->Open(sPath) )
|
||||||
{
|
{
|
||||||
WARN( "Couldn't open %s: %s", sPath.c_str(), pFile->GetError().c_str() );
|
WARN( ssprintf("Couldn't open %s: %s", sPath.c_str(), pFile->GetError().c_str()) );
|
||||||
delete pFile;
|
delete pFile;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -87,7 +85,7 @@ bool RageFileDriverZip::ReadEndCentralRecord( int &iTotalEntries, int &iCentralD
|
|||||||
|
|
||||||
if( sError != "" )
|
if( sError != "" )
|
||||||
{
|
{
|
||||||
WARN( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
WARN( ssprintf("%s: %s", m_sPath.c_str(), sError.c_str()) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +110,7 @@ bool RageFileDriverZip::SeekToEndCentralRecord()
|
|||||||
int iGot = m_pZip->Read( buf, sizeof(buf) );
|
int iGot = m_pZip->Read( buf, sizeof(buf) );
|
||||||
if( iGot == -1 )
|
if( iGot == -1 )
|
||||||
{
|
{
|
||||||
WARN( "%s: %s", m_sPath.c_str(), m_pZip->GetError().c_str() );
|
WARN( ssprintf("%s: %s", m_sPath.c_str(), m_pZip->GetError().c_str()) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +131,7 @@ bool RageFileDriverZip::ParseZipfile()
|
|||||||
{
|
{
|
||||||
if( !SeekToEndCentralRecord() )
|
if( !SeekToEndCentralRecord() )
|
||||||
{
|
{
|
||||||
WARN( "Couldn't open %s: couldn't find end of central directory record", m_sPath.c_str() );
|
WARN( ssprintf("Couldn't open %s: couldn't find end of central directory record", m_sPath.c_str()) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +160,7 @@ bool RageFileDriverZip::ParseZipfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( m_pFiles.size() == 0 )
|
if( m_pFiles.size() == 0 )
|
||||||
WARN( "%s: no files found in central file header", m_sPath.c_str() );
|
WARN( ssprintf("%s: no files found in central file header", m_sPath.c_str()) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -173,7 +171,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
|||||||
RString sSig = FileReading::ReadString( *m_pZip, 4, sError );
|
RString sSig = FileReading::ReadString( *m_pZip, 4, sError );
|
||||||
if( sSig != "\x50\x4B\x01\x02" )
|
if( sSig != "\x50\x4B\x01\x02" )
|
||||||
{
|
{
|
||||||
WARN( "%s: central directory record signature not found", m_sPath.c_str() );
|
WARN( ssprintf("%s: central directory record signature not found", m_sPath.c_str()) );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +196,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
|||||||
/* Check for errors before reading variable-length fields. */
|
/* Check for errors before reading variable-length fields. */
|
||||||
if( sError != "" )
|
if( sError != "" )
|
||||||
{
|
{
|
||||||
WARN( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
WARN( ssprintf("%s: %s", m_sPath.c_str(), sError.c_str()) );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +206,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
|||||||
|
|
||||||
if( sError != "" )
|
if( sError != "" )
|
||||||
{
|
{
|
||||||
WARN( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
WARN( ssprintf("%s: %s", m_sPath.c_str(), sError.c_str()) );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +214,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
|||||||
* file pointer in the middle of a record. */
|
* file pointer in the middle of a record. */
|
||||||
if( iGeneralPurpose & 1 )
|
if( iGeneralPurpose & 1 )
|
||||||
{
|
{
|
||||||
WARN( "Skipped encrypted \"%s\" in \"%s\"", info.m_sName.c_str(), m_sPath.c_str() );
|
WARN( ssprintf("Skipped encrypted \"%s\" in \"%s\"", info.m_sName.c_str(), m_sPath.c_str()) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,8 +233,8 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
|||||||
|
|
||||||
if( info.m_iCompressionMethod != STORED && info.m_iCompressionMethod != DEFLATED )
|
if( info.m_iCompressionMethod != STORED && info.m_iCompressionMethod != DEFLATED )
|
||||||
{
|
{
|
||||||
WARN( "File \"%s\" in \"%s\" uses unsupported compression method %i",
|
WARN( ssprintf("File \"%s\" in \"%s\" uses unsupported compression method %i",
|
||||||
info.m_sName.c_str(), m_sPath.c_str(), info.m_iCompressionMethod );
|
info.m_sName.c_str(), m_sPath.c_str(), info.m_iCompressionMethod) );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -254,13 +252,13 @@ bool RageFileDriverZip::ReadLocalFileHeader( FileInfo &info )
|
|||||||
|
|
||||||
if( sError != "" )
|
if( sError != "" )
|
||||||
{
|
{
|
||||||
WARN( "%s: error opening \"%s\": %s", m_sPath.c_str(), info.m_sName.c_str(), sError.c_str() );
|
WARN( ssprintf("%s: error opening \"%s\": %s", m_sPath.c_str(), info.m_sName.c_str(), sError.c_str()) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( sSig != "\x50\x4B\x03\x04" )
|
if( sSig != "\x50\x4B\x03\x04" )
|
||||||
{
|
{
|
||||||
WARN( "%s: local file header not found for \"%s\"", m_sPath.c_str(), info.m_sName.c_str() );
|
WARN( ssprintf("%s: local file header not found for \"%s\"", m_sPath.c_str(), info.m_sName.c_str()) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +270,7 @@ bool RageFileDriverZip::ReadLocalFileHeader( FileInfo &info )
|
|||||||
|
|
||||||
if( sError != "" )
|
if( sError != "" )
|
||||||
{
|
{
|
||||||
WARN( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
WARN( ssprintf("%s: %s", m_sPath.c_str(), sError.c_str()) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -413,19 +413,22 @@ void RageLog::UnmapLog( const RString &key )
|
|||||||
UpdateMappedLog();
|
UpdateMappedLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowWarning( const char *file, int line, const char *message )
|
void ShowWarningOrTrace( const char *file, int line, const char *message, bool bWarning )
|
||||||
{
|
{
|
||||||
/* Ignore everything up to and including the first "src/". */
|
/* Ignore everything up to and including the first "src/". */
|
||||||
const char *temp = strstr( file, "src/" );
|
const char *temp = strstr( file, "src/" );
|
||||||
if( temp )
|
if( temp )
|
||||||
file = temp + 4;
|
file = temp + 4;
|
||||||
|
|
||||||
if( LOG != NULL )
|
void (RageLog::*method)(const char *fmt, ...) = bWarning ? RageLog::Warn : RageLog::Trace;
|
||||||
LOG->Warn( "%s:%i: %s", file, line, message );
|
|
||||||
|
if( LOG )
|
||||||
|
(LOG->*method)( "%s:%i: %s", file, line, message );
|
||||||
else
|
else
|
||||||
fprintf( stderr, "%s:%i: %s", file, line, message );
|
fprintf( stderr, "%s:%i: %s", file, line, message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2004 Chris Danford, Glenn Maynard
|
* Copyright (c) 2001-2004 Chris Danford, Glenn Maynard
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -111,8 +111,9 @@ void NORETURN sm_crash( const char *reason = "Internal error" );
|
|||||||
/* Use this to catch switching on invalid values */
|
/* Use this to catch switching on invalid values */
|
||||||
#define DEFAULT_FAIL(i) default: FAIL_M( ssprintf("%s = %i", #i, (i)) )
|
#define DEFAULT_FAIL(i) default: FAIL_M( ssprintf("%s = %i", #i, (i)) )
|
||||||
|
|
||||||
void ShowWarning( const char *file, int line, const char *message ); // don't pull in LOG here
|
void ShowWarningOrTrace( const char *file, int line, const char *message, bool bWarning ); // don't pull in LOG here
|
||||||
#define WARN(MESSAGE) (ShowWarning(__FILE__, __LINE__, MESSAGE))
|
#define WARN(MESSAGE) (ShowWarningOrTrace(__FILE__, __LINE__, MESSAGE, true))
|
||||||
|
#define TRACE(MESSAGE) (ShowWarningOrTrace(__FILE__, __LINE__, MESSAGE, false))
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DEBUG_ASSERT(x) ASSERT(x)
|
#define DEBUG_ASSERT(x) ASSERT(x)
|
||||||
|
|||||||
Reference in New Issue
Block a user