OSDN Git Service

[VM][General] Merge upstream 2015-08-25.
[csp-qt/common_source_project-fm7.git] / source / src / fileio.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2006.08.18 -
6
7         [ file i/o ]
8 */
9
10 #ifndef _FILEIO_H_
11 #define _FILEIO_H_
12
13 #ifdef _USE_AGAR
14 #include <agar/core.h>
15 #elif defined(_USE_QT)
16 #include <QtCore/QFile>
17 #include <QtCore/QFileInfo>
18 #else
19 #include <windows.h>
20 #endif
21 #include <stdio.h>
22 #include "common.h"
23
24 #define FILEIO_READ_BINARY              1
25 #define FILEIO_WRITE_BINARY             2
26 #define FILEIO_READ_WRITE_BINARY        3
27 #define FILEIO_READ_WRITE_NEW_BINARY    4
28 #define FILEIO_READ_ASCII               5
29 #define FILEIO_WRITE_ASCII              6
30 #define FILEIO_READ_WRITE_ASCII         7
31 #define FILEIO_READ_WRITE_NEW_ASCII     8
32 #define FILEIO_SEEK_SET                 0
33 #define FILEIO_SEEK_CUR                 1
34 #define FILEIO_SEEK_END                 2
35
36 class FILEIO
37 {
38 private:
39         FILE* fp;
40         
41 public:
42         FILEIO();
43         ~FILEIO();
44
45         static bool IsFileExists(const _TCHAR *filename);
46         static bool IsFileProtected(const _TCHAR *filename);
47         static void RemoveFile(const _TCHAR *filename);
48
49         bool Fopen(const _TCHAR *filename, int mode);
50         void Fclose();
51         bool IsOpened() { return (fp != NULL); }
52         
53         bool FgetBool();
54         void FputBool(bool val);
55         uint8 FgetUint8();
56         void FputUint8(uint8 val);
57         uint16 FgetUint16();
58         void FputUint16(uint16 val);
59         uint32 FgetUint32();
60         void FputUint32(uint32 val);
61         uint64 FgetUint64();
62         void FputUint64(uint64 val);
63         int8 FgetInt8();
64         void FputInt8(int8 val);
65         int16 FgetInt16();
66         void FputInt16(int16 val);
67         int32 FgetInt32();
68         void FputInt32(int32 val);
69         int64 FgetInt64();
70         void FputInt64(int64 val);
71         float FgetFloat();
72         void FputFloat(float val);
73         double FgetDouble();
74         void FputDouble(double val);
75         
76         uint16 FgetUint16_LE();
77         void FputUint16_LE(uint16 val);
78         uint32 FgetUint32_LE();
79         void FputUint32_LE(uint32 val);
80         uint64 FgetUint64_LE();
81         void FputUint64_LE(uint64 val);
82         int16 FgetInt16_LE();
83         void FputInt16_LE(int16 val);
84         int32 FgetInt32_LE();
85         void FputInt32_LE(int32 val);
86         int64 FgetInt64_LE();
87         void FputInt64_LE(int64 val);
88         
89         uint16 FgetUint16_BE();
90         void FputUint16_BE(uint16 val);
91         uint32 FgetUint32_BE();
92         void FputUint32_BE(uint32 val);
93         uint64 FgetUint64_BE();
94         void FputUint64_BE(uint64 val);
95         int16 FgetInt16_BE();
96         void FputInt16_BE(int16 val);
97         int32 FgetInt32_BE();
98         void FputInt32_BE(int32 val);
99         int64 FgetInt64_BE();
100         void FputInt64_BE(int64 val);
101         
102         int Fgetc();
103         int Fputc(int c);
104         char *Fgets(char *str, int n);
105         int Fprintf(const char* format, ...);
106         
107         uint32 Fread(void* buffer, uint32 size, uint32 count);
108         uint32 Fwrite(void* buffer, uint32 size, uint32 count);
109         uint32 Fseek(long offset, int origin);
110         uint32 Ftell();
111 };
112
113 #endif