Correcting some bugs in Q3BSPZipArchive

pull/261/head
Léo Terziman 2013-09-06 17:37:01 +02:00
parent 45572e8079
commit 2ef0f0f0e1
1 changed files with 12 additions and 11 deletions

View File

@ -72,12 +72,19 @@ Q3BSPZipArchive::Q3BSPZipArchive( const std::string& rFile ) :
// Destructor. // Destructor.
Q3BSPZipArchive::~Q3BSPZipArchive() Q3BSPZipArchive::~Q3BSPZipArchive()
{ {
for( std::map<std::string, IOStream*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it )
{
delete it->second;
}
m_ArchiveMap.clear();
m_FileList.clear();
if ( NULL != m_ZipFileHandle ) if ( NULL != m_ZipFileHandle )
{ {
unzClose( m_ZipFileHandle ); unzClose( m_ZipFileHandle );
} }
m_ZipFileHandle = NULL; m_ZipFileHandle = NULL;
m_FileList.clear();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -172,19 +179,13 @@ bool Q3BSPZipArchive::mapArchive()
// At first ensure file is already open // At first ensure file is already open
if ( UNZ_OK == unzGoToFirstFile( m_ZipFileHandle ) ) if ( UNZ_OK == unzGoToFirstFile( m_ZipFileHandle ) )
{ {
char filename[ FileNameSize ];
unzGetCurrentFileInfo( m_ZipFileHandle, NULL, filename, FileNameSize, NULL, 0, NULL, 0 );
m_FileList.push_back( filename );
unzCloseCurrentFile( m_ZipFileHandle );
// Loop over all files // Loop over all files
while ( unzGoToNextFile( m_ZipFileHandle ) != UNZ_END_OF_LIST_OF_FILE ) do {
{
char filename[ FileNameSize ]; char filename[ FileNameSize ];
unzGetCurrentFileInfo( m_ZipFileHandle, NULL, filename, FileNameSize, NULL, 0, NULL, 0 ); unzGetCurrentFileInfo( m_ZipFileHandle, NULL, filename, FileNameSize, NULL, 0, NULL, 0 );
m_FileList.push_back( filename ); m_FileList.push_back( filename );
unzCloseCurrentFile( m_ZipFileHandle ); unzCloseCurrentFile( m_ZipFileHandle );
} } while ( unzGoToNextFile( m_ZipFileHandle ) != UNZ_END_OF_LIST_OF_FILE );
} }
std::sort( m_FileList.begin(), m_FileList.end() ); std::sort( m_FileList.begin(), m_FileList.end() );