📄 cpl_vsisimple.c
字号:
/****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_vsisimple.cpp * * This is a simple implementation (direct to Posix) of the Virtual System * Interface (VSI). See gdal_vsi.h. * * TODO: * - add some assertions to ensure that arguments are widely legal. For * instance validation of access strings to fopen(). * * $Log: cpl_vsisimple.c,v $ * Revision 1.1.1.1 2006/06/26 15:38:26 oconrad * no message * * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.3 1998/12/14 04:50:33 warmerda * Avoid C++ comments so it will be C compilable as well. * * Revision 1.2 1998/12/04 21:42:57 danmo * Added #ifndef WIN32 arounf #include <unistd.h> * * Revision 1.1 1998/12/03 18:26:03 warmerda * New * */#include "cpl_vsi.h"/* for stat() */#ifndef WIN32# include <unistd.h>#endif#include <sys/stat.h>/************************************************************************//* VSIFOpen() *//************************************************************************/FILE *VSIFOpen( const char * pszFilename, const char * pszAccess ){ return( fopen( (char *) pszFilename, (char *) pszAccess ) );}/************************************************************************//* VSIFClose() *//************************************************************************/int VSIFClose( FILE * fp ){ return( fclose(fp) );}/************************************************************************//* VSIFSeek() *//************************************************************************/int VSIFSeek( FILE * fp, long nOffset, int nWhence ){ return( fseek( fp, nOffset, nWhence ) );}/************************************************************************//* VSIFTell() *//************************************************************************/long VSIFTell( FILE * fp ){ return( ftell( fp ) );}/************************************************************************//* VSIRewind() *//************************************************************************/void VSIRewind( FILE * fp ){ rewind( fp );}/************************************************************************//* VSIFRead() *//************************************************************************/size_t VSIFRead( void * pBuffer, size_t nSize, size_t nCount, FILE * fp ){ return( fread( pBuffer, nSize, nCount, fp ) );}/************************************************************************//* VSIFWrite() *//************************************************************************/size_t VSIFWrite( void * pBuffer, size_t nSize, size_t nCount, FILE * fp ){ return( fwrite( pBuffer, nSize, nCount, fp ) );}/************************************************************************//* VSIFGets() *//************************************************************************/char *VSIFGets( char *pszBuffer, int nBufferSize, FILE * fp ){ return( fgets( pszBuffer, nBufferSize, fp ) );}/************************************************************************//* VSIFGetc() *//************************************************************************/int VSIFGetc( FILE * fp ){ return( fgetc( fp ) );}/************************************************************************//* VSIUngetc() *//************************************************************************/int VSIUngetc( int c, FILE * fp ){ return( ungetc( c, fp ) );}/************************************************************************//* VSIFPrintf() *//* *//* This is a little more complicated than just calling *//* fprintf() because of the variable arguments. Instead we *//* have to use vfprintf(). *//************************************************************************/int VSIFPrintf( FILE * fp, const char * pszFormat, ... ){ va_list args; int nReturn; va_start( args, pszFormat ); nReturn = vfprintf( fp, pszFormat, args ); va_end( args ); return( nReturn );}/************************************************************************//* VSIFEof() *//************************************************************************/int VSIFEof( FILE * fp ){ return( feof( fp ) );}/************************************************************************//* VSIFPuts() *//************************************************************************/int VSIFPuts( const char * pszString, FILE * fp ){ return fputs( pszString, fp );}/************************************************************************//* VSIFPutc() *//************************************************************************/int VSIFPutc( int nChar, FILE * fp ){ return( fputc( nChar, fp ) );}/************************************************************************//* VSICalloc() *//************************************************************************/void *VSICalloc( size_t nCount, size_t nSize ){ return( calloc( nCount, nSize ) );}/************************************************************************//* VSIMalloc() *//************************************************************************/void *VSIMalloc( size_t nSize ){ return( malloc( nSize ) );}/************************************************************************//* VSIRealloc() *//************************************************************************/void * VSIRealloc( void * pData, size_t nNewSize ){ return( realloc( pData, nNewSize ) );}/************************************************************************//* VSIFree() *//************************************************************************/void VSIFree( void * pData ){ if( pData != NULL ) free( pData );}/************************************************************************//* VSIStrdup() *//************************************************************************/char *VSIStrdup( const char * pszString ){ return( strdup( pszString ) );}/************************************************************************//* VSIStat() *//************************************************************************/int VSIStat( const char * pszFilename, VSIStatBuf * pStatBuf ){ return( stat( pszFilename, pStatBuf ) );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -