The file drivers are one of the few things that can be accessed before LOG is set up, guard all accesses.
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
#include "RageUtil_FileDB.h"
|
||||
#include <cerrno>
|
||||
|
||||
#define Warn(args...) if( LOG ) LOG->Warn( args ); else fprintf( stderr, args )
|
||||
|
||||
static struct FileDriverEntry_ZIP: public FileDriverEntry
|
||||
{
|
||||
FileDriverEntry_ZIP(): FileDriverEntry( "ZIP" ) { }
|
||||
@@ -48,7 +50,7 @@ bool RageFileDriverZip::Load( const RString &sPath )
|
||||
|
||||
if( !pFile->Open(sPath) )
|
||||
{
|
||||
LOG->Warn( "Couldn't open %s: %s", sPath.c_str(), pFile->GetError().c_str() );
|
||||
Warn( "Couldn't open %s: %s", sPath.c_str(), pFile->GetError().c_str() );
|
||||
delete pFile;
|
||||
return false;
|
||||
}
|
||||
@@ -85,7 +87,7 @@ bool RageFileDriverZip::ReadEndCentralRecord( int &iTotalEntries, int &iCentralD
|
||||
|
||||
if( sError != "" )
|
||||
{
|
||||
LOG->Warn( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
||||
Warn( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -110,7 +112,7 @@ bool RageFileDriverZip::SeekToEndCentralRecord()
|
||||
int iGot = m_pZip->Read( buf, sizeof(buf) );
|
||||
if( iGot == -1 )
|
||||
{
|
||||
LOG->Warn( "%s: %s", m_sPath.c_str(), m_pZip->GetError().c_str() );
|
||||
Warn( "%s: %s", m_sPath.c_str(), m_pZip->GetError().c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -131,7 +133,7 @@ bool RageFileDriverZip::ParseZipfile()
|
||||
{
|
||||
if( !SeekToEndCentralRecord() )
|
||||
{
|
||||
LOG->Warn( "Couldn't open %s: couldn't find end of central directory record", m_sPath.c_str() );
|
||||
Warn( "Couldn't open %s: couldn't find end of central directory record", m_sPath.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -160,7 +162,7 @@ bool RageFileDriverZip::ParseZipfile()
|
||||
}
|
||||
|
||||
if( m_pFiles.size() == 0 )
|
||||
LOG->Warn( "%s: no files found in central file header", m_sPath.c_str() );
|
||||
Warn( "%s: no files found in central file header", m_sPath.c_str() );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -171,7 +173,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
||||
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() );
|
||||
Warn( "%s: central directory record signature not found", m_sPath.c_str() );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -196,7 +198,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
||||
/* Check for errors before reading variable-length fields. */
|
||||
if( sError != "" )
|
||||
{
|
||||
LOG->Warn( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
||||
Warn( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -206,7 +208,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
||||
|
||||
if( sError != "" )
|
||||
{
|
||||
LOG->Warn( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
||||
Warn( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -214,7 +216,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
||||
* file pointer in the middle of a record. */
|
||||
if( iGeneralPurpose & 1 )
|
||||
{
|
||||
LOG->Warn( "Skipped encrypted \"%s\" in \"%s\"", info.m_sName.c_str(), m_sPath.c_str() );
|
||||
Warn( "Skipped encrypted \"%s\" in \"%s\"", info.m_sName.c_str(), m_sPath.c_str() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -233,7 +235,7 @@ int RageFileDriverZip::ProcessCdirFileHdr( FileInfo &info )
|
||||
|
||||
if( info.m_iCompressionMethod != STORED && info.m_iCompressionMethod != DEFLATED )
|
||||
{
|
||||
LOG->Warn( "File \"%s\" in \"%s\" uses unsupported compression method %i",
|
||||
Warn( "File \"%s\" in \"%s\" uses unsupported compression method %i",
|
||||
info.m_sName.c_str(), m_sPath.c_str(), info.m_iCompressionMethod );
|
||||
|
||||
return 0;
|
||||
@@ -252,13 +254,13 @@ bool RageFileDriverZip::ReadLocalFileHeader( FileInfo &info )
|
||||
|
||||
if( sError != "" )
|
||||
{
|
||||
LOG->Warn( "%s: error opening \"%s\": %s", m_sPath.c_str(), info.m_sName.c_str(), sError.c_str() );
|
||||
Warn( "%s: error opening \"%s\": %s", m_sPath.c_str(), info.m_sName.c_str(), sError.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( sSig != "\x50\x4B\x03\x04" )
|
||||
{
|
||||
LOG->Warn( "%s: local file header not found for \"%s\"", m_sPath.c_str(), info.m_sName.c_str() );
|
||||
Warn( "%s: local file header not found for \"%s\"", m_sPath.c_str(), info.m_sName.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -270,7 +272,7 @@ bool RageFileDriverZip::ReadLocalFileHeader( FileInfo &info )
|
||||
|
||||
if( sError != "" )
|
||||
{
|
||||
LOG->Warn( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
||||
Warn( "%s: %s", m_sPath.c_str(), sError.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user