svn-gvsig-desktop / branches / v1_0_2 / libraries / libjni-ecwcompress / include / include-sdk / NCSFileIO.h @ 39946
History | View | Annotate | Download (8.92 KB)
1 | 3538 | nacho | /********************************************************
|
---|---|---|---|
2 | ** Copyright 1999 Earth Resource Mapping Ltd.
|
||
3 | ** This document contains proprietary source code of
|
||
4 | ** Earth Resource Mapping Ltd, and can only be used under
|
||
5 | ** one of the three licenses as described in the
|
||
6 | ** license.txt file supplied with this distribution.
|
||
7 | ** See separate license.txt file for license details
|
||
8 | ** and conditions.
|
||
9 | **
|
||
10 | ** This software is covered by US patent #6,442,298,
|
||
11 | ** #6,102,897 and #6,633,688. Rights to use these patents
|
||
12 | ** is included in the license agreements.
|
||
13 | **
|
||
14 | ** FILE: include\NCSFileIO.h
|
||
15 | ** CREATED: Tue 09/14/1999
|
||
16 | ** AUTHOR: Simon Cope
|
||
17 | ** PURPOSE: 64bit file IO wrapper function header
|
||
18 | ** EDITS:
|
||
19 | ** [01] sjc 24Feb00 Added NCSGetFileVersion() call to return file version
|
||
20 | ** [02] sjc 30Apr00 Merged Mac SDK port
|
||
21 | ** [03] ny 30Oct00 Merged WinCE/Palm SDK port
|
||
22 | *******************************************************/
|
||
23 | |||
24 | #ifndef NCSFILEIO_H
|
||
25 | #define NCSFILEIO_H
|
||
26 | |||
27 | #ifdef __cplusplus
|
||
28 | extern "C" { |
||
29 | #endif
|
||
30 | |||
31 | #ifndef NCSTYPES_H
|
||
32 | #include "NCSTypes.h" |
||
33 | #endif
|
||
34 | #ifndef NCSMALLOC_H
|
||
35 | #include "NCSMalloc.h" |
||
36 | #endif
|
||
37 | |||
38 | #ifndef NCSERRORS_H
|
||
39 | #include "NCSErrors.h" |
||
40 | #endif
|
||
41 | |||
42 | #ifdef LINUX
|
||
43 | #define __USE_FILE_OFFSET64
|
||
44 | //#define __USE_LARGEFILE64
|
||
45 | #endif
|
||
46 | |||
47 | #ifdef WIN32
|
||
48 | |||
49 | #if !defined(_WIN32_WCE) //Pocket PC 2002 |
||
50 | #include <io.h> |
||
51 | #include <fcntl.h> |
||
52 | #endif
|
||
53 | |||
54 | #elif defined PALM
|
||
55 | |||
56 | #include <FileStream.h> |
||
57 | |||
58 | #elif defined _WIN32_WCE
|
||
59 | |||
60 | #include <stdlib.h> |
||
61 | |||
62 | #elif defined MACINTOSH
|
||
63 | |||
64 | #include <stdlib.h> |
||
65 | #include <fcntl.h> |
||
66 | |||
67 | #elif defined SOLARIS || defined HPUX || defined LINUX
|
||
68 | |||
69 | #include <sys/types.h> |
||
70 | #include <unistd.h> |
||
71 | #include <strings.h> |
||
72 | |||
73 | #endif
|
||
74 | |||
75 | |||
76 | #ifdef WIN32
|
||
77 | #ifndef _WIN32_WCE
|
||
78 | |||
79 | #include <sys/types.h> |
||
80 | #include <sys/stat.h> |
||
81 | |||
82 | #else /* _WIN32_WCE */ |
||
83 | |||
84 | //#if (_WIN32_WCE < 300) //< Pocket PC 2002
|
||
85 | #define NO_STDIO
|
||
86 | //#endif
|
||
87 | |||
88 | #endif /* _WIN32_WCE */ |
||
89 | |||
90 | #define NCS_FILE_SEP "\\" |
||
91 | |||
92 | #elif defined MACINTOSH
|
||
93 | |||
94 | #include <types.h> |
||
95 | #include <stat.h> |
||
96 | |||
97 | #define NCS_FILE_SEP "/" |
||
98 | |||
99 | #elif defined PALM
|
||
100 | |||
101 | #include <PalmTypes.h> |
||
102 | #define NO_STDIO
|
||
103 | |||
104 | #define NCS_FILE_SEP "/" |
||
105 | |||
106 | #elif defined SOLARIS || defined HPUX || defined LINUX
|
||
107 | |||
108 | #include <sys/types.h> |
||
109 | #include <sys/stat.h> |
||
110 | #include <fcntl.h> |
||
111 | #include <stdlib.h> |
||
112 | |||
113 | #define NCS_FILE_SEP "/" |
||
114 | |||
115 | #elif defined MACOSX
|
||
116 | #include <sys/types.h> |
||
117 | #include <sys/stat.h> |
||
118 | #include <fcntl.h> |
||
119 | #include <stdlib.h> |
||
120 | |||
121 | #define NCS_FILE_SEP "/" |
||
122 | |||
123 | #else /* WIN32 */ |
||
124 | |||
125 | #error - need to include types.h and stat.h for this platform |
||
126 | |||
127 | #endif /* WIN32 */ |
||
128 | |||
129 | |||
130 | #ifndef PALM
|
||
131 | #include <stdio.h> |
||
132 | #endif /* PALM */ |
||
133 | |||
134 | #define NCS_FILE_READ (1 << 0) |
||
135 | #define NCS_FILE_READ_WRITE (1 << 1) |
||
136 | #define NCS_FILE_CREATE (1 << 2) |
||
137 | #define NCS_FILE_CREATE_UNIQUE (1 << 3) |
||
138 | #define NCS_FILE_APPEND (1 << 4) |
||
139 | #define NCS_FILE_TEMPORARY (1 << 5) |
||
140 | #define NCS_FILE_ASYNCIO (1 << 6) |
||
141 | |||
142 | #ifdef WIN32
|
||
143 | |||
144 | typedef HANDLE NCS_FILE_HANDLE;
|
||
145 | #define NCS_NULL_FILE_HANDLE NULL |
||
146 | typedef DWORD NCS_FILE_ORIGIN;
|
||
147 | #define NCS_FILE_SEEK_START FILE_BEGIN
|
||
148 | #define NCS_FILE_SEEK_CURRENT FILE_CURRENT
|
||
149 | #define NCS_FILE_SEEK_END FILE_END
|
||
150 | |||
151 | #elif defined MACINTOSH
|
||
152 | |||
153 | typedef INT16 NCS_FILE_HANDLE;
|
||
154 | #define NCS_NULL_FILE_HANDLE NULL |
||
155 | |||
156 | typedef enum { |
||
157 | NCS_FILE_SEEK_START = 0,
|
||
158 | NCS_FILE_SEEK_CURRENT = 1,
|
||
159 | NCS_FILE_SEEK_END = 2
|
||
160 | } NCS_FILE_ORIGIN; |
||
161 | |||
162 | #elif defined PALM
|
||
163 | |||
164 | typedef HANDLE NCS_FILE_HANDLE;
|
||
165 | typedef DWORD NCS_FILE_ORIGIN;
|
||
166 | #define NCS_FILE_SEEK_START FILE_BEGIN
|
||
167 | #define NCS_FILE_SEEK_CURRENT FILE_CURRENT
|
||
168 | #define NCS_FILE_SEEK_END FILE_END
|
||
169 | |||
170 | typedef struct NCS_FILE_HANDLE_STRUCT { |
||
171 | LocalID dbID; // Local DB ID
|
||
172 | DmOpenRef dbRef; // DB Ref handle
|
||
173 | UINT16 nRecordSize;// Size of records
|
||
174 | UINT16 nRecords; // Nr of Records
|
||
175 | UINT32 nDBSize; // Total DB Data size
|
||
176 | UINT32 iOffset; // Current offset
|
||
177 | |||
178 | // Cached current record
|
||
179 | UINT16 iRecord; // Index of current record
|
||
180 | MemHandle hRecord; // Handle of current record
|
||
181 | MemPtr pData; // Data in current record
|
||
182 | } *NCS_FILE_HANDLE; |
||
183 | |||
184 | typedef enum { |
||
185 | NCS_FILE_SEEK_START = 0,
|
||
186 | NCS_FILE_SEEK_CURRENT = 1,
|
||
187 | NCS_FILE_SEEK_END = 2
|
||
188 | } NCS_FILE_ORIGIN; |
||
189 | |||
190 | #else /* PALM */ |
||
191 | |||
192 | /* STDIO */
|
||
193 | typedef int NCS_FILE_HANDLE; |
||
194 | #define NCS_NULL_FILE_HANDLE -1 |
||
195 | typedef int NCS_FILE_ORIGIN; |
||
196 | #define NCS_FILE_SEEK_START SEEK_SET
|
||
197 | #define NCS_FILE_SEEK_CURRENT SEEK_CUR
|
||
198 | #define NCS_FILE_SEEK_END SEEK_END
|
||
199 | |||
200 | #endif /* WIN32 */ |
||
201 | |||
202 | INT64 NCSFileSeekNative(NCS_FILE_HANDLE handle, INT64 offset, NCS_FILE_ORIGIN origin); |
||
203 | INT64 NCSFileTellNative(NCS_FILE_HANDLE handle); |
||
204 | |||
205 | #if defined(NO_STDIO)||defined(SOLARIS)||defined(IRIX)||defined(HPUX)||defined(LINUX)
|
||
206 | #define NCSFileSeek NCSFileSeekNative
|
||
207 | #define NCSFileTell NCSFileTellNative
|
||
208 | #else /* NO_STDIO||SOLARIS||IRIX */ |
||
209 | INT64 NCSFileSeek(int handle, INT64 offset, int origin); |
||
210 | INT64 NCSFileTell(int handle);
|
||
211 | #endif /* NO_STDIO||SOLARIS||IRIX */ |
||
212 | |||
213 | NCSError NCSFileOpen(const char *szFilename, int iFlags, NCS_FILE_HANDLE *phFile); |
||
214 | NCSError NCSFileClose(NCS_FILE_HANDLE handle); |
||
215 | NCSError NCSFileRead(NCS_FILE_HANDLE handle, void* buffer, UINT32 count, UINT32* pRead);
|
||
216 | NCSError NCSFileWrite(NCS_FILE_HANDLE handle, void* buffer, UINT32 count, UINT32* pWrote);
|
||
217 | NCSError NCSFileTouch(NCS_FILE_HANDLE hFile); |
||
218 | NCSError NCSFileFlush(NCS_FILE_HANDLE hFile); |
||
219 | //
|
||
220 | // These routines read/write the specified type from/to a file. The type in the file is the byte order
|
||
221 | // specifiec by the routine name. The value will be swapped to/from the native CPU byte order as
|
||
222 | // appropriate.
|
||
223 | //
|
||
224 | // eg, NCSFileReadUINT16_LSB() - will read a UINT16 (LSB format on disk) from the file, and swap it to
|
||
225 | // the native CPU's byte order.
|
||
226 | //
|
||
227 | NCSError NCSFileReadUINT8_MSB(NCS_FILE_HANDLE hFile, UINT8 *pBuffer); |
||
228 | NCSError NCSFileReadUINT8_LSB(NCS_FILE_HANDLE hFile, UINT8 *pBuffer); |
||
229 | NCSError NCSFileReadUINT16_MSB(NCS_FILE_HANDLE hFile, UINT16 *pBuffer); |
||
230 | NCSError NCSFileReadUINT16_LSB(NCS_FILE_HANDLE hFile, UINT16 *pBuffer); |
||
231 | NCSError NCSFileReadUINT32_MSB(NCS_FILE_HANDLE hFile, UINT32 *pBuffer); |
||
232 | NCSError NCSFileReadUINT32_LSB(NCS_FILE_HANDLE hFile, UINT32 *pBuffer); |
||
233 | NCSError NCSFileReadUINT64_MSB(NCS_FILE_HANDLE hFile, UINT64 *pBuffer); |
||
234 | NCSError NCSFileReadUINT64_LSB(NCS_FILE_HANDLE hFile, UINT64 *pBuffer); |
||
235 | NCSError NCSFileReadIEEE4_MSB(NCS_FILE_HANDLE hFile, IEEE4 *pBuffer); |
||
236 | NCSError NCSFileReadIEEE4_LSB(NCS_FILE_HANDLE hFile, IEEE4 *pBuffer); |
||
237 | NCSError NCSFileReadIEEE8_MSB(NCS_FILE_HANDLE hFile, IEEE8 *pBuffer); |
||
238 | NCSError NCSFileReadIEEE8_LSB(NCS_FILE_HANDLE hFile, IEEE8 *pBuffer); |
||
239 | NCSError NCSFileWriteUINT8_MSB(NCS_FILE_HANDLE hFile, UINT8 nValue); |
||
240 | NCSError NCSFileWriteUINT8_LSB(NCS_FILE_HANDLE hFile, UINT8 nValue); |
||
241 | NCSError NCSFileWriteUINT16_MSB(NCS_FILE_HANDLE hFile, UINT16 nValue); |
||
242 | NCSError NCSFileWriteUINT16_LSB(NCS_FILE_HANDLE hFile, UINT16 nValue); |
||
243 | NCSError NCSFileWriteUINT32_MSB(NCS_FILE_HANDLE hFile, UINT32 nValue); |
||
244 | NCSError NCSFileWriteUINT32_LSB(NCS_FILE_HANDLE hFile, UINT32 nValue); |
||
245 | NCSError NCSFileWriteUINT64_MSB(NCS_FILE_HANDLE hFile, UINT64 nValue); |
||
246 | NCSError NCSFileWriteUINT64_LSB(NCS_FILE_HANDLE hFile, UINT64 nValue); |
||
247 | NCSError NCSFileWriteIEEE4_MSB(NCS_FILE_HANDLE hFile, IEEE4 fValue); |
||
248 | NCSError NCSFileWriteIEEE4_LSB(NCS_FILE_HANDLE hFile, IEEE4 fValue); |
||
249 | NCSError NCSFileWriteIEEE8_MSB(NCS_FILE_HANDLE hFile, IEEE8 dValue); |
||
250 | NCSError NCSFileWriteIEEE8_LSB(NCS_FILE_HANDLE hFile, IEEE8 dValue); |
||
251 | /*
|
||
252 | ** Currently macros to keep dll size down.
|
||
253 | */
|
||
254 | #ifdef NO_STDIO
|
||
255 | |||
256 | NCS_FILE_HANDLE NCSFileOpenStdIO(const char *filename, int oflag, int pmode); |
||
257 | int NCSFileCloseStdIO(NCS_FILE_HANDLE handle);
|
||
258 | int NCSFileReadStdIO(NCS_FILE_HANDLE handle, void* buffer, int count); |
||
259 | int NCSFileWriteStdIO(NCS_FILE_HANDLE handle, void* buffer, int count); |
||
260 | |||
261 | #else /* NO_STDIO */ |
||
262 | #ifdef WIN32
|
||
263 | |||
264 | #define NCSFileOpenStdIO(filename, oflag, pmode) \
|
||
265 | _open((const char*)filename, (int)oflag, (int)pmode) |
||
266 | #define NCSFileCloseStdIO(handle) \
|
||
267 | _close(handle) |
||
268 | #define NCSFileReadStdIO(handle, buffer, count) \
|
||
269 | _read(handle, (void*)buffer, (unsigned int)count) |
||
270 | #define NCSFileWriteStdIO(handle, buffer, count) \
|
||
271 | _write(handle, (const void*)buffer, (unsigned int)count) |
||
272 | |||
273 | #else /* WIN32 */ |
||
274 | |||
275 | #define NCSFileOpenStdIO(filename, oflag, pmode) open((const char*)filename, (int)oflag, (int)pmode) |
||
276 | #define NCSFileCloseStdIO(handle) close(handle)
|
||
277 | #define NCSFileReadStdIO(handle, buffer, count) read(handle, (void*)buffer, (unsigned int)count) |
||
278 | #define NCSFileWriteStdIO(handle, buffer, count) write(handle, (const void*)buffer, (unsigned int)count) |
||
279 | |||
280 | #endif /* WIN32 */ |
||
281 | #endif /* NO_STDIO */ |
||
282 | |||
283 | INT64 NCSFileSizeBytes(char *pFilename);
|
||
284 | INT64 NCSFreeDiskSpaceBytes(char *pDirName, INT64 *pTotal);
|
||
285 | char *NCSGetTempDirectory(void); |
||
286 | char *NCSGetTempFileName(char *pDir, char *pPrefix, char *pExt); |
||
287 | BOOLEAN NCSRenameFile(char *pSrc, char *pDst); |
||
288 | BOOLEAN NCSDeleteFile(char *pFileName);
|
||
289 | BOOLEAN NCSFileGetVersion(char *pFileName, UINT16 *pMajor, UINT16 *pMinor, UINT16 *pRevision, UINT16 *pBuild);/**[01]**/ |
||
290 | int NCSVersionCompare(UINT16 nMajor1, UINT16 nMinor1, UINT16 nRevision1, UINT16 nBuild1, UINT16 nMajor2, UINT16 nMinor2, UINT16 nRevision2, UINT16 nBuild2);
|
||
291 | BOOLEAN NCSIsLocalFile(char *string);
|
||
292 | BOOLEAN NCSPathExists(char *pPath, BOOLEAN *pIsDirectory);
|
||
293 | |||
294 | NCSError NCSMakeDir( const char *pDirName, BOOLEAN bCreateTree ); |
||
295 | NCSError NCSRemoveDir( const char *pDirName); |
||
296 | |||
297 | #ifdef __cplusplus
|
||
298 | } |
||
299 | #endif
|
||
300 | |||
301 | #endif /* NCSFILE_H */ |