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