LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/shape - shp_vsi.c (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 31 31 100.0 %
Date: 2010-01-09 Functions: 10 10 100.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: shp_vsi.c 17131 2009-05-26 22:03:31Z rouault $
       3                 :  *
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  IO Redirection via VSI services for shp/dbf io.
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2007,  Frank Warmerdam
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #include "shapefil.h"
      31                 : #include "cpl_vsi.h"
      32                 : #include "cpl_error.h"
      33                 : 
      34                 : CPL_CVSID("$Id: shp_vsi.c 17131 2009-05-26 22:03:31Z rouault $");
      35                 : 
      36                 : /************************************************************************/
      37                 : /*                            VSI_SHP_Open()                            */
      38                 : /************************************************************************/
      39                 : 
      40            4718 : SAFile VSI_SHP_Open( const char *pszFilename, const char *pszAccess )
      41                 : 
      42                 : {
      43            4718 :     return (SAFile) VSIFOpenL( pszFilename, pszAccess );
      44                 : }
      45                 : 
      46                 : /************************************************************************/
      47                 : /*                            VSI_SHP_Read()                            */
      48                 : /************************************************************************/
      49                 : 
      50           51042 : SAOffset VSI_SHP_Read( void *p, SAOffset size, SAOffset nmemb, SAFile file )
      51                 : 
      52                 : {
      53           51042 :     return (SAOffset) VSIFReadL( p, (size_t) size, (size_t) nmemb, 
      54                 :                                  (FILE *) file );
      55                 : }
      56                 : 
      57                 : /************************************************************************/
      58                 : /*                           VSI_SHP_Write()                            */
      59                 : /************************************************************************/
      60                 : 
      61           31183 : SAOffset VSI_SHP_Write( void *p, SAOffset size, SAOffset nmemb, SAFile file )
      62                 : 
      63                 : {
      64           31183 :     return (SAOffset) VSIFWriteL( p, (size_t) size, (size_t) nmemb, 
      65                 :                                   (FILE *) file );
      66                 : }
      67                 : 
      68                 : /************************************************************************/
      69                 : /*                            VSI_SHP_Seek()                            */
      70                 : /************************************************************************/
      71                 : 
      72           78239 : SAOffset VSI_SHP_Seek( SAFile file, SAOffset offset, int whence )
      73                 : 
      74                 : {
      75           78239 :     return (SAOffset) VSIFSeekL( (FILE *) file, (vsi_l_offset) offset, whence );
      76                 : }
      77                 : 
      78                 : /************************************************************************/
      79                 : /*                            VSI_SHP_Tell()                            */
      80                 : /************************************************************************/
      81                 : 
      82              84 : SAOffset VSI_SHP_Tell( SAFile file )
      83                 : 
      84                 : {
      85              84 :     return (SAOffset) VSIFTellL( (FILE *) file );
      86                 : }
      87                 : 
      88                 : /************************************************************************/
      89                 : /*                           VSI_SHP_Flush()                            */
      90                 : /************************************************************************/
      91                 : 
      92             321 : int VSI_SHP_Flush( SAFile file )
      93                 : 
      94                 : {
      95             321 :     return VSIFFlushL( (FILE *) file );
      96                 : }
      97                 : 
      98                 : /************************************************************************/
      99                 : /*                           VSI_SHP_Close()                            */
     100                 : /************************************************************************/
     101                 : 
     102            2978 : int VSI_SHP_Close( SAFile file )
     103                 : 
     104                 : {
     105            2978 :     return VSIFCloseL( (FILE *) file );
     106                 : }
     107                 : 
     108                 : /************************************************************************/
     109                 : /*                              SADError()                              */
     110                 : /************************************************************************/
     111                 : 
     112               5 : void VSI_SHP_Error( const char *message )
     113                 : 
     114                 : {
     115               5 :     CPLError( CE_Failure, CPLE_AppDefined, "%s", message );
     116               5 : }
     117                 : 
     118                 : /************************************************************************/
     119                 : /*                           VSI_SHP_Remove()                           */
     120                 : /************************************************************************/
     121                 : 
     122              93 : int VSI_SHP_Remove( const char *pszFilename )
     123                 : 
     124                 : {
     125              93 :     return VSIUnlink( pszFilename );
     126                 : }
     127                 : 
     128                 : /************************************************************************/
     129                 : /*                        SASetupDefaultHooks()                         */
     130                 : /************************************************************************/
     131                 : 
     132            1841 : void SASetupDefaultHooks( SAHooks *psHooks )
     133                 : 
     134                 : {
     135            1841 :     psHooks->FOpen   = VSI_SHP_Open;
     136            1841 :     psHooks->FRead   = VSI_SHP_Read;
     137            1841 :     psHooks->FWrite  = VSI_SHP_Write;
     138            1841 :     psHooks->FSeek   = VSI_SHP_Seek;
     139            1841 :     psHooks->FTell   = VSI_SHP_Tell;
     140            1841 :     psHooks->FFlush  = VSI_SHP_Flush;
     141            1841 :     psHooks->FClose  = VSI_SHP_Close;
     142                 : 
     143            1841 :     psHooks->Remove  = VSI_SHP_Remove;
     144            1841 :     psHooks->Atof    = atof;
     145                 : 
     146            1841 :     psHooks->Error   = VSI_SHP_Error;
     147            1841 : }

Generated by: LCOV version 1.7