- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# cpl_vsi.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002  * $Id: cpl_vsi.h 24442 2012-05-18 15:47:54Z rouault $
    00003  *
    00004  * Project:  CPL - Common Portability Library
    00005  * Author:   Frank Warmerdam, warmerdam@pobox.com
    00006  * Purpose:  Include file defining Virtual File System (VSI) functions, a
    00007  *           layer over POSIX file and other system services.
    00008  *
    00009  ******************************************************************************
    00010  * Copyright (c) 1998, Frank Warmerdam
    00011  *
    00012  * Permission is hereby granted, free of charge, to any person obtaining a
    00013  * copy of this software and associated documentation files (the "Software"),
    00014  * to deal in the Software without restriction, including without limitation
    00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00016  * and/or sell copies of the Software, and to permit persons to whom the
    00017  * Software is furnished to do so, subject to the following conditions:
    00018  *
    00019  * The above copyright notice and this permission notice shall be included
    00020  * in all copies or substantial portions of the Software.
    00021  *
    00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00028  * DEALINGS IN THE SOFTWARE.
    00029  ****************************************************************************/
    00030
    00031 #ifndef CPL_VSI_H_INCLUDED
    00032 #define CPL_VSI_H_INCLUDED
    00033
    00034 #include "cpl_port.h"
    00054 /* -------------------------------------------------------------------- */
    00055 /*      We need access to ``struct stat''.                              */
    00056 /* -------------------------------------------------------------------- */
    00057
    00058 /* Unix */
    00059 #if !defined(_WIN32) && !defined(_WIN32_WCE)
    00060 #  include <unistd.h>
    00061 #endif
    00062
    00063 /* Windows */
    00064 #if !defined(macos_pre10) && !defined(_WIN32_WCE)
    00065 #  include <sys/stat.h>
    00066 #endif
    00067
    00068 /* Windows CE */
    00069 #if defined(_WIN32_WCE)
    00070 #  include <wce_stat.h>
    00071 #endif
    00072
    00073 CPL_C_START
    00074
    00075 /* ==================================================================== */
    00076 /*      stdio file access functions.  These may not support large       */
    00077 /*      files, and don't necessarily go through the virtualization      */
    00078 /*      API.                                                            */
    00079 /* ==================================================================== */
    00080
    00081 FILE CPL_DLL *  VSIFOpen( const char *, const char * ) CPL_WARN_UNUSED_RESULT;
    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 /*      VSIStat() related.                                              */
    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 )            /* N/A on Windows */
    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 )            /* N/A on Windows */
    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 /*      64bit stdio file access functions.  If we have a big size       */
    00122 /*      defined, then provide protypes for the large file API,          */
    00123 /*      otherwise redefine to use the regular api.                      */
    00124 /* ==================================================================== */
    00125 typedef GUIntBig vsi_l_offset;
    00126
    00127 /* Make VSIL_STRICT_ENFORCE active in DEBUG builds */
    00128 #ifdef DEBUG
    00129 #define VSIL_STRICT_ENFORCE
    00130 #endif
    00131
    00132 #ifdef VSIL_STRICT_ENFORCE
    00133 typedef struct _VSILFILE VSILFILE;
    00134 #else
    00135 typedef FILE VSILFILE;
    00136 #endif
    00137
    00138 VSILFILE CPL_DLL *  VSIFOpenL( const char *, const char * ) CPL_WARN_UNUSED_RESULT;
    00139 int CPL_DLL     VSIFCloseL( VSILFILE * );
    00140 int CPL_DLL     VSIFSeekL( VSILFILE *, vsi_l_offset, int );
    00141 vsi_l_offset CPL_DLL VSIFTellL( VSILFILE * );
    00142 void CPL_DLL    VSIRewindL( VSILFILE * );
    00143 size_t CPL_DLL  VSIFReadL( void *, size_t, size_t, VSILFILE * );
    00144 int CPL_DLL     VSIFReadMultiRangeL( int nRanges, void ** ppData, const vsi_l_offset* panOffsets, const size_t* panSizes, VSILFILE * );
    00145 size_t CPL_DLL  VSIFWriteL( const void *, size_t, size_t, VSILFILE * );
    00146 int CPL_DLL     VSIFEofL( VSILFILE * );
    00147 int CPL_DLL     VSIFTruncateL( VSILFILE *, vsi_l_offset );
    00148 int CPL_DLL     VSIFFlushL( VSILFILE * );
    00149 int CPL_DLL     VSIFPrintfL( VSILFILE *, const char *, ... ) CPL_PRINT_FUNC_FORMAT(2, 3);
    00150 int CPL_DLL     VSIFPutcL( int, VSILFILE * );
    00151
    00152 #if defined(VSI_STAT64_T)
    00153 typedef struct VSI_STAT64_T VSIStatBufL;
    00154 #else
    00155 #define VSIStatBufL    VSIStatBuf
    00156 #endif
    00157
    00158 int CPL_DLL     VSIStatL( const char *, VSIStatBufL * );
    00159
    00160 #define VSI_STAT_EXISTS_FLAG    0x1
    00161 #define VSI_STAT_NATURE_FLAG    0x2
    00162 #define VSI_STAT_SIZE_FLAG      0x4
    00163
    00164 int CPL_DLL     VSIStatExL( const char * pszFilename, VSIStatBufL * psStatBuf, int nFlags );
    00165
    00166 int CPL_DLL     VSIIsCaseSensitiveFS( const char * pszFilename );
    00167
    00168 /* ==================================================================== */
    00169 /*      Memory allocation                                               */
    00170 /* ==================================================================== */
    00171
    00172 void CPL_DLL   *VSICalloc( size_t, size_t ) CPL_WARN_UNUSED_RESULT;
    00173 void CPL_DLL   *VSIMalloc( size_t ) CPL_WARN_UNUSED_RESULT;
    00174 void CPL_DLL    VSIFree( void * );
    00175 void CPL_DLL   *VSIRealloc( void *, size_t ) CPL_WARN_UNUSED_RESULT;
    00176 char CPL_DLL   *VSIStrdup( const char * ) CPL_WARN_UNUSED_RESULT;
    00177
    00185 void CPL_DLL *VSIMalloc2( size_t nSize1, size_t nSize2 ) CPL_WARN_UNUSED_RESULT;
    00186
    00194 void CPL_DLL *VSIMalloc3( size_t nSize1, size_t nSize2, size_t nSize3 ) CPL_WARN_UNUSED_RESULT;
    00195
    00196
    00197 /* ==================================================================== */
    00198 /*      Other...                                                        */
    00199 /* ==================================================================== */
    00200
    00201 #define CPLReadDir VSIReadDir
    00202 char CPL_DLL **VSIReadDir( const char * );
    00203 char CPL_DLL **VSIReadDirRecursive( const char *pszPath );
    00204 int CPL_DLL VSIMkdir( const char * pathname, long mode );
    00205 int CPL_DLL VSIRmdir( const char * pathname );
    00206 int CPL_DLL VSIUnlink( const char * pathname );
    00207 int CPL_DLL VSIRename( const char * oldpath, const char * newpath );
    00208 char CPL_DLL *VSIStrerror( int );
    00209
    00210 /* ==================================================================== */
    00211 /*      Install special file access handlers.                           */
    00212 /* ==================================================================== */
    00213 void CPL_DLL VSIInstallMemFileHandler(void);
    00214 void CPL_DLL VSIInstallLargeFileHandler(void);
    00215 void CPL_DLL VSIInstallSubFileHandler(void);
    00216 void VSIInstallCurlFileHandler(void);
    00217 void VSIInstallCurlStreamingFileHandler(void);
    00218 void VSIInstallGZipFileHandler(void); /* No reason to export that */
    00219 void VSIInstallZipFileHandler(void); /* No reason to export that */
    00220 void VSIInstallStdinHandler(void); /* No reason to export that */
    00221 void VSIInstallStdoutHandler(void); /* No reason to export that */
    00222 void CPL_DLL VSIInstallSparseFileHandler(void);
    00223 void VSIInstallTarFileHandler(void); /* No reason to export that */
    00224 void CPL_DLL VSICleanupFileManager(void);
    00225
    00226 VSILFILE CPL_DLL *VSIFileFromMemBuffer( const char *pszFilename,
    00227                                     GByte *pabyData,
    00228                                     vsi_l_offset nDataLength,
    00229                                     int bTakeOwnership );
    00230 GByte CPL_DLL *VSIGetMemFileBuffer( const char *pszFilename,
    00231                                     vsi_l_offset *pnDataLength,
    00232                                     int bUnlinkAndSeize );
    00233
    00234 /* ==================================================================== */
    00235 /*      Time quering.                                                   */
    00236 /* ==================================================================== */
    00237
    00238 unsigned long CPL_DLL VSITime( unsigned long * );
    00239 const char CPL_DLL *VSICTime( unsigned long );
    00240 struct tm CPL_DLL *VSIGMTime( const time_t *pnTime,
    00241                               struct tm *poBrokenTime );
    00242 struct tm CPL_DLL *VSILocalTime( const time_t *pnTime,
    00243                                  struct tm *poBrokenTime );
    00244
    00245 /* -------------------------------------------------------------------- */
    00246 /*      the following can be turned on for detailed logging of          */
    00247 /*      almost all IO calls.                                            */
    00248 /* -------------------------------------------------------------------- */
    00249 #ifdef VSI_DEBUG
    00250
    00251 #ifndef DEBUG
    00252 #  define DEBUG
    00253 #endif
    00254
    00255 #include "cpl_error.h"
    00256
    00257 #define VSIDebug4(f,a1,a2,a3,a4)   CPLDebug( "VSI", f, a1, a2, a3, a4 );
    00258 #define VSIDebug3( f, a1, a2, a3 ) CPLDebug( "VSI", f, a1, a2, a3 );
    00259 #define VSIDebug2( f, a1, a2 )     CPLDebug( "VSI", f, a1, a2 );
    00260 #define VSIDebug1( f, a1 )         CPLDebug( "VSI", f, a1 );
    00261 #else
    00262 #define VSIDebug4( f, a1, a2, a3, a4 ) {}
    00263 #define VSIDebug3( f, a1, a2, a3 ) {}
    00264 #define VSIDebug2( f, a1, a2 )     {}
    00265 #define VSIDebug1( f, a1 )         {}
    00266 #endif
    00267
    00268 CPL_C_END
    00269
    00270 #endif /* ndef CPL_VSI_H_INCLUDED */

Generated for GDAL by 1.7.1.