OSDN Git Service

[Build][VM][Agar][General] Compilation of common routines.
[csp-qt/common_source_project-fm7.git] / source / src / fileio.h
1 /*\r
2         Skelton for retropc emulator\r
3 \r
4         Author : Takeda.Toshiya\r
5         Date   : 2006.08.18 -\r
6 \r
7         [ file i/o ]\r
8 */\r
9 \r
10 #ifndef _FILEIO_H_\r
11 #define _FILEIO_H_\r
12 \r
13 #ifndef _USE_AGAR\r
14 #include <windows.h>\r
15 #else\r
16 #include <agar/core.h>\r
17 #endif\r
18 \r
19 #include <stdio.h>\r
20 #include "common.h"\r
21 \r
22 #define FILEIO_READ_BINARY              1\r
23 #define FILEIO_WRITE_BINARY             2\r
24 #define FILEIO_READ_WRITE_BINARY        3\r
25 #define FILEIO_READ_WRITE_NEW_BINARY    4\r
26 #define FILEIO_READ_ASCII               5\r
27 #define FILEIO_WRITE_ASCII              6\r
28 #define FILEIO_READ_WRITE_ASCII         7\r
29 #define FILEIO_READ_WRITE_NEW_ASCII     8\r
30 #define FILEIO_SEEK_SET                 0\r
31 #define FILEIO_SEEK_CUR                 1\r
32 #define FILEIO_SEEK_END                 2\r
33 \r
34 #if defined(_USE_AGAR) || defined(_USE_SDL)\r
35 inline FILE* _tfopen(const _TCHAR *filename , const _TCHAR *mode)\r
36 {\r
37    return fopen((const char *)filename, (const char *)mode);\r
38 }\r
39 #endif\r
40 \r
41 class FILEIO\r
42 {\r
43 private:\r
44         FILE* fp;\r
45         \r
46 public:\r
47         FILEIO();\r
48         ~FILEIO();\r
49         bool IsFileExists(_TCHAR *filename);\r
50         bool IsProtected(_TCHAR *filename);\r
51         bool Fopen(_TCHAR *filename, int mode);\r
52         void Fclose();\r
53         bool IsOpened() { return (fp != NULL); }\r
54         bool FgetBool();\r
55         void FputBool(bool val);\r
56         uint8 FgetUint8();\r
57         void FputUint8(uint8 val);\r
58         uint16 FgetUint16();\r
59         void FputUint16(uint16 val);\r
60         uint32 FgetUint32();\r
61         void FputUint32(uint32 val);\r
62         uint64 FgetUint64();\r
63         void FputUint64(uint64 val);\r
64         int8 FgetInt8();\r
65         void FputInt8(int8 val);\r
66         int16 FgetInt16();\r
67         void FputInt16(int16 val);\r
68         int32 FgetInt32();\r
69         void FputInt32(int32 val);\r
70         int64 FgetInt64();\r
71         void FputInt64(int64 val);\r
72         float FgetFloat();\r
73         void FputFloat(float val);\r
74         double FgetDouble();\r
75         void FputDouble(double val);\r
76         int Fgetc();\r
77         int Fputc(int c);\r
78         uint32 Fread(void* buffer, uint32 size, uint32 count);\r
79         uint32 Fwrite(void* buffer, uint32 size, uint32 count);\r
80         uint32 Fseek(long offset, int origin);\r
81         uint32 Ftell();\r
82         void Remove(_TCHAR *filename);\r
83 };\r
84 \r
85 #endif\r