fix refcounting
This commit is contained in:
@@ -74,7 +74,7 @@ RageFile::RageFile( const RageFile &cpy )
|
|||||||
ResetBuf();
|
ResetBuf();
|
||||||
|
|
||||||
/* This will copy the file driver, including its internal file pointer. */
|
/* This will copy the file driver, including its internal file pointer. */
|
||||||
m_File = cpy.m_File->Copy( *this );
|
m_File = FILEMAN->CopyFileObj( cpy.m_File, *this );
|
||||||
m_Path = cpy.m_Path;
|
m_Path = cpy.m_Path;
|
||||||
m_Mode = cpy.m_Mode;
|
m_Mode = cpy.m_Mode;
|
||||||
m_Error = cpy.m_Error;
|
m_Error = cpy.m_Error;
|
||||||
|
|||||||
@@ -339,6 +339,20 @@ RageFileObj *RageFileManager::Open( const CString &sPath, RageFile::OpenMode mod
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy a RageFileObj for a new RageFile. */
|
||||||
|
RageFileObj *RageFileManager::CopyFileObj( const RageFileObj *cpy, RageFile &p )
|
||||||
|
{
|
||||||
|
FileReferences::const_iterator it = g_Refs.find( cpy );
|
||||||
|
RAGE_ASSERT_M( it != g_Refs.end(), ssprintf( "RemoveReference: Missing reference (%s)", cpy->GetDisplayPath().c_str() ) );
|
||||||
|
|
||||||
|
RageFileObj *ret = cpy->Copy( p );
|
||||||
|
|
||||||
|
/* It's from the same driver as the original. */
|
||||||
|
AddReference( ret, it->second );
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
RageFileObj *RageFileManager::OpenForWriting( const CString &sPath, RageFile::OpenMode mode, RageFile &p, int &err )
|
RageFileObj *RageFileManager::OpenForWriting( const CString &sPath, RageFile::OpenMode mode, RageFile &p, int &err )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
/* Used only by RageFile: */
|
/* Used only by RageFile: */
|
||||||
RageFileObj *Open( const CString &sPath, RageFile::OpenMode mode, RageFile &p, int &err );
|
RageFileObj *Open( const CString &sPath, RageFile::OpenMode mode, RageFile &p, int &err );
|
||||||
void Close( RageFileObj *obj );
|
void Close( RageFileObj *obj );
|
||||||
|
RageFileObj *CopyFileObj( const RageFileObj *cpy, RageFile &p );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RageFileObj *OpenForWriting( const CString &sPath, RageFile::OpenMode mode, RageFile &p, int &err );
|
RageFileObj *OpenForWriting( const CString &sPath, RageFile::OpenMode mode, RageFile &p, int &err );
|
||||||
|
|||||||
Reference in New Issue
Block a user