OpenMW
|
00001 #ifndef COMPONENTS_FILES_LOWLEVELFILE_HPP 00002 #define COMPONENTS_FILES_LOWLEVELFILE_HPP 00003 00004 #include <OgrePlatform.h> 00005 00006 #include <cstdlib> 00007 00008 #define FILE_API_STDIO 0 00009 #define FILE_API_POSIX 1 00010 #define FILE_API_WIN32 2 00011 00012 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX 00013 #define FILE_API FILE_API_POSIX 00014 #elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32 00015 #define FILE_API FILE_API_WIN32 00016 #else 00017 #define FILE_API FILE_API_STDIO 00018 #endif 00019 00020 #if FILE_API == FILE_API_STDIO 00021 #include <cstdio> 00022 #elif FILE_API == FILE_API_POSIX 00023 #elif FILE_API == FILE_API_WIN32 00024 #include <windows.h> 00025 #else 00026 #error Unsupported File API 00027 #endif 00028 00029 class LowLevelFile 00030 { 00031 public: 00032 00033 LowLevelFile (); 00034 ~LowLevelFile (); 00035 00036 void open (char const * filename); 00037 void close (); 00038 00039 size_t size (); 00040 00041 void seek (size_t Position); 00042 size_t tell (); 00043 00044 size_t read (void * data, size_t size); 00045 00046 private: 00047 #if FILE_API == FILE_API_STDIO 00048 FILE* mHandle; 00049 #elif FILE_API == FILE_API_POSIX 00050 int mHandle; 00051 #elif FILE_API == FILE_API_WIN32 00052 HANDLE mHandle; 00053 #endif 00054 }; 00055 00056 #endif