00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef CPL_VSI_H_INCLUDED
00032 #define CPL_VSI_H_INCLUDED
00033
00034 #include "cpl_port.h"
00054
00055
00056
00057
00058
00059 #if !defined(_WIN32) && !defined(_WIN32_WCE)
00060 # include <unistd.h>
00061 #endif
00062
00063
00064 #if !defined(macos_pre10) && !defined(_WIN32_WCE)
00065 # include <sys/stat.h>
00066 #endif
00067
00068
00069 #if defined(_WIN32_WCE)
00070 # include <wce_stat.h>
00071 #endif
00072
00073 CPL_C_START
00074
00075
00076
00077
00078
00079
00080
00081 FILE CPL_DLL * VSIFOpen( const char *, const char * );
00082 int CPL_DLL VSIFClose( FILE * );
00083 int CPL_DLL VSIFSeek( FILE *, long, int );
00084 long CPL_DLL VSIFTell( FILE * );
00085 void CPL_DLL VSIRewind( FILE * );
00086 void CPL_DLL VSIFFlush( FILE * );
00087
00088 size_t CPL_DLL VSIFRead( void *, size_t, size_t, FILE * );
00089 size_t CPL_DLL VSIFWrite( const void *, size_t, size_t, FILE * );
00090 char CPL_DLL *VSIFGets( char *, int, FILE * );
00091 int CPL_DLL VSIFPuts( const char *, FILE * );
00092 int CPL_DLL VSIFPrintf( FILE *, const char *, ... ) CPL_PRINT_FUNC_FORMAT(2, 3);
00093
00094 int CPL_DLL VSIFGetc( FILE * );
00095 int CPL_DLL VSIFPutc( int, FILE * );
00096 int CPL_DLL VSIUngetc( int, FILE * );
00097 int CPL_DLL VSIFEof( FILE * );
00098
00099
00100
00101
00102
00103 typedef struct stat VSIStatBuf;
00104 int CPL_DLL VSIStat( const char *, VSIStatBuf * );
00105
00106 #ifdef _WIN32
00107 # define VSI_ISLNK(x) ( 0 )
00108 # define VSI_ISREG(x) ((x) & S_IFREG)
00109 # define VSI_ISDIR(x) ((x) & S_IFDIR)
00110 # define VSI_ISCHR(x) ((x) & S_IFCHR)
00111 # define VSI_ISBLK(x) ( 0 )
00112 #else
00113 # define VSI_ISLNK(x) S_ISLNK(x)
00114 # define VSI_ISREG(x) S_ISREG(x)
00115 # define VSI_ISDIR(x) S_ISDIR(x)
00116 # define VSI_ISCHR(x) S_ISCHR(x)
00117 # define VSI_ISBLK(x) S_ISBLK(x)
00118 #endif
00119
00120
00121
00122
00123
00124
00125 typedef GUIntBig vsi_l_offset;
00126
00127 FILE CPL_DLL * VSIFOpenL( const char *, const char * );
00128 int CPL_DLL VSIFCloseL( FILE * );
00129 int CPL_DLL VSIFSeekL( FILE *, vsi_l_offset, int );
00130 vsi_l_offset CPL_DLL VSIFTellL( FILE * );
00131 void CPL_DLL VSIRewindL( FILE * );
00132 size_t CPL_DLL VSIFReadL( void *, size_t, size_t, FILE * );
00133 size_t CPL_DLL VSIFWriteL( const void *, size_t, size_t, FILE * );
00134 int CPL_DLL VSIFEofL( FILE * );
00135 int CPL_DLL VSIFFlushL( FILE * );
00136 int CPL_DLL VSIFPrintfL( FILE *, const char *, ... ) CPL_PRINT_FUNC_FORMAT(2, 3);
00137 int CPL_DLL VSIFPutcL( int, FILE * );
00138
00139 #if defined(VSI_STAT64_T)
00140 typedef struct VSI_STAT64_T VSIStatBufL;
00141 #else
00142 #define VSIStatBufL VSIStatBuf
00143 #endif
00144
00145 int CPL_DLL VSIStatL( const char *, VSIStatBufL * );
00146
00147
00148
00149
00150
00151 void CPL_DLL *VSICalloc( size_t, size_t );
00152 void CPL_DLL *VSIMalloc( size_t );
00153 void CPL_DLL VSIFree( void * );
00154 void CPL_DLL *VSIRealloc( void *, size_t );
00155 char CPL_DLL *VSIStrdup( const char * );
00156
00164 void CPL_DLL *VSIMalloc2( size_t nSize1, size_t nSize2 );
00165
00173 void CPL_DLL *VSIMalloc3( size_t nSize1, size_t nSize2, size_t nSize3 );
00174
00175
00176
00177
00178
00179
00180 #define CPLReadDir VSIReadDir
00181 char CPL_DLL **VSIReadDir( const char * );
00182 int CPL_DLL VSIMkdir( const char * pathname, long mode );
00183 int CPL_DLL VSIRmdir( const char * pathname );
00184 int CPL_DLL VSIUnlink( const char * pathname );
00185 int CPL_DLL VSIRename( const char * oldpath, const char * newpath );
00186 char CPL_DLL *VSIStrerror( int );
00187
00188
00189
00190
00191 void CPL_DLL VSIInstallMemFileHandler(void);
00192 void CPL_DLL VSIInstallLargeFileHandler(void);
00193 void CPL_DLL VSIInstallSubFileHandler(void);
00194 void VSIInstallGZipFileHandler(void);
00195 void VSIInstallZipFileHandler(void);
00196 void CPL_DLL VSICleanupFileManager(void);
00197
00198 FILE CPL_DLL *VSIFileFromMemBuffer( const char *pszFilename,
00199 GByte *pabyData,
00200 vsi_l_offset nDataLength,
00201 int bTakeOwnership );
00202 GByte CPL_DLL *VSIGetMemFileBuffer( const char *pszFilename,
00203 vsi_l_offset *pnDataLength,
00204 int bUnlinkAndSeize );
00205
00206
00207
00208
00209
00210 unsigned long CPL_DLL VSITime( unsigned long * );
00211 const char CPL_DLL *VSICTime( unsigned long );
00212 struct tm CPL_DLL *VSIGMTime( const time_t *pnTime,
00213 struct tm *poBrokenTime );
00214 struct tm CPL_DLL *VSILocalTime( const time_t *pnTime,
00215 struct tm *poBrokenTime );
00216
00217
00218
00219
00220
00221 #ifdef VSI_DEBUG
00222
00223 #ifndef DEBUG
00224 # define DEBUG
00225 #endif
00226
00227 #include "cpl_error.h"
00228
00229 #define VSIDebug4(f,a1,a2,a3,a4) CPLDebug( "VSI", f, a1, a2, a3, a4 );
00230 #define VSIDebug3( f, a1, a2, a3 ) CPLDebug( "VSI", f, a1, a2, a3 );
00231 #define VSIDebug2( f, a1, a2 ) CPLDebug( "VSI", f, a1, a2 );
00232 #define VSIDebug1( f, a1 ) CPLDebug( "VSI", f, a1 );
00233 #else
00234 #define VSIDebug4( f, a1, a2, a3, a4 ) {}
00235 #define VSIDebug3( f, a1, a2, a3 ) {}
00236 #define VSIDebug2( f, a1, a2 ) {}
00237 #define VSIDebug1( f, a1 ) {}
00238 #endif
00239
00240 CPL_C_END
00241
00242 #endif