LCOV - code coverage report
Current view: directory - port - cpl_vsi_virtual.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 15 5 33.3 %
Date: 2010-01-09 Functions: 12 5 41.7 %

       1                 : /******************************************************************************
       2                 :  * $Id: cpl_vsi_virtual.h 15257 2008-08-30 21:15:54Z mloskot $
       3                 :  *
       4                 :  * Project:  VSI Virtual File System
       5                 :  * Purpose:  Declarations for classes related to the virtual filesystem.
       6                 :  *           These would only be normally required by applications implmenting
       7                 :  *           their own virtual file system classes which should be rare.  
       8                 :  *           The class interface may be fragile through versions.
       9                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
      10                 :  *
      11                 :  ******************************************************************************
      12                 :  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
      13                 :  *
      14                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      15                 :  * copy of this software and associated documentation files (the "Software"),
      16                 :  * to deal in the Software without restriction, including without limitation
      17                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      18                 :  * and/or sell copies of the Software, and to permit persons to whom the
      19                 :  * Software is furnished to do so, subject to the following conditions:
      20                 :  *
      21                 :  * The above copyright notice and this permission notice shall be included
      22                 :  * in all copies or substantial portions of the Software.
      23                 :  *
      24                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      25                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      26                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      27                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      28                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      29                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      30                 :  * DEALINGS IN THE SOFTWARE.
      31                 :  ****************************************************************************/
      32                 : 
      33                 : #ifndef CPL_VSI_VIRTUAL_H_INCLUDED
      34                 : #define CPL_VSI_VIRTUAL_H_INCLUDED
      35                 : 
      36                 : #include "cpl_vsi.h"
      37                 : 
      38                 : #if defined(WIN32CE)
      39                 : #  include "cpl_wince.h"
      40                 : #  include <wce_errno.h>
      41                 : #  pragma warning(disable:4786) /* Remove annoying warnings in eVC++ and VC++ 6.0 */
      42                 : #endif
      43                 : 
      44                 : #include <map>
      45                 : #include <vector>
      46                 : #include <string>
      47                 : 
      48                 : /************************************************************************/
      49                 : /*                           VSIVirtualHandle                           */
      50                 : /************************************************************************/
      51                 : 
      52           13983 : class CPL_DLL VSIVirtualHandle { 
      53                 :   public:
      54                 :     virtual int       Seek( vsi_l_offset nOffset, int nWhence ) = 0;
      55                 :     virtual vsi_l_offset Tell() = 0;
      56                 :     virtual size_t    Read( void *pBuffer, size_t nSize, size_t nMemb ) = 0;
      57                 :     virtual size_t    Write( const void *pBuffer, size_t nSize,size_t nMemb)=0;
      58                 :     virtual int       Eof() = 0;
      59               5 :     virtual int       Flush() {return 0;}
      60                 :     virtual int       Close() = 0;
      61           13982 :     virtual           ~VSIVirtualHandle() { }
      62                 : };
      63                 : 
      64                 : /************************************************************************/
      65                 : /*                         VSIFilesystemHandler                         */
      66                 : /************************************************************************/
      67                 : 
      68            1895 : class CPL_DLL VSIFilesystemHandler {
      69                 : 
      70                 : public:
      71                 : 
      72            1815 :     virtual ~VSIFilesystemHandler() {}
      73                 : 
      74                 :     virtual VSIVirtualHandle *Open( const char *pszFilename, 
      75                 :                                     const char *pszAccess) = 0;
      76                 :     virtual int Stat( const char *pszFilename, VSIStatBufL *pStatBuf) = 0;
      77               0 :     virtual int Unlink( const char *pszFilename )
      78               0 :                       { errno=ENOENT; return -1; }
      79               0 :     virtual int Mkdir( const char *pszDirname, long nMode ) 
      80               0 :                      { errno=ENOENT; return -1; }
      81               0 :     virtual int Rmdir( const char *pszDirname ) 
      82               0 :                      { errno=ENOENT; return -1; }
      83               0 :     virtual char **ReadDir( const char *pszDirname ) 
      84               0 :                           { return NULL; }
      85               0 :     virtual int Rename( const char *oldpath, const char *newpath )
      86               0 :                       { errno=ENOENT; return -1; }
      87                 : };
      88                 : 
      89                 : /************************************************************************/
      90                 : /*                            VSIFileManager                            */
      91                 : /************************************************************************/
      92                 : 
      93                 : class CPL_DLL VSIFileManager 
      94                 : {
      95                 : private:
      96                 :     VSIFilesystemHandler *poDefaultHandler;
      97                 :     std::map<std::string, VSIFilesystemHandler *> oHandlers;
      98                 : 
      99                 :     VSIFileManager();
     100                 : 
     101                 :     static VSIFileManager *Get();
     102                 : 
     103                 : public:
     104                 :     ~VSIFileManager();
     105                 : 
     106                 :     static VSIFilesystemHandler *GetHandler( const char * );
     107                 :     static void InstallHandler( const std::string& osPrefix, 
     108                 :                                 VSIFilesystemHandler * );
     109                 :     static void RemoveHandler( const std::string& osPrefix );
     110                 : };
     111                 : 
     112                 : #endif /* ndef CPL_VSI_VIRTUAL_H_INCLUDED */

Generated by: LCOV version 1.7