📄 cplvsi.h
字号:
#ifndef CPL_VSI_H_INCLUDED#define CPL_VSI_H_INCLUDED#include "CplPort.h"/** * \file cpl_vsi.h * * Standard C Covers * * The VSI functions are intended to be hookable aliases for Standard C * I/O, memory allocation and other system functions. They are intended * to allow virtualization of disk I/O so that non file data sources * can be made to appear as files, and so that additional error trapping * and reporting can be interested. The memory access API is aliased * so that special application memory management services can be used. * * Is is intended that each of these functions retains exactly the same * calling pattern as the original Standard C functions they relate to. * This means we don't have to provide custom documentation, and also means * that the default implementation is very simple. *//* -------------------------------------------------------------------- *//* We need access to ``struct stat''. *//* -------------------------------------------------------------------- */#ifndef _WIN32# include <unistd.h>#endif#if !defined(macos_pre10)# include <sys/stat.h>#endifCPL_C_START/* ==================================================================== *//* stdio file access functions. *//* ==================================================================== */FILE CPL_DLL * VSIFOpen( const char *, const char * );int CPL_DLL VSIFClose( FILE * );int CPL_DLL VSIFSeek( FILE *, long, int );long CPL_DLL VSIFTell( FILE * );void CPL_DLL VSIRewind( FILE * );void CPL_DLL VSIFFlush( FILE * );size_t CPL_DLL VSIFRead( void *, size_t, size_t, FILE * );size_t CPL_DLL VSIFWrite( void *, size_t, size_t, FILE * );char CPL_DLL *VSIFGets( char *, int, FILE * );int CPL_DLL VSIFPuts( const char *, FILE * );int CPL_DLL VSIFPrintf( FILE *, const char *, ... );int CPL_DLL VSIFGetc( FILE * );int CPL_DLL VSIFPutc( int, FILE * );int CPL_DLL VSIUngetc( int, FILE * );int CPL_DLL VSIFEof( FILE * );/* ==================================================================== *//* VSIStat() related. *//* ==================================================================== */typedef struct stat VSIStatBuf;int CPL_DLL VSIStat( const char *, VSIStatBuf * );#ifdef _WIN32# define VSI_ISLNK(x) ( 0 ) /* N/A on Windows */# define VSI_ISREG(x) ((x) & S_IFREG)# define VSI_ISDIR(x) ((x) & S_IFDIR)# define VSI_ISCHR(x) ((x) & S_IFCHR)# define VSI_ISBLK(x) ( 0 ) /* N/A on Windows */#else# define VSI_ISLNK(x) S_ISLNK(x)# define VSI_ISREG(x) S_ISREG(x)# define VSI_ISDIR(x) S_ISDIR(x)# define VSI_ISCHR(x) S_ISCHR(x)# define VSI_ISBLK(x) S_ISBLK(x)#endif/* ==================================================================== *//* 64bit stdio file access functions. If we have a big size *//* defined, then provide protypes for the large file API, *//* otherwise redefine to use the regular api. *//* ==================================================================== */#ifdef VSI_LARGE_API_SUPPORTEDtypedef GUIntBig vsi_l_offset;FILE CPL_DLL * VSIFOpenL( const char *, const char * );int CPL_DLL VSIFCloseL( FILE * );int CPL_DLL VSIFSeekL( FILE *, vsi_l_offset, int );vsi_l_offset CPL_DLL VSIFTellL( FILE * );void CPL_DLL VSIRewindL( FILE * );size_t CPL_DLL VSIFReadL( void *, size_t, size_t, FILE * );size_t CPL_DLL VSIFWriteL( void *, size_t, size_t, FILE * );int CPL_DLL VSIFEofL( FILE * );void CPL_DLL VSIFFlushL( FILE * );#ifndef WIN32typedef struct stat64 VSIStatBufL;int CPL_DLL VSIStatL( const char *, VSIStatBufL * );#else#define VSIStatBufL VSIStatBuf#define VSIStatL VSIStat#endif#elsetypedef long vsi_l_offset;#define vsi_l_offset long#define VSIFOpenL VSIFOpen#define VSIFCloseL VSIFClose#define VSIFSeekL VSIFSeek#define VSIFTellL VSIFTell#define VSIFRewindL VSIFRewind#define VSIFReadL VSIFRead#define VSIFWriteL VSIFWrite#define VSIFEofL VSIFEof#define VSIFFlushL VSIFFlush#define VSIStatBufL VSIStatBuf#define VSIStatL VSIStat#endif/* ==================================================================== *//* Memory allocation *//* ==================================================================== */void CPL_DLL *VSICalloc( size_t, size_t );void CPL_DLL *VSIMalloc( size_t );void CPL_DLL VSIFree( void * );void CPL_DLL *VSIRealloc( void *, size_t );char CPL_DLL *VSIStrdup( const char * );/* ==================================================================== *//* Other... *//* ==================================================================== */int CPL_DLL VSIMkdir( const char * pathname, long mode );int CPL_DLL VSIRmdir( const char * pathname );int CPL_DLL VSIUnlink( const char * pathname );char CPL_DLL *VSIStrerror( int );/* ==================================================================== *//* Time quering. *//* ==================================================================== */unsigned long CPL_DLL VSITime( unsigned long * );const char CPL_DLL *VSICTime( unsigned long );struct tm CPL_DLL *VSIGMTime( const time_t *pnTime, struct tm *poBrokenTime );struct tm CPL_DLL *VSILocalTime( const time_t *pnTime, struct tm *poBrokenTime );/* -------------------------------------------------------------------- *//* the following can be turned on for detailed logging of *//* almost all IO calls. *//* -------------------------------------------------------------------- */#ifdef VSI_DEBUG#ifndef DEBUG# define DEBUG#endif#include "cpl_error.h"#define VSIDebug4(f,a1,a2,a3,a4) CPLDebug( "VSI", f, a1, a2, a3, a4 );#define VSIDebug3( f, a1, a2, a3 ) CPLDebug( "VSI", f, a1, a2, a3 );#define VSIDebug2( f, a1, a2 ) CPLDebug( "VSI", f, a1, a2 );#define VSIDebug1( f, a1 ) CPLDebug( "VSI", f, a1 );#else#define VSIDebug4( f, a1, a2, a3, a4 ) {}#define VSIDebug3( f, a1, a2, a3 ) {}#define VSIDebug2( f, a1, a2 ) {}#define VSIDebug1( f, a1 ) {}#endifCPL_C_END#endif /* ndef CPL_VSI_H_INCLUDED */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -