add "DIRRO" driver for read-only access

This commit is contained in:
Glenn Maynard
2009-11-05 01:09:24 +00:00
parent efe33da964
commit c78548d862
2 changed files with 33 additions and 1 deletions
+24 -1
View File
@@ -22,13 +22,20 @@
#include <io.h>
#endif
/* Direct filesystem access: */
static struct FileDriverEntry_DIR: public FileDriverEntry
{
FileDriverEntry_DIR(): FileDriverEntry( "DIR" ) { }
RageFileDriver *Create( const RString &sRoot ) const { return new RageFileDriverDirect( sRoot ); }
} const g_RegisterDriver;
/* Direct read-only filesystem access: */
static struct FileDriverEntry_DIRRO: public FileDriverEntry
{
FileDriverEntry_DIRRO(): FileDriverEntry( "DIRRO" ) { }
RageFileDriver *Create( const RString &sRoot ) const { return new RageFileDriverDirectReadOnly( sRoot ); }
} const g_RegisterDriver2;
/* This driver handles direct file access. */
class RageFileObjDirect: public RageFileObj
@@ -222,6 +229,22 @@ bool RageFileDriverDirect::Remount( const RString &sPath )
return true;
}
/* The DIRRO driver is just like DIR, except writes are disallowed. */
RageFileDriverDirectReadOnly::RageFileDriverDirectReadOnly( const RString &sRoot ):
RageFileDriverDirect( sRoot ) { }
RageFileBasic *RageFileDriverDirectReadOnly::Open( const RString &sPath, int iMode, int &iError )
{
if( iMode & RageFile::WRITE )
{
iError = EROFS;
return NULL;
}
return RageFileDriverDirect::Open( sPath, iMode, iError );
}
bool RageFileDriverDirectReadOnly::Move( const RString &sOldPath, const RString &sNewPath ) { return false; }
bool RageFileDriverDirectReadOnly::Remove( const RString &sPath ) { return false; }
static const unsigned int BUFSIZE = 1024*64;
RageFileObjDirect::RageFileObjDirect( const RString &sPath, int iFD, int iMode )
{
+9
View File
@@ -19,6 +19,15 @@ private:
RString m_sRoot;
};
class RageFileDriverDirectReadOnly: public RageFileDriverDirect
{
public:
RageFileDriverDirectReadOnly( const RString &sRoot );
RageFileBasic *Open( const RString &sPath, int iMode, int &iError );
bool Move( const RString &sOldPath, const RString &sNewPath );
bool Remove( const RString &sPath );
};
#endif
/*