OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lowlevelfile.hpp
Go to the documentation of this file.
1 #ifndef COMPONENTS_FILES_LOWLEVELFILE_HPP
2 #define COMPONENTS_FILES_LOWLEVELFILE_HPP
3 
4 #include <cstdlib>
5 
6 #define FILE_API_STDIO 0
7 #define FILE_API_POSIX 1
8 #define FILE_API_WIN32 2
9 
10 #if defined(__linux) || defined(__unix) || defined(__posix)
11 #define FILE_API FILE_API_POSIX
12 #elif defined(_WIN32)
13 #define FILE_API FILE_API_WIN32
14 #else
15 #define FILE_API FILE_API_STDIO
16 #endif
17 
18 #if FILE_API == FILE_API_STDIO
19 #include <cstdio>
20 #elif FILE_API == FILE_API_POSIX
21 #elif FILE_API == FILE_API_WIN32
22 #include <windows.h>
23 #else
24 #error Unsupported File API
25 #endif
26 
28 {
29 public:
30 
31  LowLevelFile ();
32  ~LowLevelFile ();
33 
34  void open (char const * filename);
35  void close ();
36 
37  size_t size ();
38 
39  void seek (size_t Position);
40  size_t tell ();
41 
42  size_t read (void * data, size_t size);
43 
44 private:
45 #if FILE_API == FILE_API_STDIO
46  FILE* mHandle;
47 #elif FILE_API == FILE_API_POSIX
48  int mHandle;
49 #elif FILE_API == FILE_API_WIN32
50  HANDLE mHandle;
51 #endif
52 };
53 
54 #endif
Definition: lowlevelfile.hpp:27
void close()
Definition: lowlevelfile.cpp:47
void seek(size_t Position)
Definition: lowlevelfile.cpp:79
size_t size()
Definition: lowlevelfile.cpp:56
size_t read(void *data, size_t size)
Definition: lowlevelfile.cpp:99
size_t tell()
Definition: lowlevelfile.cpp:87
~LowLevelFile()
Definition: lowlevelfile.cpp:27
void open(char const *filename)
Definition: lowlevelfile.cpp:33
FILE * mHandle
Definition: lowlevelfile.hpp:46
LowLevelFile()
Definition: lowlevelfile.cpp:22