00001 #ifndef FILE_HPP 00002 #define FILE_HPP 00003 00004 00005 #include "audiere.h" 00006 00007 00008 class IFile 00009 { 00010 public: 00011 virtual ~IFile() { } 00012 00013 virtual int Read(void* bytes, int byte_count) = 0; 00014 virtual bool Seek(int offset, ADR_SEEK_TYPE type) = 0; 00015 virtual int Tell() = 0; 00016 }; 00017 00018 00019 class IFileSystem 00020 { 00021 public: 00022 virtual IFile* Open(const char* filename) = 0; 00023 }; 00024 00025 00026 class ADRFile; 00027 00028 00029 class ADRFileSystem : public IFileSystem 00030 { 00031 public: 00032 ADRFileSystem( 00033 void* opaque, 00034 ADR_FILE_OPEN open, 00035 ADR_FILE_CLOSE close, 00036 ADR_FILE_READ read, 00037 ADR_FILE_SEEK seek, 00038 ADR_FILE_TELL tell); 00039 00040 IFile* Open(const char* filename); 00041 00042 private: 00043 void* m_opaque; 00044 ADR_FILE_OPEN m_open; 00045 ADR_FILE_CLOSE m_close; 00046 ADR_FILE_READ m_read; 00047 ADR_FILE_SEEK m_seek; 00048 ADR_FILE_TELL m_tell; 00049 00050 friend class ADRFile; 00051 }; 00052 00053 00054 class ADRFile : public IFile 00055 { 00056 public: 00057 ADRFile(ADRFileSystem* file_system, ADR_FILE file); 00058 ~ADRFile(); 00059 00060 int Read(void* bytes, int byte_count); 00061 bool Seek(int offset, ADR_SEEK_TYPE type); 00062 int Tell(); 00063 00064 private: 00065 ADRFileSystem* m_file_system; 00066 ADR_FILE m_file; 00067 00068 friend class ADRFileSystem; 00069 }; 00070 00071 00072 #endif