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