diff --git a/stepmania/src/RageFileDriverDirect.cpp b/stepmania/src/RageFileDriverDirect.cpp index 3607355fb8..ff3ace85e4 100644 --- a/stepmania/src/RageFileDriverDirect.cpp +++ b/stepmania/src/RageFileDriverDirect.cpp @@ -22,13 +22,20 @@ #include #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 ) { diff --git a/stepmania/src/RageFileDriverDirect.h b/stepmania/src/RageFileDriverDirect.h index 50f2056ece..d88813b848 100644 --- a/stepmania/src/RageFileDriverDirect.h +++ b/stepmania/src/RageFileDriverDirect.h @@ -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 /*