00001 #include "file.hpp" 00002 00003 00005 00006 ADRFileSystem::ADRFileSystem( 00007 void* opaque, 00008 ADR_FILE_OPEN open, 00009 ADR_FILE_CLOSE close, 00010 ADR_FILE_READ read, 00011 ADR_FILE_SEEK seek, 00012 ADR_FILE_TELL tell) 00013 { 00014 m_opaque = opaque; 00015 m_open = open; 00016 m_close = close; 00017 m_read = read; 00018 m_seek = seek; 00019 m_tell = tell; 00020 } 00021 00023 00024 IFile* 00025 ADRFileSystem::Open(const char* filename) 00026 { 00027 ADR_FILE file = m_open(m_opaque, filename); 00028 return (file ? new ADRFile(this, file) : 0); 00029 } 00030 00032 00033 ADRFile::ADRFile(ADRFileSystem* file_system, ADR_FILE file) 00034 { 00035 m_file_system = file_system; 00036 m_file = file; 00037 } 00038 00040 00041 ADRFile::~ADRFile() 00042 { 00043 m_file_system->m_close(m_file); 00044 } 00045 00047 00048 int 00049 ADRFile::Read(void* bytes, int byte_count) 00050 { 00051 return m_file_system->m_read(m_file, bytes, byte_count); 00052 } 00053 00055 00056 bool 00057 ADRFile::Seek(int offset, ADR_SEEK_TYPE type) 00058 { 00059 return (m_file_system->m_seek(m_file, offset, type) == ADR_TRUE); 00060 } 00061 00063 00064 int 00065 ADRFile::Tell() 00066 { 00067 return m_file_system->m_tell(m_file); 00068 } 00069