OSDN Git Service

[Build][UI][Qt] Building has passed from compiler.
[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 #ifdef _USE_AGAR\r
14 #include <agar/core.h>\r
15 #elif defined(_USE_QT)\r
16 #include <QtCore/QFile>\r
17 #include <QtCore/QFileInfo>\r
18 #else\r
19 #include <windows.h>\r
20 #endif\r
21 \r
22 #include <stdio.h>\r
23 #include "common.h"\r
24 \r
25 #define FILEIO_READ_BINARY              1\r
26 #define FILEIO_WRITE_BINARY             2\r
27 #define FILEIO_READ_WRITE_BINARY        3\r
28 #define FILEIO_READ_WRITE_NEW_BINARY    4\r
29 #define FILEIO_READ_ASCII               5\r
30 #define FILEIO_WRITE_ASCII              6\r
31 #define FILEIO_READ_WRITE_ASCII         7\r
32 #define FILEIO_READ_WRITE_NEW_ASCII     8\r
33 #define FILEIO_SEEK_SET                 0\r
34 #define FILEIO_SEEK_CUR                 1\r
35 #define FILEIO_SEEK_END                 2\r
36 \r
37 #if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)\r
38 inline FILE* _tfopen(const _TCHAR *filename , const _TCHAR *mode)\r
39 {\r
40    return fopen((const char *)filename, (const char *)mode);\r
41 }\r
42 #endif\r
43 \r
44 class FILEIO\r
45 {\r
46 private:\r
47 #if defined(_USE_QT)\r
48        QFile* fp;\r
49 #else\r
50        FILE* fp;\r
51 #endif  \r
52 public:\r
53         FILEIO();\r
54         ~FILEIO();\r
55         bool IsFileExists(_TCHAR *filename);\r
56         bool IsProtected(_TCHAR *filename);\r
57         bool Fopen(_TCHAR *filename, int mode);\r
58         void Fclose();\r
59         bool IsOpened() { return (fp != NULL); }\r
60         bool FgetBool();\r
61         void FputBool(bool val);\r
62         uint8 FgetUint8();\r
63         void FputUint8(uint8 val);\r
64         uint16 FgetUint16();\r
65         void FputUint16(uint16 val);\r
66         uint32 FgetUint32();\r
67         void FputUint32(uint32 val);\r
68         uint64 FgetUint64();\r
69         void FputUint64(uint64 val);\r
70         int8 FgetInt8();\r
71         void FputInt8(int8 val);\r
72         int16 FgetInt16();\r
73         void FputInt16(int16 val);\r
74         int32 FgetInt32();\r
75         void FputInt32(int32 val);\r
76         int64 FgetInt64();\r
77         void FputInt64(int64 val);\r
78         float FgetFloat();\r
79         void FputFloat(float val);\r
80         double FgetDouble();\r
81         void FputDouble(double val);\r
82         int Fgetc();\r
83         int Fputc(int c);\r
84         uint32 Fread(void* buffer, uint32 size, uint32 count);\r
85         uint32 Fwrite(void* buffer, uint32 size, uint32 count);\r
86         uint32 Fseek(long offset, int origin);\r
87         uint32 Ftell();\r
88         void Remove(_TCHAR *filename);\r
89 };\r
90 \r
91 #endif\r