GDAL
cpl_vsi.h
Go to the documentation of this file.
1/******************************************************************************
2 * $Id$
3 *
4 * Project: CPL - Common Portability Library
5 * Author: Frank Warmerdam, warmerdam@pobox.com
6 * Purpose: Include file defining Virtual File System (VSI) functions, a
7 * layer over POSIX file and other system services.
8 *
9 ******************************************************************************
10 * Copyright (c) 1998, Frank Warmerdam
11 * Copyright (c) 2008-2014, Even Rouault <even dot rouault at spatialys.com>
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included
21 * in all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 * DEALINGS IN THE SOFTWARE.
30 ****************************************************************************/
31
32#ifndef CPL_VSI_H_INCLUDED
33#define CPL_VSI_H_INCLUDED
34
35#include "cpl_port.h"
36#include "cpl_progress.h"
37
38#include <stdbool.h>
39
58/* -------------------------------------------------------------------- */
59/* We need access to ``struct stat''. */
60/* -------------------------------------------------------------------- */
61
62/* Unix */
63#if !defined(_WIN32)
64# include <unistd.h>
65#endif
66
67/* Windows */
68#include <sys/stat.h>
69
71
73#ifdef ENABLE_EXPERIMENTAL_CPL_WARN_UNUSED_RESULT
74#define EXPERIMENTAL_CPL_WARN_UNUSED_RESULT CPL_WARN_UNUSED_RESULT
75#else
76#define EXPERIMENTAL_CPL_WARN_UNUSED_RESULT
77#endif
80/* ==================================================================== */
81/* stdio file access functions. These do not support large */
82/* files, and do not go through the virtualization API. */
83/* ==================================================================== */
84
87FILE CPL_DLL * VSIFOpen( const char *, const char * ) CPL_WARN_UNUSED_RESULT;
88int CPL_DLL VSIFClose( FILE * );
89int CPL_DLL VSIFSeek( FILE *, long, int ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
90long CPL_DLL VSIFTell( FILE * ) CPL_WARN_UNUSED_RESULT;
91void CPL_DLL VSIRewind( FILE * );
92void CPL_DLL VSIFFlush( FILE * );
93
94size_t CPL_DLL VSIFRead( void *, size_t, size_t, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
95size_t CPL_DLL VSIFWrite( const void *, size_t, size_t, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
96char CPL_DLL *VSIFGets( char *, int, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
97int CPL_DLL VSIFPuts( const char *, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
98int CPL_DLL VSIFPrintf( FILE *, CPL_FORMAT_STRING(const char *), ... ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT CPL_PRINT_FUNC_FORMAT(2, 3);
99
100int CPL_DLL VSIFGetc( FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
101int CPL_DLL VSIFPutc( int, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
102int CPL_DLL VSIUngetc( int, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
103int CPL_DLL VSIFEof( FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
104
107/* ==================================================================== */
108/* VSIStat() related. */
109/* ==================================================================== */
110
112typedef struct stat VSIStatBuf;
113int CPL_DLL VSIStat( const char *, VSIStatBuf * ) CPL_WARN_UNUSED_RESULT;
116#ifdef _WIN32
117# define VSI_ISLNK(x) ( 0 ) /* N/A on Windows */
118# define VSI_ISREG(x) ((x) & S_IFREG)
119# define VSI_ISDIR(x) ((x) & S_IFDIR)
120# define VSI_ISCHR(x) ((x) & S_IFCHR)
121# define VSI_ISBLK(x) ( 0 ) /* N/A on Windows */
122#else
124# define VSI_ISLNK(x) S_ISLNK(x)
126# define VSI_ISREG(x) S_ISREG(x)
128# define VSI_ISDIR(x) S_ISDIR(x)
130# define VSI_ISCHR(x) S_ISCHR(x)
131# define VSI_ISBLK(x) S_ISBLK(x)
133#endif
134
135/* ==================================================================== */
136/* 64bit stdio file access functions. If we have a big size */
137/* defined, then provide prototypes for the large file API, */
138/* otherwise redefine to use the regular api. */
139/* ==================================================================== */
140
144#define VSI_L_OFFSET_MAX GUINTBIG_MAX
145
147/* Make VSIL_STRICT_ENFORCE active in DEBUG builds */
148#ifdef DEBUG
149#define VSIL_STRICT_ENFORCE
150#endif
153#ifdef VSIL_STRICT_ENFORCE
155typedef struct _VSILFILE VSILFILE;
156#else
158typedef FILE VSILFILE;
159#endif
160
161VSILFILE CPL_DLL * VSIFOpenL( const char *, const char * ) CPL_WARN_UNUSED_RESULT;
162VSILFILE CPL_DLL * VSIFOpenExL( const char *, const char *, int ) CPL_WARN_UNUSED_RESULT;
163VSILFILE CPL_DLL * VSIFOpenEx2L( const char *, const char *, int, CSLConstList ) CPL_WARN_UNUSED_RESULT;
164int CPL_DLL VSIFCloseL( VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
165int CPL_DLL VSIFSeekL( VSILFILE *, vsi_l_offset, int ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
167void CPL_DLL VSIRewindL( VSILFILE * );
168size_t CPL_DLL VSIFReadL( void *, size_t, size_t, VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
169int CPL_DLL VSIFReadMultiRangeL( int nRanges, void ** ppData, const vsi_l_offset* panOffsets, const size_t* panSizes, VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
170size_t CPL_DLL VSIFWriteL( const void *, size_t, size_t, VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
171int CPL_DLL VSIFEofL( VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
172int CPL_DLL VSIFTruncateL( VSILFILE *, vsi_l_offset ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
173int CPL_DLL VSIFFlushL( VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
174int CPL_DLL VSIFPrintfL( VSILFILE *, CPL_FORMAT_STRING(const char *), ... ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT CPL_PRINT_FUNC_FORMAT(2, 3);
175int CPL_DLL VSIFPutcL( int, VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT;
176
178typedef enum
179{
184
186
187int CPL_DLL VSIIngestFile( VSILFILE* fp,
188 const char* pszFilename,
189 GByte** ppabyRet,
190 vsi_l_offset* pnSize,
192
193int CPL_DLL VSIOverwriteFile( VSILFILE* fpTarget, const char* pszSourceFilename ) CPL_WARN_UNUSED_RESULT;
194
195#if defined(VSI_STAT64_T)
197typedef struct VSI_STAT64_T VSIStatBufL;
198#else
200#define VSIStatBufL VSIStatBuf
201#endif
202
203int CPL_DLL VSIStatL( const char *, VSIStatBufL * ) CPL_WARN_UNUSED_RESULT;
204
206#define VSI_STAT_EXISTS_FLAG 0x1
208#define VSI_STAT_NATURE_FLAG 0x2
210#define VSI_STAT_SIZE_FLAG 0x4
212#define VSI_STAT_SET_ERROR_FLAG 0x8
216#define VSI_STAT_CACHE_ONLY 0x10
217
218int CPL_DLL VSIStatExL( const char * pszFilename, VSIStatBufL * psStatBuf, int nFlags ) CPL_WARN_UNUSED_RESULT;
219
220int CPL_DLL VSIIsCaseSensitiveFS( const char * pszFilename );
221
222int CPL_DLL VSISupportsSparseFiles( const char* pszPath );
223
224bool CPL_DLL VSIIsLocal( const char* pszPath );
225
226bool CPL_DLL VSISupportsSequentialWrite( const char* pszPath, bool bAllowLocalTempFile );
227
228bool CPL_DLL VSISupportsRandomWrite( const char* pszPath, bool bAllowLocalTempFile );
229
230int CPL_DLL VSIHasOptimizedReadMultiRange( const char* pszPath );
231
232const char CPL_DLL *VSIGetActualURL( const char* pszFilename );
233
234char CPL_DLL *VSIGetSignedURL( const char* pszFilename, CSLConstList papszOptions );
235
236const char CPL_DLL *VSIGetFileSystemOptions( const char* pszFilename );
237
238char CPL_DLL **VSIGetFileSystemsPrefixes( void );
239
240void CPL_DLL *VSIFGetNativeFileDescriptorL( VSILFILE* );
241
242char CPL_DLL **VSIGetFileMetadata( const char * pszFilename, const char* pszDomain,
244
245int CPL_DLL VSISetFileMetadata( const char * pszFilename,
246 CSLConstList papszMetadata,
247 const char* pszDomain,
248 CSLConstList papszOptions );
249
250void CPL_DLL VSISetCredential( const char* pszPathPrefix, const char* pszKey,
251 const char* pszValue );
252void CPL_DLL VSIClearCredentials(const char* pszPathPrefix );
253const char CPL_DLL* VSIGetCredential( const char* pszPath, const char* pszKey,
254 const char* pszDefault );
255
256/* ==================================================================== */
257/* Memory allocation */
258/* ==================================================================== */
259
260void CPL_DLL *VSICalloc( size_t, size_t ) CPL_WARN_UNUSED_RESULT;
261void CPL_DLL *VSIMalloc( size_t ) CPL_WARN_UNUSED_RESULT;
262void CPL_DLL VSIFree( void * );
263void CPL_DLL *VSIRealloc( void *, size_t ) CPL_WARN_UNUSED_RESULT;
264char CPL_DLL *VSIStrdup( const char * ) CPL_WARN_UNUSED_RESULT;
265
266void CPL_DLL *VSIMallocAligned( size_t nAlignment, size_t nSize ) CPL_WARN_UNUSED_RESULT;
267void CPL_DLL *VSIMallocAlignedAuto( size_t nSize ) CPL_WARN_UNUSED_RESULT;
268void CPL_DLL VSIFreeAligned( void* ptr );
269
270void CPL_DLL *VSIMallocAlignedAutoVerbose( size_t nSize, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT;
272#define VSI_MALLOC_ALIGNED_AUTO_VERBOSE( size ) VSIMallocAlignedAutoVerbose(size,__FILE__,__LINE__)
273
281void CPL_DLL *VSIMalloc2( size_t nSize1, size_t nSize2 ) CPL_WARN_UNUSED_RESULT;
282
290void CPL_DLL *VSIMalloc3( size_t nSize1, size_t nSize2, size_t nSize3 ) CPL_WARN_UNUSED_RESULT;
291
293void CPL_DLL *VSIMallocVerbose( size_t nSize, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT;
295#define VSI_MALLOC_VERBOSE( size ) VSIMallocVerbose(size,__FILE__,__LINE__)
296
298void CPL_DLL *VSIMalloc2Verbose( size_t nSize1, size_t nSize2, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT;
300#define VSI_MALLOC2_VERBOSE( nSize1, nSize2 ) VSIMalloc2Verbose(nSize1,nSize2,__FILE__,__LINE__)
301
303void CPL_DLL *VSIMalloc3Verbose( size_t nSize1, size_t nSize2, size_t nSize3, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT;
305#define VSI_MALLOC3_VERBOSE( nSize1, nSize2, nSize3 ) VSIMalloc3Verbose(nSize1,nSize2,nSize3,__FILE__,__LINE__)
306
308void CPL_DLL *VSICallocVerbose( size_t nCount, size_t nSize, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT;
310#define VSI_CALLOC_VERBOSE( nCount, nSize ) VSICallocVerbose(nCount,nSize,__FILE__,__LINE__)
311
313void CPL_DLL *VSIReallocVerbose( void* pOldPtr, size_t nNewSize, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT;
315#define VSI_REALLOC_VERBOSE( pOldPtr, nNewSize ) VSIReallocVerbose(pOldPtr,nNewSize,__FILE__,__LINE__)
316
318char CPL_DLL *VSIStrdupVerbose( const char* pszStr, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT;
320#define VSI_STRDUP_VERBOSE( pszStr ) VSIStrdupVerbose(pszStr,__FILE__,__LINE__)
321
322GIntBig CPL_DLL CPLGetPhysicalRAM(void);
323GIntBig CPL_DLL CPLGetUsablePhysicalRAM(void);
324
325/* ==================================================================== */
326/* Other... */
327/* ==================================================================== */
328
330#define CPLReadDir VSIReadDir
331char CPL_DLL **VSIReadDir( const char * );
332char CPL_DLL **VSIReadDirRecursive( const char *pszPath );
333char CPL_DLL **VSIReadDirEx( const char *pszPath, int nMaxFiles );
334char CPL_DLL **VSISiblingFiles( const char *pszPath );
335
337typedef struct VSIDIR VSIDIR;
338
339VSIDIR CPL_DLL *VSIOpenDir( const char *pszPath,
340 int nRecurseDepth,
341 const char* const *papszOptions);
342
344typedef struct VSIDIREntry VSIDIREntry;
349{
351 char* pszName;
353 int nMode;
366
367#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
369 VSIDIREntry();
370 ~VSIDIREntry();
371 VSIDIREntry(const VSIDIREntry&);
372 VSIDIREntry& operator=(VSIDIREntry&) = delete;
374#endif
375};
376
377const VSIDIREntry CPL_DLL *VSIGetNextDirEntry(VSIDIR* dir);
378void CPL_DLL VSICloseDir(VSIDIR* dir);
379
380int CPL_DLL VSIMkdir( const char * pszPathname, long mode );
381int CPL_DLL VSIMkdirRecursive( const char * pszPathname, long mode );
382int CPL_DLL VSIRmdir( const char * pszDirname );
383int CPL_DLL VSIRmdirRecursive( const char * pszDirname );
384int CPL_DLL VSIUnlink( const char * pszFilename );
385int CPL_DLL *VSIUnlinkBatch( CSLConstList papszFiles );
386int CPL_DLL VSIRename( const char * oldpath, const char * newpath );
387int CPL_DLL VSISync( const char* pszSource, const char* pszTarget,
388 const char* const * papszOptions,
389 GDALProgressFunc pProgressFunc,
390 void *pProgressData,
391 char*** ppapszOutputs );
392int CPL_DLL VSIAbortPendingUploads( const char* pszFilename );
393
394char CPL_DLL *VSIStrerror( int );
395GIntBig CPL_DLL VSIGetDiskFreeSpace(const char *pszDirname);
396
397void CPL_DLL VSINetworkStatsReset( void );
398char CPL_DLL *VSINetworkStatsGetAsSerializedJSON( char** papszOptions );
399
400/* ==================================================================== */
401/* Install special file access handlers. */
402/* ==================================================================== */
403void CPL_DLL VSIInstallMemFileHandler(void);
405void CPL_DLL VSIInstallLargeFileHandler(void);
407void CPL_DLL VSIInstallSubFileHandler(void);
409void CPL_DLL VSICurlClearCache(void);
410void CPL_DLL VSICurlPartialClearCache(const char* pszFilenamePrefix);
412void VSIInstallS3FileHandler(void);
414void VSIInstallGSFileHandler(void);
419void VSIInstallOSSFileHandler(void);
423void VSIInstallGZipFileHandler(void); /* No reason to export that */
424void VSIInstallZipFileHandler(void); /* No reason to export that */
425void VSIInstallStdinHandler(void); /* No reason to export that */
426void VSIInstallHdfsHandler(void); /* No reason to export that */
427void VSIInstallWebHdfsHandler(void); /* No reason to export that */
428void VSIInstallStdoutHandler(void); /* No reason to export that */
429void CPL_DLL VSIInstallSparseFileHandler(void);
430void VSIInstallTarFileHandler(void); /* No reason to export that */
431void CPL_DLL VSIInstallCryptFileHandler(void);
432void CPL_DLL VSISetCryptKey(const GByte* pabyKey, int nKeySize);
434void CPL_DLL VSICleanupFileManager(void);
437VSILFILE CPL_DLL *VSIFileFromMemBuffer( const char *pszFilename,
438 GByte *pabyData,
439 vsi_l_offset nDataLength,
440 int bTakeOwnership ) CPL_WARN_UNUSED_RESULT;
441GByte CPL_DLL *VSIGetMemFileBuffer( const char *pszFilename,
442 vsi_l_offset *pnDataLength,
443 int bUnlinkAndSeize );
444
446typedef size_t (*VSIWriteFunction)(const void* ptr, size_t size, size_t nmemb, FILE* stream);
447void CPL_DLL VSIStdoutSetRedirection( VSIWriteFunction pFct, FILE* stream );
448
453typedef int (*VSIFilesystemPluginStatCallback) ( void *pUserData, const char *pszFilename, VSIStatBufL *pStatBuf, int nFlags );
458typedef int (*VSIFilesystemPluginUnlinkCallback) ( void *pUserData, const char *pszFilename );
463typedef int (*VSIFilesystemPluginRenameCallback) ( void *pUserData, const char *oldpath, const char *newpath );
468typedef int (*VSIFilesystemPluginMkdirCallback) ( void *pUserData, const char *pszDirname, long nMode );
473typedef int (*VSIFilesystemPluginRmdirCallback) ( void *pUserData, const char *pszDirname );
478typedef char** (*VSIFilesystemPluginReadDirCallback) ( void *pUserData, const char *pszDirname, int nMaxFiles );
487typedef char** (*VSIFilesystemPluginSiblingFilesCallback) ( void *pUserData, const char *pszDirname );
493typedef void* (*VSIFilesystemPluginOpenCallback) ( void *pUserData, const char *pszFilename, const char *pszAccess );
503typedef int (*VSIFilesystemPluginSeekCallback) ( void *pFile, vsi_l_offset nOffset, int nWhence );
509typedef size_t (*VSIFilesystemPluginReadCallback) ( void *pFile, void *pBuffer, size_t nSize, size_t nCount );
514typedef int (*VSIFilesystemPluginReadMultiRangeCallback)( void *pFile, int nRanges, void ** ppData,
515 const vsi_l_offset* panOffsets, const size_t* panSizes );
525typedef int (*VSIFilesystemPluginEofCallback) ( void *pFile );
530typedef size_t (*VSIFilesystemPluginWriteCallback) ( void *pFile, const void *pBuffer, size_t nSize,size_t nCount);
535typedef int (*VSIFilesystemPluginFlushCallback) ( void *pFile );
539typedef int (*VSIFilesystemPluginTruncateCallback) ( void *pFile, vsi_l_offset nNewSize );
544typedef int (*VSIFilesystemPluginCloseCallback) ( void *pFile );
545
553typedef struct {
575 size_t nBufferSize;
576 size_t nCacheSize;
578/*
579 Callbacks are defined as a struct allocated by a call to VSIAllocFilesystemPluginCallbacksStruct
580 in order to try to maintain ABI stability when eventually adding a new member.
581 Any callbacks added to this struct SHOULD be added to the END of this struct
582*/
584
590
596
603int CPL_DLL VSIInstallPluginHandler( const char* pszPrefix, const VSIFilesystemPluginCallbacksStruct* poCb);
604
605/* ==================================================================== */
606/* Time querying. */
607/* ==================================================================== */
608
610unsigned long CPL_DLL VSITime( unsigned long * );
611const char CPL_DLL *VSICTime( unsigned long );
612struct tm CPL_DLL *VSIGMTime( const time_t *pnTime,
613 struct tm *poBrokenTime );
614struct tm CPL_DLL *VSILocalTime( const time_t *pnTime,
615 struct tm *poBrokenTime );
619/* -------------------------------------------------------------------- */
620/* the following can be turned on for detailed logging of */
621/* almost all IO calls. */
622/* -------------------------------------------------------------------- */
623#ifdef VSI_DEBUG
624
625#ifndef DEBUG
626# define DEBUG
627#endif
628
629#include "cpl_error.h"
630
631#define VSIDebug4(f,a1,a2,a3,a4) CPLDebug( "VSI", f, a1, a2, a3, a4 );
632#define VSIDebug3( f, a1, a2, a3 ) CPLDebug( "VSI", f, a1, a2, a3 );
633#define VSIDebug2( f, a1, a2 ) CPLDebug( "VSI", f, a1, a2 );
634#define VSIDebug1( f, a1 ) CPLDebug( "VSI", f, a1 );
635#else
636#define VSIDebug4( f, a1, a2, a3, a4 ) {}
637#define VSIDebug3( f, a1, a2, a3 ) {}
638#define VSIDebug2( f, a1, a2 ) {}
639#define VSIDebug1( f, a1 ) {}
640#endif
644
645#endif /* ndef CPL_VSI_H_INCLUDED */
CPL error handling services.
Core portability definitions for CPL.
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:233
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:306
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:304
#define CPL_FORMAT_STRING(arg)
Macro into which to wrap the format argument of a printf-like function.
Definition: cpl_port.h:859
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:844
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1056
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:869
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:203
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:230
#define VSIStatBufL
Type for VSIStatL()
Definition: cpl_vsi.h:200
void * VSICallocVerbose(size_t nCount, size_t nSize, const char *pszFile, int nLine)
VSICallocVerbose.
Definition: cpl_vsisimple.cpp:1205
int VSISetFileMetadata(const char *pszFilename, CSLConstList papszMetadata, const char *pszDomain, CSLConstList papszOptions)
Set metadata on files.
Definition: cpl_vsil.cpp:887
int * VSIUnlinkBatch(CSLConstList papszFiles)
Delete several files, possibly in a batch.
Definition: cpl_vsil.cpp:455
VSIRangeStatus VSIFGetRangeStatusL(VSILFILE *fp, vsi_l_offset nStart, vsi_l_offset nLength)
Return if a given file range contains data or holes filled with zeroes.
Definition: cpl_vsil.cpp:2359
void VSINetworkStatsReset(void)
Clear network related statistics.
Definition: cpl_vsil_curl.cpp:5612
size_t(* VSIWriteFunction)(const void *ptr, size_t size, size_t nmemb, FILE *stream)
Callback used by VSIStdoutSetRedirection()
Definition: cpl_vsi.h:446
void VSIInstallS3StreamingFileHandler(void)
Install /vsis3_streaming/ Amazon S3 file system handler (requires libcurl).
Definition: cpl_vsil_curl_streaming.cpp:2041
char ** VSISiblingFiles(const char *pszPath)
Return related filenames.
Definition: cpl_vsil.cpp:152
int VSIFFlushL(VSILFILE *)
Flush pending writes to disk.
Definition: cpl_vsil.cpp:1990
int(* VSIFilesystemPluginReadMultiRangeCallback)(void *pFile, int nRanges, void **ppData, const vsi_l_offset *panOffsets, const size_t *panSizes)
Read from multiple offsets.
Definition: cpl_vsi.h:514
vsi_l_offset VSIFTellL(VSILFILE *)
Tell current file offset.
Definition: cpl_vsil.cpp:1927
int VSIRename(const char *oldpath, const char *newpath)
Rename a file.
Definition: cpl_vsil.cpp:499
void VSISetCredential(const char *pszPathPrefix, const char *pszKey, const char *pszValue)
Set a credential (or more generally an option related to a virtual file system) for a given path pref...
Definition: cpl_vsil.cpp:2759
size_t VSIFWriteL(const void *, size_t, size_t, VSILFILE *)
Write bytes to file.
Definition: cpl_vsil.cpp:2156
VSIRangeStatus
Range status.
Definition: cpl_vsi.h:179
@ VSI_RANGE_STATUS_DATA
Data present.
Definition: cpl_vsi.h:181
@ VSI_RANGE_STATUS_HOLE
Hole.
Definition: cpl_vsi.h:182
@ VSI_RANGE_STATUS_UNKNOWN
Unknown.
Definition: cpl_vsi.h:180
size_t(* VSIFilesystemPluginReadCallback)(void *pFile, void *pBuffer, size_t nSize, size_t nCount)
Read data from current position, returns the number of blocks correctly read.
Definition: cpl_vsi.h:509
void VSIInstallStdinHandler(void)
Install /vsistdin/ file system handler.
Definition: cpl_vsil_stdin.cpp:652
bool VSISupportsRandomWrite(const char *pszPath, bool bAllowLocalTempFile)
Returns if the filesystem supports random write.
Definition: cpl_vsil.cpp:1032
GIntBig CPLGetPhysicalRAM(void)
Return the total physical RAM in bytes.
Definition: cpl_vsisimple.cpp:1369
int VSIFTruncateL(VSILFILE *, vsi_l_offset)
Truncate/expand the file to the specified size.
Definition: cpl_vsil.cpp:2244
void * VSICalloc(size_t, size_t)
Analog of calloc().
Definition: cpl_vsisimple.cpp:444
vsi_l_offset(* VSIFilesystemPluginTellCallback)(void *pFile)
Return current position in handle.
Definition: cpl_vsi.h:498
int VSIIsCaseSensitiveFS(const char *pszFilename)
Returns if the filenames of the filesystem are case sensitive.
Definition: cpl_vsil.cpp:923
void VSIInstallGZipFileHandler(void)
Install GZip file system handler.
Definition: cpl_vsil_gzip.cpp:2478
void * VSIMalloc2Verbose(size_t nSize1, size_t nSize2, const char *pszFile, int nLine)
VSIMalloc2Verbose.
Definition: cpl_vsisimple.cpp:1155
int VSIHasOptimizedReadMultiRange(const char *pszPath)
Returns if the filesystem supports efficient multi-range reading.
Definition: cpl_vsil.cpp:1058
char **(* VSIFilesystemPluginReadDirCallback)(void *pUserData, const char *pszDirname, int nMaxFiles)
List directory content.
Definition: cpl_vsi.h:478
void VSIFreeFilesystemPluginCallbacksStruct(VSIFilesystemPluginCallbacksStruct *poCb)
free resources allocated by VSIAllocFilesystemPluginCallbacksStruct
Definition: cpl_vsil_plugin.cpp:370
int(* VSIFilesystemPluginRenameCallback)(void *pUserData, const char *oldpath, const char *newpath)
Rename handle.
Definition: cpl_vsi.h:463
void VSIInstallCurlFileHandler(void)
Install /vsicurl/ HTTP/FTP file system handler (requires libcurl)
Definition: cpl_vsil_curl.cpp:5526
void * VSIMallocVerbose(size_t nSize, const char *pszFile, int nLine)
VSIMallocVerbose.
Definition: cpl_vsisimple.cpp:1138
void VSIInstallWebHdfsHandler(void)
Install /vsiwebhdfs/ WebHDFS (Hadoop File System) REST API file system handler (requires libcurl)
Definition: cpl_vsil_webhdfs.cpp:1240
bool VSISupportsSequentialWrite(const char *pszPath, bool bAllowLocalTempFile)
Returns if the filesystem supports sequential write.
Definition: cpl_vsil.cpp:1007
void VSIInstallS3FileHandler(void)
Install /vsis3/ Amazon S3 file system handler (requires libcurl)
Definition: cpl_vsil_s3.cpp:4760
void VSIInstallHdfsHandler(void)
Install /vsihdfs/ file system handler (requires JVM and HDFS support)
Definition: cpl_vsil_hdfs.cpp:415
void VSIInstallCryptFileHandler(void)
Install /vsicrypt/ encrypted file system handler (requires libcrypto++)
Definition: cpl_vsil_crypt.cpp:2047
char ** VSIGetFileSystemsPrefixes(void)
Return the list of prefixes for virtual file system handlers currently registered.
Definition: cpl_vsil.cpp:2694
int VSIOverwriteFile(VSILFILE *fpTarget, const char *pszSourceFilename)
Overwrite an existing file with content from another one.
Definition: cpl_vsil.cpp:2579
void VSIInstallSwiftStreamingFileHandler(void)
Install /vsiswift_streaming/ OpenStack Swif Object Storage (Swift) file system handler (requires libc...
Definition: cpl_vsil_curl_streaming.cpp:2124
void VSISetCryptKey(const GByte *pabyKey, int nKeySize)
Installs the encryption/decryption key.
Definition: cpl_vsil_crypt.cpp:208
void * VSIMallocAlignedAutoVerbose(size_t nSize, const char *pszFile, int nLine)
See VSIMallocAlignedAuto()
Definition: cpl_vsisimple.cpp:951
void VSIInstallStdoutHandler(void)
Install /vsistdout/ file system handler.
Definition: cpl_vsil_stdout.cpp:452
int VSIMkdirRecursive(const char *pszPathname, long mode)
Create a directory and all its ancestors.
Definition: cpl_vsil.cpp:371
void VSIInstallMemFileHandler(void)
Install "memory" file system handler.
Definition: cpl_vsi_mem.cpp:911
int VSIFPutcL(int, VSILFILE *)
Write a single byte to the file.
Definition: cpl_vsil.cpp:2307
int VSISync(const char *pszSource, const char *pszTarget, const char *const *papszOptions, GDALProgressFunc pProgressFunc, void *pProgressData, char ***ppapszOutputs)
Synchronize a source file/directory with a target file/directory.
Definition: cpl_vsil.cpp:585
void * VSIMalloc2(size_t nSize1, size_t nSize2)
VSIMalloc2 allocates (nSize1 * nSize2) bytes.
Definition: cpl_vsisimple.cpp:1116
int(* VSIFilesystemPluginCloseCallback)(void *pFile)
Close file handle.
Definition: cpl_vsi.h:544
struct VSIDIR VSIDIR
Opaque type for a directory iterator.
Definition: cpl_vsi.h:337
void VSICurlClearCache(void)
Clean local cache associated with /vsicurl/ (and related file systems)
Definition: cpl_vsil_curl.cpp:5549
void VSICurlPartialClearCache(const char *pszFilenamePrefix)
Clean local cache associated with /vsicurl/ (and related file systems) for a given filename (and its ...
Definition: cpl_vsil_curl.cpp:5588
int VSIIngestFile(VSILFILE *fp, const char *pszFilename, GByte **ppabyRet, vsi_l_offset *pnSize, GIntBig nMaxSize)
Ingest a file into memory.
Definition: cpl_vsil.cpp:2396
VSILFILE * VSIFOpenExL(const char *, const char *, int)
Open file.
Definition: cpl_vsil.cpp:1723
int VSISupportsSparseFiles(const char *pszPath)
Returns if the filesystem supports sparse files.
Definition: cpl_vsil.cpp:953
int(* VSIFilesystemPluginMkdirCallback)(void *pUserData, const char *pszDirname, long nMode)
Create Directory.
Definition: cpl_vsi.h:468
void * VSIRealloc(void *, size_t)
Analog of realloc().
Definition: cpl_vsisimple.cpp:681
int(* VSIFilesystemPluginTruncateCallback)(void *pFile, vsi_l_offset nNewSize)
Truncate handle.
Definition: cpl_vsi.h:539
VSIFilesystemPluginCallbacksStruct * VSIAllocFilesystemPluginCallbacksStruct(void)
return a VSIFilesystemPluginCallbacksStruct to be populated at runtime with handler callbacks
Definition: cpl_vsil_plugin.cpp:367
size_t(* VSIFilesystemPluginWriteCallback)(void *pFile, const void *pBuffer, size_t nSize, size_t nCount)
Write bytes at current offset.
Definition: cpl_vsi.h:530
char **(* VSIFilesystemPluginSiblingFilesCallback)(void *pUserData, const char *pszDirname)
List related files.
Definition: cpl_vsi.h:487
void VSICloseDir(VSIDIR *dir)
Close a directory.
Definition: cpl_vsil.cpp:323
int VSIUnlink(const char *pszFilename)
Delete a file.
Definition: cpl_vsil.cpp:423
void * VSIMalloc3(size_t nSize1, size_t nSize2, size_t nSize3)
VSIMalloc3 allocates (nSize1 * nSize2 * nSize3) bytes.
Definition: cpl_vsisimple.cpp:1129
int VSIFCloseL(VSILFILE *)
Close file.
Definition: cpl_vsil.cpp:1824
VSIDIR * VSIOpenDir(const char *pszPath, int nRecurseDepth, const char *const *papszOptions)
Open a directory to read its entries.
Definition: cpl_vsil.cpp:267
GByte * VSIGetMemFileBuffer(const char *pszFilename, vsi_l_offset *pnDataLength, int bUnlinkAndSeize)
Fetch buffer underlying memory file.
Definition: cpl_vsi_mem.cpp:1011
void VSIInstallSwiftFileHandler(void)
Install /vsiswift/ OpenStack Swif Object Storage (Swift) file system handler (requires libcurl)
Definition: cpl_vsil_swift.cpp:789
void VSIInstallZipFileHandler(void)
Install ZIP file system handler.
Definition: cpl_vsil_gzip.cpp:3333
const char * VSIGetCredential(const char *pszPath, const char *pszKey, const char *pszDefault)
Get a credential option for a given path.
Definition: cpl_vsil.cpp:2818
VSIRangeStatus(* VSIFilesystemPluginGetRangeStatusCallback)(void *pFile, vsi_l_offset nOffset, vsi_l_offset nLength)
Get empty ranges.
Definition: cpl_vsi.h:520
void * VSIFGetNativeFileDescriptorL(VSILFILE *)
Returns the "native" file descriptor for the virtual handle.
Definition: cpl_vsil.cpp:2651
int(* VSIFilesystemPluginSeekCallback)(void *pFile, vsi_l_offset nOffset, int nWhence)
Seek to position in handle.
Definition: cpl_vsi.h:503
void VSIClearCredentials(const char *pszPathPrefix)
Clear credentials set with VSISetCredential()
Definition: cpl_vsil.cpp:2791
int(* VSIFilesystemPluginStatCallback)(void *pUserData, const char *pszFilename, VSIStatBufL *pStatBuf, int nFlags)
Return information about a handle.
Definition: cpl_vsi.h:453
void VSIInstallOSSStreamingFileHandler(void)
Install /vsiaz_streaming/ Alibaba Cloud Object Storage Service (OSS) (requires libcurl)
Definition: cpl_vsil_curl_streaming.cpp:2103
char ** VSIReadDirEx(const char *pszPath, int nMaxFiles)
Read names in a directory.
Definition: cpl_vsil.cpp:124
void * VSIMallocAligned(size_t nAlignment, size_t nSize)
Allocates a buffer with an alignment constraint.
Definition: cpl_vsisimple.cpp:892
char * VSIGetSignedURL(const char *pszFilename, CSLConstList papszOptions)
Returns a signed URL of a supplied filename.
Definition: cpl_vsil.cpp:1135
int VSIInstallPluginHandler(const char *pszPrefix, const VSIFilesystemPluginCallbacksStruct *poCb)
register a handler on the given prefix.
Definition: cpl_vsil_plugin.cpp:360
const char * VSIGetActualURL(const char *pszFilename)
Returns the actual URL of a supplied filename.
Definition: cpl_vsil.cpp:1088
int VSIRmdirRecursive(const char *pszDirname)
Delete a directory recursively.
Definition: cpl_vsil.cpp:691
int VSIMkdir(const char *pszPathname, long mode)
Create a directory.
Definition: cpl_vsil.cpp:348
void * VSIReallocVerbose(void *pOldPtr, size_t nNewSize, const char *pszFile, int nLine)
VSIReallocVerbose.
Definition: cpl_vsisimple.cpp:1224
void *(* VSIFilesystemPluginOpenCallback)(void *pUserData, const char *pszFilename, const char *pszAccess)
Open a handle.
Definition: cpl_vsi.h:493
size_t VSIFReadL(void *, size_t, size_t, VSILFILE *)
Read bytes from file.
Definition: cpl_vsil.cpp:2042
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:2102
void VSIInstallCurlStreamingFileHandler(void)
Install /vsicurl_streaming/ HTTP/FTP file system handler (requires libcurl).
Definition: cpl_vsil_curl_streaming.cpp:2021
char * VSIStrdup(const char *)
Analog of strdup().
Definition: cpl_vsisimple.cpp:995
VSILFILE * VSIFOpenL(const char *, const char *)
Open file.
Definition: cpl_vsil.cpp:1173
int VSIFEofL(VSILFILE *)
Test for end of file.
Definition: cpl_vsil.cpp:2202
void VSIInstallSparseFileHandler(void)
Install /vsisparse/ virtual file handler.
Definition: cpl_vsil_sparsefile.cpp:551
void VSIInstallSubFileHandler(void)
Install /vsisubfile/ virtual file handler.
Definition: cpl_vsil_subfile.cpp:510
void VSIRewindL(VSILFILE *)
Rewind the file pointer to the beginning of the file.
Definition: cpl_vsil.cpp:1949
char ** VSIReadDir(const char *)
Read names in a directory.
Definition: cpl_vsil.cpp:90
void * VSIMalloc3Verbose(size_t nSize1, size_t nSize2, size_t nSize3, const char *pszFile, int nLine)
VSIMalloc3Verbose.
Definition: cpl_vsisimple.cpp:1180
int(* VSIFilesystemPluginUnlinkCallback)(void *pUserData, const char *pszFilename)
Remove handle by name.
Definition: cpl_vsi.h:458
char * VSIStrerror(int)
Return the error string corresponding to the error number.
Definition: cpl_vsisimple.cpp:1347
void VSIInstallADLSFileHandler(void)
Install /vsiaz/ Microsoft Azure Data Lake Storage Gen2 file system handler (requires libcurl)
Definition: cpl_vsil_adls.cpp:2186
GIntBig CPLGetUsablePhysicalRAM(void)
Return the total physical RAM, usable by a process, in bytes.
Definition: cpl_vsisimple.cpp:1460
int VSIStatL(const char *, VSIStatBufL *)
Get filesystem object info.
Definition: cpl_vsil.cpp:728
char ** VSIReadDirRecursive(const char *pszPath)
Read names in a directory recursively.
Definition: cpl_vsil.cpp:186
void VSIInstallGSStreamingFileHandler(void)
Install /vsigs_streaming/ Google Cloud Storage file system handler (requires libcurl)
Definition: cpl_vsil_curl_streaming.cpp:2062
int(* VSIFilesystemPluginEofCallback)(void *pFile)
Has end of file been reached.
Definition: cpl_vsi.h:525
int VSIFPrintfL(VSILFILE *, const char *,...)
Formatted write to file.
Definition: cpl_vsil.cpp:2270
int VSIStatExL(const char *pszFilename, VSIStatBufL *psStatBuf, int nFlags)
Get filesystem object info.
Definition: cpl_vsil.cpp:767
char * VSINetworkStatsGetAsSerializedJSON(char **papszOptions)
Return network related statistics, as a JSON serialized object.
Definition: cpl_vsil_curl.cpp:5710
void VSIInstallOSSFileHandler(void)
Install /vsioss/ Alibaba Cloud Object Storage Service (OSS) file system handler (requires libcurl)
Definition: cpl_vsil_oss.cpp:410
GIntBig VSIGetDiskFreeSpace(const char *pszDirname)
Return free disk space available on the filesystem.
Definition: cpl_vsil.cpp:2672
VSILFILE * VSIFOpenEx2L(const char *, const char *, int, CSLConstList)
Open file.
Definition: cpl_vsil.cpp:1768
void VSIInstallTarFileHandler(void)
Install /vsitar/ file system handler.
Definition: cpl_vsil_tar.cpp:641
const char * VSIGetFileSystemOptions(const char *pszFilename)
Return the list of options associated with a virtual file system handler as a serialized XML string.
Definition: cpl_vsil.cpp:2714
void VSIFreeAligned(void *ptr)
Free a buffer allocated with VSIMallocAligned().
Definition: cpl_vsisimple.cpp:975
void * VSIMallocAlignedAuto(size_t nSize)
Allocates a buffer with an alignment constraint such that it can be used by the most demanding vector...
Definition: cpl_vsisimple.cpp:938
int VSIAbortPendingUploads(const char *pszFilename)
Abort ongoing multi-part uploads.
Definition: cpl_vsil.cpp:636
void VSIStdoutSetRedirection(VSIWriteFunction pFct, FILE *stream)
Set an alternative write function and output file handle instead of fwrite() / stdout.
Definition: cpl_vsil_stdout.cpp:64
void * VSIMalloc(size_t)
Analog of malloc().
Definition: cpl_vsisimple.cpp:558
int VSIFSeekL(VSILFILE *, vsi_l_offset, int)
Seek to requested offset.
Definition: cpl_vsil.cpp:1884
int(* VSIFilesystemPluginFlushCallback)(void *pFile)
Sync written bytes.
Definition: cpl_vsi.h:535
VSILFILE * VSIFileFromMemBuffer(const char *pszFilename, GByte *pabyData, vsi_l_offset nDataLength, int bTakeOwnership)
Create memory "file" from a buffer.
Definition: cpl_vsi_mem.cpp:943
bool VSIIsLocal(const char *pszPath)
Returns if the file/filesystem is "local".
Definition: cpl_vsil.cpp:982
int VSIRmdir(const char *pszDirname)
Delete a directory.
Definition: cpl_vsil.cpp:664
FILE VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition: cpl_vsi.h:158
void VSIInstallAzureFileHandler(void)
Install /vsiaz/ Microsoft Azure Blob file system handler (requires libcurl)
Definition: cpl_vsil_az.cpp:2278
void VSIFree(void *)
Analog of free() for data allocated with VSIMalloc(), VSICalloc(), VSIRealloc()
Definition: cpl_vsisimple.cpp:827
char * VSIStrdupVerbose(const char *pszStr, const char *pszFile, int nLine)
VSIStrdupVerbose.
Definition: cpl_vsisimple.cpp:1242
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:142
const VSIDIREntry * VSIGetNextDirEntry(VSIDIR *dir)
Return the next entry of the directory.
Definition: cpl_vsil.cpp:304
void VSIInstallGSFileHandler(void)
Install /vsigs/ Google Cloud Storage file system handler (requires libcurl)
Definition: cpl_vsil_gs.cpp:825
void VSIInstallAzureStreamingFileHandler(void)
Install /vsiaz_streaming/ Microsoft Azure Blob file system handler (requires libcurl)
Definition: cpl_vsil_curl_streaming.cpp:2082
char ** VSIGetFileMetadata(const char *pszFilename, const char *pszDomain, CSLConstList papszOptions)
Get metadata on files.
Definition: cpl_vsil.cpp:830
int(* VSIFilesystemPluginRmdirCallback)(void *pUserData, const char *pszDirname)
Delete Directory.
Definition: cpl_vsi.h:473
Directory entry.
Definition: cpl_vsi.h:349
char * pszName
Filename.
Definition: cpl_vsi.h:351
GIntBig nMTime
Last modification time (seconds since 1970/01/01)
Definition: cpl_vsi.h:357
char bMTimeKnown
Whether nMTime is known: 0 = unknown, 1 = known.
Definition: cpl_vsi.h:363
char bSizeKnown
Whether nSize is known: 0 = unknown, 1 = known.
Definition: cpl_vsi.h:361
char bModeKnown
Whether nMode is known: 0 = unknown, 1 = known.
Definition: cpl_vsi.h:359
char ** papszExtra
NULL-terminated list of extra properties.
Definition: cpl_vsi.h:365
vsi_l_offset nSize
File size.
Definition: cpl_vsi.h:355
int nMode
File mode.
Definition: cpl_vsi.h:353
struct containing callbacks to used by the handler.
Definition: cpl_vsi.h:553
VSIFilesystemPluginWriteCallback write
write bytes to current position (w)
Definition: cpl_vsi.h:571
size_t nBufferSize
buffer small reads (makes handler read only)
Definition: cpl_vsi.h:575
VSIFilesystemPluginRenameCallback rename
rename handle ()
Definition: cpl_vsi.h:560
VSIFilesystemPluginReadMultiRangeCallback read_multi_range
read multiple blocks ()
Definition: cpl_vsi.h:568
VSIFilesystemPluginUnlinkCallback unlink
unlink handle by name ()
Definition: cpl_vsi.h:559
VSIFilesystemPluginRmdirCallback rmdir
remove directory ()
Definition: cpl_vsi.h:562
size_t nCacheSize
max mem to use per file when buffering
Definition: cpl_vsi.h:576
VSIFilesystemPluginEofCallback eof
has end of file been reached (r?)
Definition: cpl_vsi.h:570
VSIFilesystemPluginSiblingFilesCallback sibling_files
list related files
Definition: cpl_vsi.h:577
VSIFilesystemPluginOpenCallback open
open handle by name (rw)
Definition: cpl_vsi.h:564
VSIFilesystemPluginSeekCallback seek
set current position of handle (rw)
Definition: cpl_vsi.h:566
VSIFilesystemPluginGetRangeStatusCallback get_range_status
get range status ()
Definition: cpl_vsi.h:569
VSIFilesystemPluginCloseCallback close
close handle (rw)
Definition: cpl_vsi.h:574
VSIFilesystemPluginReadCallback read
read from current position (r)
Definition: cpl_vsi.h:567
VSIFilesystemPluginFlushCallback flush
sync bytes (w)
Definition: cpl_vsi.h:572
VSIFilesystemPluginReadDirCallback read_dir
list directory content (r?)
Definition: cpl_vsi.h:563
void * pUserData
Optional opaque pointer passed back to filemanager callbacks (e.g.
Definition: cpl_vsi.h:557
VSIFilesystemPluginTruncateCallback truncate
truncate handle (w?)
Definition: cpl_vsi.h:573
VSIFilesystemPluginMkdirCallback mkdir
make directory ()
Definition: cpl_vsi.h:561
VSIFilesystemPluginStatCallback stat
stat handle by name (rw)
Definition: cpl_vsi.h:558
VSIFilesystemPluginTellCallback tell
get current position of handle (rw)
Definition: cpl_vsi.h:565