# cpl_vsi_virtual.h

    00001 /******************************************************************************
    00002  * $Id: cpl_vsi_virtual.h 15257 2008-08-30 21:15:54Z mloskot $
    00003  *
    00004  * Project:  VSI Virtual File System
    00005  * Purpose:  Declarations for classes related to the virtual filesystem.
    00006  *           These would only be normally required by applications implmenting
    00007  *           their own virtual file system classes which should be rare.
    00008  *           The class interface may be fragile through versions.
    00009  * Author:   Frank Warmerdam, warmerdam@pobox.com
    00010  *
    00011  ******************************************************************************
    00012  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
    00013  *
    00014  * Permission is hereby granted, free of charge, to any person obtaining a
    00015  * copy of this software and associated documentation files (the "Software"),
    00016  * to deal in the Software without restriction, including without limitation
    00017  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00018  * and/or sell copies of the Software, and to permit persons to whom the
    00019  * Software is furnished to do so, subject to the following conditions:
    00020  *
    00021  * The above copyright notice and this permission notice shall be included
    00022  * in all copies or substantial portions of the Software.
    00023  *
    00024  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00025  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00026  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    00027  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00028  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00029  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00030  * DEALINGS IN THE SOFTWARE.
    00031  ****************************************************************************/
    00032
    00033 #ifndef CPL_VSI_VIRTUAL_H_INCLUDED
    00034 #define CPL_VSI_VIRTUAL_H_INCLUDED
    00035
    00036 #include "cpl_vsi.h"
    00037
    00038 #if defined(WIN32CE)
    00039 #  include "cpl_wince.h"
    00040 #  include <wce_errno.h>
    00041 #  pragma warning(disable:4786) /* Remove annoying warnings in eVC++ and VC++ 6.0 */
    00042 #endif
    00043
    00044 #include <map>
    00045 #include <vector>
    00046 #include <string>
    00047
    00048 /************************************************************************/
    00049 /*                           VSIVirtualHandle                           */
    00050 /************************************************************************/
    00051
    00052 class CPL_DLL VSIVirtualHandle {
    00053   public:
    00054     virtual int       Seek( vsi_l_offset nOffset, int nWhence ) = 0;
    00055     virtual vsi_l_offset Tell() = 0;
    00056     virtual size_t    Read( void *pBuffer, size_t nSize, size_t nMemb ) = 0;
    00057     virtual size_t    Write( const void *pBuffer, size_t nSize,size_t nMemb)=0;
    00058     virtual int       Eof() = 0;
    00059     virtual int       Flush() {return 0;}
    00060     virtual int       Close() = 0;
    00061     virtual           ~VSIVirtualHandle() { }
    00062 };
    00063
    00064 /************************************************************************/
    00065 /*                         VSIFilesystemHandler                         */
    00066 /************************************************************************/
    00067
    00068 class CPL_DLL VSIFilesystemHandler {
    00069
    00070 public:
    00071
    00072     virtual ~VSIFilesystemHandler() {}
    00073
    00074     virtual VSIVirtualHandle *Open( const char *pszFilename,
    00075                                     const char *pszAccess) = 0;
    00076     virtual int Stat( const char *pszFilename, VSIStatBufL *pStatBuf) = 0;
    00077     virtual int Unlink( const char *pszFilename )
    00078                       { errno=ENOENT; return -1; }
    00079     virtual int Mkdir( const char *pszDirname, long nMode )
    00080                      { errno=ENOENT; return -1; }
    00081     virtual int Rmdir( const char *pszDirname )
    00082                      { errno=ENOENT; return -1; }
    00083     virtual char **ReadDir( const char *pszDirname )
    00084                           { return NULL; }
    00085     virtual int Rename( const char *oldpath, const char *newpath )
    00086                       { errno=ENOENT; return -1; }
    00087 };
    00088
    00089 /************************************************************************/
    00090 /*                            VSIFileManager                            */
    00091 /************************************************************************/
    00092
    00093 class CPL_DLL VSIFileManager
    00094 {
    00095 private:
    00096     VSIFilesystemHandler *poDefaultHandler;
    00097     std::map<std::string, VSIFilesystemHandler *> oHandlers;
    00098
    00099     VSIFileManager();
    00100
    00101     static VSIFileManager *Get();
    00102
    00103 public:
    00104     ~VSIFileManager();
    00105
    00106     static VSIFilesystemHandler *GetHandler( const char * );
    00107     static void InstallHandler( const std::string& osPrefix,
    00108                                 VSIFilesystemHandler * );
    00109     static void RemoveHandler( const std::string& osPrefix );
    00110 };
    00111
    00112 #endif /* ndef CPL_VSI_VIRTUAL_H_INCLUDED */

Generated for GDAL by 1.5.7.1.