added read-only direct file driver, re-derived crypto drivers off of it
authorMark Cannon <vyhdycokio@gmail.com>
Thu, 7 Oct 2010 03:31:20 +0000 (03:31 +0000)
committerMark Cannon <vyhdycokio@gmail.com>
Thu, 7 Oct 2010 03:31:20 +0000 (03:31 +0000)
git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg/branches/dev@854 83fadc84-e282-4d84-a09a-c4228d6ae7e5

src/RageFileDriver.h
src/RageFileDriverDirect.cpp
src/RageFileDriverDirect.h
src/StepMania.cpp
src/arch/ArchHooks/ArchHooks_Unix.cpp

index 39e1f7b..22eab6e 100755 (executable)
@@ -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;
index fe216d8..a3bb269 100755 (executable)
@@ -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;
index efa45ce..3f86e21 100755 (executable)
@@ -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
 
 /*
index 07c6aee..63e1c0d 100755 (executable)
@@ -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) )
        {
index 4638041..025e2e9 100755 (executable)
@@ -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 */