From d6127ee7dd07b06c6fc43ea0c4a67016dcf14b61 Mon Sep 17 00:00:00 2001 From: Mark Cannon Date: Thu, 7 Oct 2010 03:31:20 +0000 Subject: [PATCH] added read-only direct file driver, re-derived crypto drivers off of it git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg/branches/dev@854 83fadc84-e282-4d84-a09a-c4228d6ae7e5 --- src/RageFileDriver.h | 2 +- src/RageFileDriverDirect.cpp | 19 +++++++++++++++++++ src/RageFileDriverDirect.h | 9 +++++++++ src/StepMania.cpp | 2 +- src/arch/ArchHooks/ArchHooks_Unix.cpp | 4 ++-- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/RageFileDriver.h b/src/RageFileDriver.h index 39e1f7b5..22eab6eb 100755 --- a/src/RageFileDriver.h +++ b/src/RageFileDriver.h @@ -10,7 +10,7 @@ { \ FileDriverEntry_##name(): FileDriverEntry( type ) { } \ RageFileDriver *Create( const CString &sRoot ) const { return new RageFileDriver##name( sRoot ); } \ - } const g_RegisterDriver; + } const g_Register##name##Driver; class RageFileBasic; class FilenameDB; diff --git a/src/RageFileDriverDirect.cpp b/src/RageFileDriverDirect.cpp index fe216d82..a3bb269f 100755 --- a/src/RageFileDriverDirect.cpp +++ b/src/RageFileDriverDirect.cpp @@ -21,6 +21,7 @@ #endif REGISTER_FILE_DRIVER( Direct, "DIR" ); +REGISTER_FILE_DRIVER( DirectReadOnly, "DIRRO" ); // 64 KB buffer static const unsigned int BUFFER_SIZE = 1024*64; @@ -124,6 +125,24 @@ bool RageFileDriverDirect::Remove( const CString &sPath_ ) } } +/* The DIRRO driver is just like DIR, except writes are disallowed. */ +RageFileDriverDirectReadOnly::RageFileDriverDirectReadOnly( const CString &sRoot ) : + RageFileDriverDirect( sRoot ) { } + +RageFileBasic *RageFileDriverDirectReadOnly::Open( const CString &sPath, int iMode, int &iError ) +{ + if( iMode & RageFile::WRITE ) + { + iError = EROFS; + return NULL; + } + + return RageFileDriverDirect::Open( sPath, iMode, iError ); +} +bool RageFileDriverDirectReadOnly::Move( const CString &sOldPath, const CString &sNewPath ) { return false; } +bool RageFileDriverDirectReadOnly::Remove( const CString &sPath ) { return false; } + + bool RageFileObjDirect::OpenInternal( const CString &sPath, int iMode, int &iError ) { m_sPath = sPath; diff --git a/src/RageFileDriverDirect.h b/src/RageFileDriverDirect.h index efa45cec..3f86e210 100755 --- a/src/RageFileDriverDirect.h +++ b/src/RageFileDriverDirect.h @@ -60,6 +60,15 @@ protected: CString m_sRoot; }; +class RageFileDriverDirectReadOnly: public RageFileDriverDirect +{ +public: + RageFileDriverDirectReadOnly( const CString &sRoot ); + RageFileBasic *Open( const CString &sPath, int iMode, int &iError ); + bool Move( const CString &sOldPath, const CString &sNewPath ); + bool Remove( const CString &sPath ); +}; + #endif /* diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 07c6aeeb..63e1c0d6 100755 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -1058,7 +1058,7 @@ int main(int argc, char* argv[]) if( IsADirectory(PATCH_DATA_DIR) ) { LOG->Info( "VFS: mounting Data/patch/patch/." ); - FILEMAN->Mount( "dir", PATCH_DATA_DIR, "/", false ); + FILEMAN->Mount( "dirro", PATCH_DATA_DIR, "/", false ); } else if( IsAFile(PATCH_FILE) ) { diff --git a/src/arch/ArchHooks/ArchHooks_Unix.cpp b/src/arch/ArchHooks/ArchHooks_Unix.cpp index 46380415..025e2e9a 100755 --- a/src/arch/ArchHooks/ArchHooks_Unix.cpp +++ b/src/arch/ArchHooks/ArchHooks_Unix.cpp @@ -56,11 +56,11 @@ void ArchHooks_Unix::MountInitialFilesystems( const CString &sDirOfExecutable ) { /* Mount the root filesystem, so we can read files in /proc, /etc, and so on. * This is /rootfs, not /root, to avoid confusion with root's home directory. */ - FILEMAN->Mount( "dir", "/", "/rootfs" ); + FILEMAN->Mount( "dirro", "/", "/rootfs" ); /* Mount /proc, so Alsa9Buf::GetSoundCardDebugInfo() and others can access it. * (Deprecated; use rootfs.) */ - FILEMAN->Mount( "dir", "/proc", "/proc" ); + FILEMAN->Mount( "dirro", "/proc", "/proc" ); /* FileDB cannot accept relative paths, so Root must be absolute */ /* using DirOfExecutable for now --infamouspat */ -- 2.11.0