OSDN Git Service

[Qt][X1][General] Fix FILEIO::IsFileExists(). Fixed non-start X1 series when not...
[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_WRITE_APPEND_ASCII       9
33 #define FILEIO_READ_WRITE_APPEND_ASCII  10
34 #define FILEIO_SEEK_SET                 0
35 #define FILEIO_SEEK_CUR                 1
36 #define FILEIO_SEEK_END                 2
37
38 class FILEIO
39 {
40 private:
41         FILE* fp;
42         
43 public:
44         FILEIO();
45         ~FILEIO();
46
47         static bool IsFileExists(const _TCHAR *file_path);
48         static bool IsFileProtected(const _TCHAR *file_path);
49         static bool RemoveFile(const _TCHAR *file_path);
50         static bool FILEIO::RenameFile(const _TCHAR *existing_file_path, const _TCHAR *new_file_path);
51
52         bool Fopen(const _TCHAR *file_path, int mode);
53         void Fclose();
54         bool IsOpened() { return (fp != NULL); }
55         uint32 FileLength();
56         
57         bool FgetBool();
58         void FputBool(bool val);
59         uint8 FgetUint8();
60         void FputUint8(uint8 val);
61         uint16 FgetUint16();
62         void FputUint16(uint16 val);
63         uint32 FgetUint32();
64         void FputUint32(uint32 val);
65         uint64 FgetUint64();
66         void FputUint64(uint64 val);
67         int8 FgetInt8();
68         void FputInt8(int8 val);
69         int16 FgetInt16();
70         void FputInt16(int16 val);
71         int32 FgetInt32();
72         void FputInt32(int32 val);
73         int64 FgetInt64();
74         void FputInt64(int64 val);
75         float FgetFloat();
76         void FputFloat(float val);
77         double FgetDouble();
78         void FputDouble(double val);
79         
80         uint16 FgetUint16_LE();
81         void FputUint16_LE(uint16 val);
82         uint32 FgetUint32_LE();
83         void FputUint32_LE(uint32 val);
84         uint64 FgetUint64_LE();
85         void FputUint64_LE(uint64 val);
86         int16 FgetInt16_LE();
87         void FputInt16_LE(int16 val);
88         int32 FgetInt32_LE();
89         void FputInt32_LE(int32 val);
90         int64 FgetInt64_LE();
91         void FputInt64_LE(int64 val);
92         
93         uint16 FgetUint16_BE();
94         void FputUint16_BE(uint16 val);
95         uint32 FgetUint32_BE();
96         void FputUint32_BE(uint32 val);
97         uint64 FgetUint64_BE();
98         void FputUint64_BE(uint64 val);
99         int16 FgetInt16_BE();
100         void FputInt16_BE(int16 val);
101         int32 FgetInt32_BE();
102         void FputInt32_BE(int32 val);
103         int64 FgetInt64_BE();
104         void FputInt64_BE(int64 val);
105         
106         int Fgetc();
107         int Fputc(int c);
108         char *Fgets(char *str, int n);
109         int Fprintf(const char* format, ...);
110         
111         uint32 Fread(void* buffer, uint32 size, uint32 count);
112         uint32 Fwrite(void* buffer, uint32 size, uint32 count);
113         uint32 Fseek(long offset, int origin);
114         uint32 Ftell();
115 };
116
117 #endif