00001 /* RageFileDriver, RageFileObj: Low-level file access driver classes. */ 00002 00003 #ifndef RAGE_FILE_DRIVER_H 00004 #define RAGE_FILE_DRIVER_H 00005 00006 #include "RageFile.h" 00007 #include "RageFileManager.h" 00008 00009 class RageFileObj; 00010 class FilenameDB; 00011 class RageFileDriver 00012 { 00013 public: 00014 RageFileDriver( FilenameDB *db ) { FDB = db; } 00015 virtual ~RageFileDriver(); 00016 virtual RageFileBasic *Open( const CString &path, int mode, int &err ) = 0; 00017 virtual void GetDirListing( const CString &sPath, CStringArray &AddTo, bool bOnlyDirs, bool bReturnPathToo ); 00018 virtual RageFileManager::FileType GetFileType( const CString &sPath ); 00019 virtual int GetFileSizeInBytes( const CString &sFilePath ); 00020 virtual int GetFileHash( const CString &sPath ); 00021 virtual int GetPathValue( const CString &path ); 00022 virtual bool Ready() { return true; } /* see RageFileManager::MountpointIsReady */ 00023 virtual void FlushDirCache( const CString &sPath ); 00024 virtual bool Remove( const CString &sPath ) { return false; } 00025 00026 /* Optional: Move to a different place, as if reconstructed with a different path. */ 00027 virtual bool Remount( const CString &sPath ) { return false; } 00028 00029 /* Possible error returns from Open, in addition to standard errno.h values: */ 00030 enum { ERROR_WRITING_NOT_SUPPORTED = -1 }; 00031 // protected: 00032 FilenameDB *FDB; 00033 }; 00034 00035 /* This is used to register the driver, so RageFileManager can see it. */ 00036 struct FileDriverEntry 00037 { 00038 FileDriverEntry( CString Type ); 00039 virtual ~FileDriverEntry(); 00040 virtual RageFileDriver *Create( CString Root ) const = 0; 00041 00042 CString m_Type; 00043 const FileDriverEntry *m_Link; 00044 }; 00045 RageFileDriver *MakeFileDriver( CString Type, CString Root ); 00046 00047 #endif 00048 00049 /* 00050 * Copyright (c) 2003-2004 Glenn Maynard 00051 * All rights reserved. 00052 * 00053 * Permission is hereby granted, free of charge, to any person obtaining a 00054 * copy of this software and associated documentation files (the 00055 * "Software"), to deal in the Software without restriction, including 00056 * without limitation the rights to use, copy, modify, merge, publish, 00057 * distribute, and/or sell copies of the Software, and to permit persons to 00058 * whom the Software is furnished to do so, provided that the above 00059 * copyright notice(s) and this permission notice appear in all copies of 00060 * the Software and that both the above copyright notice(s) and this 00061 * permission notice appear in supporting documentation. 00062 * 00063 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00064 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00065 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00066 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00067 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00068 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00069 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00070 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00071 * PERFORMANCE OF THIS SOFTWARE. 00072 */