1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * FileSystem.h
|
---|
4 | * Copyright (C) 2003 UNESCO
|
---|
5 | *
|
---|
6 | * A component of the Greenstone digital library software
|
---|
7 | * from the New Zealand Digital Library Project at the
|
---|
8 | * University of Waikato, New Zealand.
|
---|
9 | *
|
---|
10 | * This program is free software; you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * This program is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with this program; if not, write to the Free Software
|
---|
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | *
|
---|
24 | *********************************************************************/
|
---|
25 |
|
---|
26 | ////////////////////////////////////////////////////////////////////////////////
|
---|
27 | // FileSystem.h -- The generic file pointer routines are a collection of member
|
---|
28 | // functions used to wrap the underlying file system.
|
---|
29 |
|
---|
30 | //
|
---|
31 |
|
---|
32 |
|
---|
33 | #ifndef __FILE_SYSTEM__
|
---|
34 | #define __FILE_SYSTEM__
|
---|
35 |
|
---|
36 | // Non-platform specific include files
|
---|
37 | #include <string.h>
|
---|
38 | #include <stdlib.h>
|
---|
39 | #include <fcntl.h>
|
---|
40 | #include <sys/types.h>
|
---|
41 | #include <sys/stat.h>
|
---|
42 | #include <stdio.h>
|
---|
43 | #include "DLLCode.h"
|
---|
44 | #include "IsisTypes.h"
|
---|
45 |
|
---|
46 | namespace FileSystem {
|
---|
47 |
|
---|
48 | // ----------------
|
---|
49 | // Type definitions
|
---|
50 | // ----------------
|
---|
51 | // typedefs for 64-bit and 32-bit file operations and stream position
|
---|
52 | #if defined (__64_BIT_FILE_SYSTEM__)
|
---|
53 | typedef isis::int64_t FAU; // 64-bit File Address Unit, physical file address type
|
---|
54 | typedef isis::int64_t FAU_t; // Native 64-bit FAU type
|
---|
55 | typedef isis::int64_t StreamPos; // 64-bit stream position
|
---|
56 | #else // Use the 32-bit version by default
|
---|
57 | typedef isis::int32_t FAU; // 32-bit File Address Unit, physical file address type
|
---|
58 | typedef isis::int32_t FAU_t; // Native 32-bit FAU type
|
---|
59 | typedef isis::int32_t StreamPos; // 32-bit stream position
|
---|
60 | #endif
|
---|
61 |
|
---|
62 |
|
---|
63 | // Select the underlying file system
|
---|
64 | #if defined (__64_BIT_FILE_SYSTEM__)
|
---|
65 | #include "FS64.H" // WIN32 will always use NTFS for large files
|
---|
66 | typedef FPTR64 FPTR;
|
---|
67 |
|
---|
68 |
|
---|
69 | #elif defined (__WIN32__) && defined (__NTFS__)
|
---|
70 | // WIN32 file I/O API
|
---|
71 | #include <windows.h>
|
---|
72 | #include <io.h>
|
---|
73 | #include <string.h>
|
---|
74 | #include <stdlib.h>
|
---|
75 | #include <fcntl.h>
|
---|
76 | #include <sys/types.h>
|
---|
77 | #include <sys/stat.h>
|
---|
78 | #include <stdio.h>
|
---|
79 | #include "gxdtypes.h"
|
---|
80 | #include "gxheader.h"
|
---|
81 |
|
---|
82 | struct DLL_CODE_API FPTR { // Platform specific file pointer type
|
---|
83 | HANDLE fptr;
|
---|
84 | };
|
---|
85 |
|
---|
86 | #else // Use the stdio version by default. Common to all platforms.
|
---|
87 | // Non-platform specific stdio include files
|
---|
88 | #include <string.h>
|
---|
89 | #include <stdlib.h>
|
---|
90 | #include <fcntl.h>
|
---|
91 | #include <sys/types.h>
|
---|
92 | #include <sys/stat.h>
|
---|
93 | #include <stdio.h>
|
---|
94 | #include "IsisTypes.h"
|
---|
95 | //#include "gxheader.h"
|
---|
96 |
|
---|
97 | struct DLL_CODE_API FPTR { // File pointer type
|
---|
98 | FILE *fptr;
|
---|
99 | };
|
---|
100 | #endif // File system type
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 | // NOTE: Any underlying file system used must provide the basic
|
---|
105 | // functionallity defined here.
|
---|
106 | DLL_CODE_API FPTR *Create(const char *fname);
|
---|
107 | DLL_CODE_API FPTR *Open(const char *fname, AccessMode mode);
|
---|
108 | DLL_CODE_API int Close(FPTR *stream);
|
---|
109 | DLL_CODE_API int Flush(FPTR *stream);
|
---|
110 | DLL_CODE_API isis::ulong32_t Read(FPTR *stream, void *buf, isis::ulong32_t bytes);
|
---|
111 | DLL_CODE_API isis::ulong32_t Write(FPTR *stream, const void *buf, isis::ulong32_t bytes);
|
---|
112 | DLL_CODE_API FAU_t Seek(FPTR *stream, FAU_t, SeekMode mode);
|
---|
113 | DLL_CODE_API FAU_t Tell(FPTR *stream);
|
---|
114 | DLL_CODE_API int Exists(const _TCHAR *fname);
|
---|
115 | DLL_CODE_API FAU_t FileSize(const _TCHAR *fname);
|
---|
116 | // DLL_CODE_API int CanOpenForWriting(const _TCHAR *fname);
|
---|
117 | // DLL_CODE_API int CanOpenReadOnly(const _TCHAR *fname);
|
---|
118 | // DLL_CODE_API int IsReadOnly(const _TCHAR *fname);
|
---|
119 | }
|
---|
120 |
|
---|
121 | #endif // __FILE_SYSTEM__
|
---|