add RageFileDriverSlice::DeleteFileWhenFinished
This commit is contained in:
@@ -7,16 +7,19 @@ RageFileDriverSlice::RageFileDriverSlice( RageFileBasic *pFile, int iOffset, int
|
||||
m_iOffset = iOffset;
|
||||
m_iFileSize = iFileSize;
|
||||
m_iFilePos = 0;
|
||||
m_bFileOwned = false;
|
||||
}
|
||||
|
||||
RageFileDriverSlice::~RageFileDriverSlice()
|
||||
{
|
||||
delete m_pFile;
|
||||
if( m_bFileOwned )
|
||||
delete m_pFile;
|
||||
}
|
||||
|
||||
RageFileBasic *RageFileDriverSlice::Copy() const
|
||||
{
|
||||
RageFileDriverSlice *pRet = new RageFileDriverSlice( m_pFile->Copy(), m_iOffset, m_iFileSize );
|
||||
pRet->m_bFileOwned = true;
|
||||
pRet->m_iFilePos = m_iFilePos;
|
||||
return pRet;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ public:
|
||||
~RageFileDriverSlice();
|
||||
RageFileBasic *Copy() const;
|
||||
|
||||
void DeleteFileWhenFinished() { m_bFileOwned = true; }
|
||||
|
||||
int ReadInternal( void *pBuffer, size_t iBytes );
|
||||
int WriteInternal( const void *pBuffer, size_t iBytes ) { SetError( "Not implemented" ); return -1; }
|
||||
int SeekInternal( int iOffset );
|
||||
@@ -22,6 +24,7 @@ private:
|
||||
RageFileBasic *m_pFile;
|
||||
int m_iFilePos;
|
||||
int m_iOffset, m_iFileSize;
|
||||
bool m_bFileOwned;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -366,7 +366,9 @@ RageFileBasic *RageFileDriverZip::Open( const CString &path, int mode, int &err
|
||||
|
||||
zip.Seek( info->data_offset );
|
||||
|
||||
RageFileBasic *pFile = new RageFileDriverSlice( zip.Copy(), info->data_offset, info->compr_size );
|
||||
RageFileDriverSlice *pFile = new RageFileDriverSlice( zip.Copy(), info->data_offset, info->compr_size );
|
||||
pFile->DeleteFileWhenFinished();
|
||||
|
||||
switch( info->compression_method )
|
||||
{
|
||||
case STORED:
|
||||
|
||||
Reference in New Issue
Block a user