9 #include <vrecko/Export>
17 #define BUFFILE_INITBUFFERSIZE 65536
18 #define BUFFILE_MINBUFFERSIZE 16384
20 #define BUFFILE_MAXBUFFILESIZE 65536
24 #ifndef INVALID_SET_FILE_POINTER
25 #define INVALID_SET_FILE_POINTER ((DWORD)-1)
29 #define BUFFILE_BEHVF_UNICODE_START_HIDE 0x00000002
30 #define BUFFILE_BEHVF_LOADFILETOMEM 0x00000001
50 bool setBehaviour (DWORD dwBehvFlags);
54 bool init (_TCHAR* lpFileName);
56 bool init (HANDLE hFile,
bool bCallSPF);
61 HANDLE getHandle() {
return hFile; };
65 inline DWORD getFilePos (
void)
const;
70 bool setFilePos (DWORD dwNewFilePos);
74 inline DWORD getMaxPos (
void)
const;
75 inline DWORD getBufSize (
void)
const;
76 inline DWORD getFileSize (
void)
const;
77 void setBufSize (DWORD dwNewSize);
79 bool preReadBytes (DWORD dwNumOfBytes);
82 inline bool readBytes (LPVOID lpDest, DWORD dwBytesToRead);
85 inline bool readBytes (LPVOID lpDest, DWORD dwBytesToRead, LPDWORD lpdwBytesRead) {
95 return readBytesCore(lpDest, dwBytesToRead, lpdwBytesRead);
102 inline BYTE readByte (
void);
105 bool readWCharTrans (WCHAR *wChar);
108 inline bool readBool (
bool *pData) {
return readBytes (pData, 1); };
109 inline bool readByte (BYTE *pData) {
return readBytes (pData, 1); };
110 inline bool readWORD (WORD *pData) {
return readBytes (pData, 2); };
111 inline bool readDWORD (DWORD *pData) {
return readBytes (pData, 4); };
112 inline bool readLONG (LONG *pData) {
return readBytes (pData,
sizeof (LONG)); };
113 inline bool readFloat (
float *pData) {
return readBytes (pData, 4); };
114 inline bool readVec3f (osg::Vec3f *v) {
return readBytes(&v->x(), 4) && readBytes(&v->y(), 4) && readBytes(&v->z(), 4); };
115 inline bool readInt (
int *pData) {
return readBytes (pData, 4); };
116 inline bool readPOINT (POINT *pData) {
return readBytes (pData,
sizeof (POINT)); };
117 inline bool readInt64 (__int64 *pData) {
return readBytes (pData, 8); };
118 inline bool readRECT (RECT *pData) {
return readBytes (pData,
sizeof (RECT)); };
119 inline bool readStr (CHAR *pData);
122 inline bool tReadLine(_TCHAR* tBuffer, PDWORD pdwCharSize) {
return readLineW(tBuffer, pdwCharSize); }
124 inline bool tReadLine(_TCHAR* tBuffer, PDWORD pdwCharSize) {
return readLine(tBuffer, pdwCharSize); }
128 bool readLine (PSTR pBuffer, PDWORD pdwCharSize);
136 bool readLineW (PWSTR pBuffer, PDWORD pdwCharSize);
143 inline bool isEOF (
void) {
return (getFilePos () >= getFileSize ()); }
169 bool readBytesCore(LPVOID lpDest, DWORD dwBytesToRead, LPDWORD lpdwBytesRead);
171 void UNICODECheck (
void);
180 bool init (TCHAR *lpFileName);
184 inline bool write (LPVOID lpBuffer, DWORD dwSize);
197 inline bool writeStr (PSTR pData) {
return write (pData, (DWORD)strlen (pData) + 1); };
238 if (!
readBytes (lpDest, dwBytesToRead, &dw))
240 return (dw == dwBytesToRead);
276 DWORD dwTmp = dwSize;
280 memcpy (
buffer.lpBuffer +
buffer.dwNum, lpBuffer, dwTmp);
283 lpBuffer = (LPVOID)((LPBYTE)lpBuffer + dwTmp);
287 if (FALSE == ::WriteFile (
hFile,
buffer.lpBuffer,
buffer.dwNum, &dwWritten, NULL))