add RageFileDriverSlice::DeleteFileWhenFinished

This commit is contained in:
Glenn Maynard
2004-12-12 04:07:22 +00:00
parent fdf6ad8735
commit ea79ec3e1b
3 changed files with 10 additions and 2 deletions
+4 -1
View File
@@ -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;
}
+3
View File
@@ -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
+3 -1
View File
@@ -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: