Skip to content

Latest commit

 

History

History
167 lines (134 loc) · 5.31 KB

File metadata and controls

167 lines (134 loc) · 5.31 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//
// __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
// /_//_//_//_/\ /_//_//_//_/\ /_//_//_//_/\ /_//_//_//_/\
// \_/_//_/\\_\/ \_/_//_/\\_\//_/\\_\\_\\_\//_/\\_\\_/_/\/
// /_//_/\/ /_//_/\/ /_/\/ __ /_/\/ __ /_/\/
// /_//_/\/ /_//_/\/ /_//_//_/\ /_//_//_//_/\/
// /_//_/\/ /_//_/\/ /_/\\_\\_\/ /_/\\_\\_\\_\/
// __ /_//_/\/ __ /_//_/\/ /_/\/ __ __ /_/\/
// /_//_//_//_/\ /_//_//_//_/\ /_//_//_//_/\ /_/\/
// \_\\_\\_\\_\/ \_\\_\\_\\_\/ \_\\_\\_\\_\/ \_\/
//
//
// ..:: Interactive Internet Entertainment Platform ::..
//
// (C) 2000-2005, FAN YI PENG. ALL RIGHTS RESERVED
//
// ________________________________________________________________________________________________
//
/// @file IIEP_FileIn.H
/// @brief 文件输入接口类
// ________________________________________________________________________________________________
//
//
// _____________________________________
// | |
// | DATA |
// _____________________________|_____________________________________|____________________________
//
// __________
// __________________________________________| CONFIG |__________________________________________
#pragma once
// ____________________________________________ CONFIG ____________________________________________
//
// __________
// __________________________________________| HEADER |__________________________________________
#include <stdio.h>
#include <string>
#include <IIEP_Def.H>
// ____________________________________________ HEADER ____________________________________________
//
// __________
// __________________________________________| DEFINE |__________________________________________
//
// ___________
// ____/ CFileIn \_______________________________________________________________________________
namespace IIEP
{
/// @brief 文件输入接口类
class CFileIn
{
public:
CFileIn(void);
~CFileIn(void);
bool Open(const char *pcszFileName);
bool Open(const WORD *pcwsFileName);
void Close(void);
DWORD GetFileSize(void) const;
DWORD GetReadPosition(void) const;
bool Seek(long nOffset, long nOrigin = 0); // SEEK_SET = 0 SEEK_CUR = 1 SEEK_END = 2
bool Skip(long nOffset) { return Seek(nOffset, 1); }
DWORD Read(PVOID pDataBuffer, DWORD dwReadSize);
bool ReadB(BYTE &ucData)
{
return (1 == Read(&ucData, 1));
}
bool ReadW(WORD &wData)
{
return (2 == Read(&wData, 2));
}
bool ReadDW(DWORD &dwData)
{
return (4 == Read(&dwData, 4));
}
bool ReadInverseW(WORD &wData)
{
if (2 == Read(&wData, 2))
{
_asm
{
MOV ECX, wData
MOV AX, [ECX]
XCHG AH, AL
MOV [ECX], AX
}
return true;
}
return false;
}
bool ReadInverseDW(DWORD &dwData)
{
if (4 == Read(&dwData, 4))
{
_asm
{
MOV ECX, dwData
MOV EAX, [ECX]
BSWAP EAX
MOV [ECX], EAX
}
return true;
}
return false;
}
// --------------------------------------------------------------------------------------------
bool ReadAnsiLine(std::string &strLine);
bool ReadUnicodeLine(std::wstring &wstrLine, bool bBigEndian);
bool ReadAnsiString (char *pszBuffer, DWORD dwBufferLength);
bool ReadUnicodeString(WORD *pwzBuffer, DWORD dwBufferLength);
// --------------------------------------------------------------------------------------------
private:
CFileIn(const CFileIn &); // forbidden
CFileIn & operator = (const CFileIn &); // forbidden
#include <CORE/CORE_FileIn.H>
};
}
// ______ CFileIn _________________________________________________________________________________
//
// _______________
// ____/ Memory File \___________________________________________________________________________
namespace IIEP
{
bool CreateMemoryFile(PVOID pMemory, DWORD dwLength, const char *pcszFileName);
bool CreateMemoryFile(PVOID pMemory, DWORD dwLength, const WORD *pcwsFileName);
bool RemoveMemoryFile(const char *pcszFileName);
bool RemoveMemoryFile(const WORD *pcwsFileName);
void RemoveMemoryFile(void);
}
// ______ Memory File _____________________________________________________________________________
//
// ____________________________________________ DEFINE ____________________________________________
//
// ____________________________________________________________________________________ DATA ______
//
// ___________________________________________ FILE END ___________________________________________