GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

cpl_vsil_plugin.h
1 /******************************************************************************
2 *
3 * Project: CPL - Common Portability Library
4 * Purpose: Declarations for vsi filesystem plugin handlers
5 * Author: Thomas Bonfort <thomas.bonfort@airbus.com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2019, Thomas Bonfort <thomas.bonfort@airbus.com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ****************************************************************************/
28
29 #ifndef CPL_VSIL_PLUGIN_H_INCLUDED
30 #define CPL_VSIL_PLUGIN_H_INCLUDED
31
32 #include "cpl_port.h"
33 #include "cpl_string.h"
34 #include "cpl_vsi.h"
35 #include "cpl_vsi_virtual.h"
36
38
39 namespace cpl {
40
41 /************************************************************************/
42 /* VSIPluginFilesystemHandler */
43 /************************************************************************/
44
45 class VSIPluginHandle;
46
47 class VSIPluginFilesystemHandler : public VSIFilesystemHandler
48 {
49 CPL_DISALLOW_COPY_ASSIGN(VSIPluginFilesystemHandler)
50
51 private:
52 const char* m_Prefix;
53 const VSIFilesystemPluginCallbacksStruct* m_cb;
54
55 protected:
56 friend class VSIPluginHandle;
57 VSIPluginHandle* CreatePluginHandle(void *cbData);
58 const char* GetCallbackFilename(const char* pszFilename);
59 bool IsValidFilename(const char *pszFilename);
60
61 vsi_l_offset Tell( void *pFile );
62 int Seek( void *pFile, vsi_l_offset nOffset, int nWhence );
63 size_t Read( void *pFile, void *pBuffer, size_t nSize, size_t nCount );
64 int ReadMultiRange( void *pFile, int nRanges, void ** ppData, const vsi_l_offset* panOffsets, const size_t* panSizes );
65 VSIRangeStatus GetRangeStatus( void *pFile, vsi_l_offset nOffset, vsi_l_offset nLength );
66 int Eof( void *pFile );
67 size_t Write( void *pFile, const void *pBuffer, size_t nSize,size_t nCount);
68 int Flush( void *pFile );
69 int Truncate( void *pFile, vsi_l_offset nNewSize );
70 int Close( void *pFile );
71
72 public:
73 VSIPluginFilesystemHandler( const char *pszPrefix,
74 const VSIFilesystemPluginCallbacksStruct *cb);
75 ~VSIPluginFilesystemHandler() override;
76
77 VSIVirtualHandle *Open( const char *pszFilename,
78 const char *pszAccess,
79 bool bSetError ) override;
80
81 int Stat ( const char *pszFilename, VSIStatBufL *pStatBuf, int nFlags ) override;
82 int Unlink ( const char * pszFilename ) override;
83 int Rename ( const char * oldpath, const char * /*newpath*/ ) override;
84 int Mkdir ( const char * pszDirname, long nMode ) override;
85 int Rmdir ( const char * pszDirname ) override;
86 char **ReadDir ( const char *pszDirname ) override
87 { return ReadDirEx(pszDirname, 0); }
88 char **ReadDirEx( const char * pszDirname, int nMaxFiles ) override;
89 int HasOptimizedReadMultiRange(const char* pszPath ) override;
90
91 };
92
93 /************************************************************************/
94 /* VSIPluginHandle */
95 /************************************************************************/
96
97 class VSIPluginHandle : public VSIVirtualHandle
98 {
99 CPL_DISALLOW_COPY_ASSIGN(VSIPluginHandle)
100
101 protected:
102 VSIPluginFilesystemHandler* poFS;
103 void *cbData;
104
105 public:
106
107 VSIPluginHandle( VSIPluginFilesystemHandler* poFS, void *cbData);
108 ~VSIPluginHandle() override;
109
110 vsi_l_offset Tell() override;
111 int Seek( vsi_l_offset nOffset, int nWhence ) override;
112 size_t Read( void *pBuffer, size_t nSize, size_t nCount ) override;
113 int ReadMultiRange( int nRanges, void ** ppData, const vsi_l_offset* panOffsets, const size_t* panSizes ) override;
114 VSIRangeStatus GetRangeStatus( vsi_l_offset nOffset, vsi_l_offset nLength ) override;
115 int Eof() override;
116 size_t Write( const void *pBuffer, size_t nSize,size_t nCount) override;
117 int Flush() override;
118 int Truncate( vsi_l_offset nNewSize ) override;
119 int Close() override;
120 };
121
122 } // namespace cpl
123
125
126 #endif // CPL_VSIL_PLUGIN_H_INCLUDED
VSIRangeStatus
VSIRangeStatus
Range status.
Definition: cpl_vsi.h:175
cpl
Definition: cpl_conv.h:367
cpl_vsi.h
Standard C Covers.
cpl_port.h
Core portability definitions for CPL.
VSIVirtualHandle
Virtual file handle.
Definition: cpl_vsi_virtual.h:56
VSIFilesystemPluginCallbacksStruct
struct containing callbacks to used by the handler.
Definition: cpl_vsi.h:504
cpl_string.h
Various convenience functions for working with strings and string lists.
VSIStatBufL
struct VSI_STAT64_T VSIStatBufL
Type for VSIStatL()
Definition: cpl_vsi.h:192
vsi_l_offset
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:140
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:997

Generated for GDAL by 1.8.8.