RageFileBasic *RageFileDriverDirect::Open( const CString &sPath_, int iMode, int &iError ) { CString sPath = sPath_; ASSERT( sPath.size() && sPath[0] == '/' ); /* This partially resolves. For example, if "abc/def" exists, and we're opening * "ABC/DEF/GHI/jkl/mno", this will resolve it to "abc/def/GHI/jkl/mno"; we'll * create the missing parts below. */ FDB->ResolvePath( sPath ); if( iMode & RageFile::WRITE ) { const CString dir = Dirname(sPath); if( this->GetFileType(dir) != RageFileManager::TYPE_DIR ) CreateDirectories( m_sRoot + dir ); } RageFileObjDirect *ret = this->CreateInternal( m_sRoot + sPath ); if( ret->OpenInternal( m_sRoot + sPath, iMode, iError) ) return ret; SAFE_DELETE( ret ); return NULL; }
RageFileObjDirect *RageFileObjDirect::Copy() const { int iErr; RageFileObjDirect *ret = MakeFileObjDirect( m_sPath, m_iMode, iErr ); if( ret == NULL ) RageException::Throw( "Couldn't reopen \"%s\": %s", m_sPath.c_str(), strerror(iErr) ); ret->Seek( (int)lseek( m_iFD, 0, SEEK_CUR ) ); return ret; }
RageFileObjDirect *RageFileObjDirect::Copy() const { int iErr; RageFileObjDirect *ret = new RageFileObjDirect; if( ret->OpenInternal( m_sPath, m_iMode, iErr ) ) { ret->Seek( lseek( m_iFD, 0, SEEK_CUR ) ); return ret; } RageException::Throw( "Couldn't reopen \"%s\": %s", m_sPath.c_str(), strerror(iErr) ); delete ret; return NULL; }