32 #ifndef CPL_VSI_H_INCLUDED 33 #define CPL_VSI_H_INCLUDED 60 #if !defined(_WIN32) && !defined(_WIN32_WCE) 65 #if !defined(macos_pre10) && !defined(_WIN32_WCE) 66 # include <sys/stat.h> 70 #if defined(_WIN32_WCE) 71 # include <wce_stat.h> 82 FILE CPL_DLL * VSIFOpen(
const char *,
const char * ) CPL_WARN_UNUSED_RESULT;
83 int CPL_DLL VSIFClose( FILE * );
84 int CPL_DLL VSIFSeek( FILE *,
long,
int );
85 long CPL_DLL VSIFTell( FILE * );
86 void CPL_DLL VSIRewind( FILE * );
87 void CPL_DLL VSIFFlush( FILE * );
89 size_t CPL_DLL VSIFRead(
void *,
size_t,
size_t, FILE * );
90 size_t CPL_DLL VSIFWrite( const
void *,
size_t,
size_t, FILE * );
91 char CPL_DLL *VSIFGets(
char *,
int, FILE * );
92 int CPL_DLL VSIFPuts( const
char *, FILE * );
93 int CPL_DLL VSIFPrintf( FILE *, const
char *, ... ) CPL_PRINT_FUNC_FORMAT(2, 3);
95 int CPL_DLL VSIFGetc( FILE * );
96 int CPL_DLL VSIFPutc(
int, FILE * );
97 int CPL_DLL VSIUngetc(
int, FILE * );
98 int CPL_DLL VSIFEof( FILE * );
104 typedef struct stat VSIStatBuf;
105 int CPL_DLL VSIStat( const
char *, VSIStatBuf * );
108 # define VSI_ISLNK(x) ( 0 ) 109 # define VSI_ISREG(x) ((x) & S_IFREG) 110 # define VSI_ISDIR(x) ((x) & S_IFDIR) 111 # define VSI_ISCHR(x) ((x) & S_IFCHR) 112 # define VSI_ISBLK(x) ( 0 ) 114 # define VSI_ISLNK(x) S_ISLNK(x) 115 # define VSI_ISREG(x) S_ISREG(x) 116 # define VSI_ISDIR(x) S_ISDIR(x) 117 # define VSI_ISCHR(x) S_ISCHR(x) 118 # define VSI_ISBLK(x) S_ISBLK(x) 126 typedef GUIntBig vsi_l_offset;
130 #define VSIL_STRICT_ENFORCE 133 #ifdef VSIL_STRICT_ENFORCE 134 typedef struct _VSILFILE VSILFILE;
136 typedef FILE VSILFILE;
139 VSILFILE CPL_DLL *
VSIFOpenL(
const char *,
const char * ) CPL_WARN_UNUSED_RESULT;
141 int CPL_DLL
VSIFSeekL( VSILFILE *, vsi_l_offset,
int );
142 vsi_l_offset CPL_DLL
VSIFTellL( VSILFILE * );
143 void CPL_DLL VSIRewindL( VSILFILE * );
144 size_t CPL_DLL
VSIFReadL(
void *,
size_t,
size_t, VSILFILE * );
145 int CPL_DLL
VSIFReadMultiRangeL(
int nRanges,
void ** ppData, const vsi_l_offset* panOffsets, const
size_t* panSizes, VSILFILE * );
146 size_t CPL_DLL
VSIFWriteL( const
void *,
size_t,
size_t, VSILFILE * );
150 int CPL_DLL
VSIFPrintfL( VSILFILE *, const
char *, ... ) CPL_PRINT_FUNC_FORMAT(2, 3);
151 int CPL_DLL VSIFPutcL(
int, VSILFILE * );
154 const
char* pszFilename,
156 vsi_l_offset* pnSize,
159 #if defined(VSI_STAT64_T) 160 typedef struct VSI_STAT64_T VSIStatBufL;
162 #define VSIStatBufL VSIStatBuf 165 int CPL_DLL
VSIStatL(
const char *, VSIStatBufL * );
167 #define VSI_STAT_EXISTS_FLAG 0x1 168 #define VSI_STAT_NATURE_FLAG 0x2 169 #define VSI_STAT_SIZE_FLAG 0x4 171 int CPL_DLL
VSIStatExL(
const char * pszFilename, VSIStatBufL * psStatBuf,
int nFlags );
181 void CPL_DLL *VSICalloc(
size_t,
size_t ) CPL_WARN_UNUSED_RESULT;
182 void CPL_DLL *VSIMalloc(
size_t ) CPL_WARN_UNUSED_RESULT;
183 void CPL_DLL VSIFree(
void * );
184 void CPL_DLL *VSIRealloc(
void *,
size_t ) CPL_WARN_UNUSED_RESULT;
185 char CPL_DLL *VSIStrdup( const
char * ) CPL_WARN_UNUSED_RESULT;
194 void CPL_DLL *
VSIMalloc2(
size_t nSize1,
size_t nSize2 ) CPL_WARN_UNUSED_RESULT;
203 void CPL_DLL *
VSIMalloc3(
size_t nSize1,
size_t nSize2,
size_t nSize3 ) CPL_WARN_UNUSED_RESULT;
210 #define CPLReadDir VSIReadDir 213 int CPL_DLL
VSIMkdir(
const char * pathname,
long mode );
214 int CPL_DLL
VSIRmdir(
const char * pathname );
215 int CPL_DLL
VSIUnlink(
const char * pathname );
216 int CPL_DLL
VSIRename(
const char * oldpath,
const char * newpath );
217 char CPL_DLL *VSIStrerror(
int );
223 void CPL_DLL VSIInstallLargeFileHandler(
void);
233 void CPL_DLL VSICleanupFileManager(
void);
237 vsi_l_offset nDataLength,
238 int bTakeOwnership );
240 vsi_l_offset *pnDataLength,
241 int bUnlinkAndSeize );
247 unsigned long CPL_DLL VSITime(
unsigned long * );
248 const char CPL_DLL *VSICTime(
unsigned long );
249 struct tm CPL_DLL *VSIGMTime(
const time_t *pnTime,
250 struct tm *poBrokenTime );
251 struct tm CPL_DLL *VSILocalTime(
const time_t *pnTime,
252 struct tm *poBrokenTime );
266 #define VSIDebug4(f,a1,a2,a3,a4) CPLDebug( "VSI", f, a1, a2, a3, a4 ); 267 #define VSIDebug3( f, a1, a2, a3 ) CPLDebug( "VSI", f, a1, a2, a3 ); 268 #define VSIDebug2( f, a1, a2 ) CPLDebug( "VSI", f, a1, a2 ); 269 #define VSIDebug1( f, a1 ) CPLDebug( "VSI", f, a1 ); 271 #define VSIDebug4( f, a1, a2, a3, a4 ) {} 272 #define VSIDebug3( f, a1, a2, a3 ) {} 273 #define VSIDebug2( f, a1, a2 ) {} 274 #define VSIDebug1( f, a1 ) {} int VSIMkdir(const char *pathname, long mode)
Create a directory.
Definition: cpl_vsil.cpp:262
char ** VSIReadDir(const char *)
Read names in a directory.
Definition: cpl_vsil.cpp:63
int VSIRename(const char *oldpath, const char *newpath)
Rename a file.
Definition: cpl_vsil.cpp:321
int VSIIngestFile(VSILFILE *fp, const char *pszFilename, GByte **ppabyRet, vsi_l_offset *pnSize, GIntBig nMaxSize)
Ingest a file into memory.
Definition: cpl_vsil.cpp:873
void * VSIFGetNativeFileDescriptorL(VSILFILE *)
Returns the "native" file descriptor for the virtual handle.
Definition: cpl_vsil.cpp:1030
Core portability definitions for CPL.
size_t VSIFReadL(void *, size_t, size_t, VSILFILE *)
Read bytes from file.
Definition: cpl_vsil.cpp:669
void * VSIMalloc3(size_t nSize1, size_t nSize2, size_t nSize3) CPL_WARN_UNUSED_RESULT
VSIMalloc3 allocates (nSize1 * nSize2 * nSize3) bytes.
Definition: cpl_vsisimple.cpp:821
int VSIStatL(const char *, VSIStatBufL *)
Get filesystem object info.
Definition: cpl_vsil.cpp:383
void VSIInstallStdoutHandler(void)
Install /vsistdout/ file system handler.
Definition: cpl_vsil_stdout.cpp:378
void VSIInstallSubFileHandler(void)
Install /vsisubfile/ virtual file handler.
Definition: cpl_vsil_subfile.cpp:458
void VSIInstallCurlStreamingFileHandler(void)
Install /vsicurl_streaming/ HTTP/FTP file system handler (requires libcurl)
Definition: cpl_vsil_curl_streaming.cpp:1461
VSILFILE * VSIFOpenL(const char *, const char *) CPL_WARN_UNUSED_RESULT
Open file.
Definition: cpl_vsil.cpp:504
void VSIInstallStdinHandler(void)
Install /vsistdin/ file system handler.
Definition: cpl_vsil_stdin.cpp:389
int VSIFTruncateL(VSILFILE *, vsi_l_offset)
Truncate/expand the file to the specified size.
Definition: cpl_vsil.cpp:794
int VSIFFlushL(VSILFILE *)
Flush pending writes to disk.
Definition: cpl_vsil.cpp:637
VSILFILE * VSIFileFromMemBuffer(const char *pszFilename, GByte *pabyData, vsi_l_offset nDataLength, int bTakeOwnership)
Create memory "file" from a buffer.
Definition: cpl_vsi_mem.cpp:825
void VSIInstallTarFileHandler(void)
Install /vsitar/ file system handler.
Definition: cpl_vsil_tar.cpp:334
void VSIInstallZipFileHandler(void)
Install ZIP file system handler.
Definition: cpl_vsil_gzip.cpp:2348
int VSIIsCaseSensitiveFS(const char *pszFilename)
Returns if the filenames of the filesystem are case sensitive.
Definition: cpl_vsil.cpp:466
void * VSIMalloc2(size_t nSize1, size_t nSize2) CPL_WARN_UNUSED_RESULT
VSIMalloc2 allocates (nSize1 * nSize2) bytes.
Definition: cpl_vsisimple.cpp:789
int VSIFPrintfL(VSILFILE *, const char *,...)
Formatted write to file.
Definition: cpl_vsil.cpp:820
CPL error handling services.
void VSIInstallSparseFileHandler(void)
Install /vsisparse/ virtual file handler.
Definition: cpl_vsil_sparsefile.cpp:568
int VSIFReadMultiRangeL(int nRanges, void **ppData, const vsi_l_offset *panOffsets, const size_t *panSizes, VSILFILE *)
Read several ranges of bytes from file.
Definition: cpl_vsil.cpp:705
int VSIStatExL(const char *pszFilename, VSIStatBufL *psStatBuf, int nFlags)
Get filesystem object info.
Definition: cpl_vsil.cpp:420
void VSIInstallGZipFileHandler(void)
Install GZip file system handler.
Definition: cpl_vsil_gzip.cpp:1559
int VSIFEofL(VSILFILE *)
Test for end of file.
Definition: cpl_vsil.cpp:767
vsi_l_offset VSIFTellL(VSILFILE *)
Tell current file offset.
Definition: cpl_vsil.cpp:599
int VSIFSeekL(VSILFILE *, vsi_l_offset, int)
Seek to requested offset.
Definition: cpl_vsil.cpp:571
int VSIRmdir(const char *pathname)
Delete a directory.
Definition: cpl_vsil.cpp:350
void VSIInstallCurlFileHandler(void)
Install /vsicurl/ HTTP/FTP file system handler (requires libcurl)
Definition: cpl_vsil_curl.cpp:2673
int VSIUnlink(const char *pathname)
Delete a file.
Definition: cpl_vsil.cpp:290
int VSIFCloseL(VSILFILE *)
Close file.
Definition: cpl_vsil.cpp:536
void VSIInstallMemFileHandler(void)
Install "memory" file system handler.
Definition: cpl_vsi_mem.cpp:795
GByte * VSIGetMemFileBuffer(const char *pszFilename, vsi_l_offset *pnDataLength, int bUnlinkAndSeize)
Fetch buffer underlying memory file.
Definition: cpl_vsi_mem.cpp:881
size_t VSIFWriteL(const void *, size_t, size_t, VSILFILE *)
Write bytes to file.
Definition: cpl_vsil.cpp:738
char ** VSIReadDirRecursive(const char *pszPath)
Read names in a directory recursively.
Definition: cpl_vsil.cpp:106