OSDN Git Service

[VM][General] Merge upstream 2016-03-01. (Pahse 1).
[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 #include <stdio.h>
14 #include "common.h"
15
16 #define FILEIO_READ_BINARY              1
17 #define FILEIO_WRITE_BINARY             2
18 #define FILEIO_READ_WRITE_BINARY        3
19 #define FILEIO_READ_WRITE_NEW_BINARY    4
20 #define FILEIO_READ_ASCII               5
21 #define FILEIO_WRITE_ASCII              6
22 #define FILEIO_READ_WRITE_ASCII         7
23 #define FILEIO_READ_WRITE_NEW_ASCII     8
24 #define FILEIO_WRITE_APPEND_ASCII       9
25 #define FILEIO_READ_WRITE_APPEND_ASCII  10
26 #define FILEIO_SEEK_SET                 0
27 #define FILEIO_SEEK_CUR                 1
28 #define FILEIO_SEEK_END                 2
29
30 class FILEIO
31 {
32 private:
33         FILE* fp;
34         
35 public:
36         FILEIO();
37         ~FILEIO();
38
39         static bool IsFileExisting(const _TCHAR *file_path);
40         static bool IsFileProtected(const _TCHAR *file_path);
41         static bool RemoveFile(const _TCHAR *file_path);
42         static bool RenameFile(const _TCHAR *existing_file_path, const _TCHAR *new_file_path);
43
44         bool Fopen(const _TCHAR *file_path, int mode);
45         void Fclose();
46         bool IsOpened() { return (fp != NULL); }
47         uint32_t FileLength();
48         
49         bool FgetBool();
50         void FputBool(bool val);
51         uint8_t FgetUint8();
52         void FputUint8(uint8_t val);
53         uint16_t FgetUint16();
54         void FputUint16(uint16_t val);
55         uint32_t FgetUint32();
56         void FputUint32(uint32_t val);
57         uint64_t FgetUint64();
58         void FputUint64(uint64_t val);
59         int8_t FgetInt8();
60         void FputInt8(int8_t val);
61         int16_t FgetInt16();
62         void FputInt16(int16_t val);
63         int32_t FgetInt32();
64         void FputInt32(int32_t val);
65         int64_t FgetInt64();
66         void FputInt64(int64_t val);
67         float FgetFloat();
68         void FputFloat(float val);
69         double FgetDouble();
70         void FputDouble(double val);
71         
72         uint16_t FgetUint16_LE();
73         void FputUint16_LE(uint16_t val);
74         uint32_t FgetUint32_LE();
75         void FputUint32_LE(uint32_t val);
76         uint64_t FgetUint64_LE();
77         void FputUint64_LE(uint64_t val);
78         int16_t FgetInt16_LE();
79         void FputInt16_LE(int16_t val);
80         int32_t FgetInt32_LE();
81         void FputInt32_LE(int32_t val);
82         int64_t FgetInt64_LE();
83         void FputInt64_LE(int64_t val);
84         
85         uint16_t FgetUint16_BE();
86         void FputUint16_BE(uint16_t val);
87         uint32_t FgetUint32_BE();
88         void FputUint32_BE(uint32_t val);
89         uint64_t FgetUint64_BE();
90         void FputUint64_BE(uint64_t val);
91         int16_t FgetInt16_BE();
92         void FputInt16_BE(int16_t val);
93         int32_t FgetInt32_BE();
94         void FputInt32_BE(int32_t val);
95         int64_t FgetInt64_BE();
96         void FputInt64_BE(int64_t val);
97         
98         int Fgetc();
99         int Fputc(int c);
100         char *Fgets(char *str, int n);
101         int Fprintf(const char* format, ...);
102         
103         uint32_t Fread(void* buffer, uint32_t size, uint32_t count);
104         uint32_t Fwrite(void* buffer, uint32_t size, uint32_t count);
105         uint32_t Fseek(long offset, int origin);
106         uint32_t Ftell();
107 };
108
109 #endif