add "DIRRO" driver for read-only access
This commit is contained in:
@@ -22,13 +22,20 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Direct filesystem access: */
|
||||||
static struct FileDriverEntry_DIR: public FileDriverEntry
|
static struct FileDriverEntry_DIR: public FileDriverEntry
|
||||||
{
|
{
|
||||||
FileDriverEntry_DIR(): FileDriverEntry( "DIR" ) { }
|
FileDriverEntry_DIR(): FileDriverEntry( "DIR" ) { }
|
||||||
RageFileDriver *Create( const RString &sRoot ) const { return new RageFileDriverDirect( sRoot ); }
|
RageFileDriver *Create( const RString &sRoot ) const { return new RageFileDriverDirect( sRoot ); }
|
||||||
} const g_RegisterDriver;
|
} 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. */
|
/* This driver handles direct file access. */
|
||||||
|
|
||||||
class RageFileObjDirect: public RageFileObj
|
class RageFileObjDirect: public RageFileObj
|
||||||
@@ -222,6 +229,22 @@ bool RageFileDriverDirect::Remount( const RString &sPath )
|
|||||||
return true;
|
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;
|
static const unsigned int BUFSIZE = 1024*64;
|
||||||
RageFileObjDirect::RageFileObjDirect( const RString &sPath, int iFD, int iMode )
|
RageFileObjDirect::RageFileObjDirect( const RString &sPath, int iFD, int iMode )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ private:
|
|||||||
RString m_sRoot;
|
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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user