~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to port/cpl_vsi_virtual.h

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: cpl_vsi_virtual.h 15257 2008-08-30 21:15:54Z mloskot $
 
2
 * $Id: cpl_vsi_virtual.h 23467 2011-12-04 22:56:00Z rouault $
3
3
 *
4
4
 * Project:  VSI Virtual File System
5
5
 * Purpose:  Declarations for classes related to the virtual filesystem.
34
34
#define CPL_VSI_VIRTUAL_H_INCLUDED
35
35
 
36
36
#include "cpl_vsi.h"
 
37
#include "cpl_string.h"
37
38
 
38
39
#if defined(WIN32CE)
39
40
#  include "cpl_wince.h"
54
55
    virtual int       Seek( vsi_l_offset nOffset, int nWhence ) = 0;
55
56
    virtual vsi_l_offset Tell() = 0;
56
57
    virtual size_t    Read( void *pBuffer, size_t nSize, size_t nMemb ) = 0;
 
58
    virtual int       ReadMultiRange( int nRanges, void ** ppData, const vsi_l_offset* panOffsets, const size_t* panSizes );
57
59
    virtual size_t    Write( const void *pBuffer, size_t nSize,size_t nMemb)=0;
58
60
    virtual int       Eof() = 0;
59
61
    virtual int       Flush() {return 0;}
60
62
    virtual int       Close() = 0;
 
63
    virtual int       Truncate( vsi_l_offset nNewSize ) { return -1; }
61
64
    virtual           ~VSIVirtualHandle() { }
62
65
};
63
66
 
73
76
 
74
77
    virtual VSIVirtualHandle *Open( const char *pszFilename, 
75
78
                                    const char *pszAccess) = 0;
76
 
    virtual int Stat( const char *pszFilename, VSIStatBufL *pStatBuf) = 0;
 
79
    virtual int Stat( const char *pszFilename, VSIStatBufL *pStatBuf, int nFlags) = 0;
77
80
    virtual int Unlink( const char *pszFilename )
78
 
                      { errno=ENOENT; return -1; }
 
81
                      { (void) pszFilename; errno=ENOENT; return -1; }
79
82
    virtual int Mkdir( const char *pszDirname, long nMode ) 
80
 
                     { errno=ENOENT; return -1; }
 
83
                      {(void)pszDirname; (void)nMode; errno=ENOENT; return -1;}
81
84
    virtual int Rmdir( const char *pszDirname ) 
82
 
                     { errno=ENOENT; return -1; }
 
85
                      { (void) pszDirname; errno=ENOENT; return -1; }
83
86
    virtual char **ReadDir( const char *pszDirname ) 
84
 
                          { return NULL; }
 
87
                      { (void) pszDirname; return NULL; }
85
88
    virtual int Rename( const char *oldpath, const char *newpath )
86
 
                      { errno=ENOENT; return -1; }
 
89
                      { (void) oldpath; (void)newpath; errno=ENOENT; return -1; }
 
90
    virtual int IsCaseSensitive( const char* pszFilename )
 
91
                      { (void) pszFilename; return TRUE; }
87
92
};
88
93
 
89
94
/************************************************************************/
109
114
    static void RemoveHandler( const std::string& osPrefix );
110
115
};
111
116
 
 
117
 
 
118
/************************************************************************/
 
119
/* ==================================================================== */
 
120
/*                       VSIArchiveFilesystemHandler                   */
 
121
/* ==================================================================== */
 
122
/************************************************************************/
 
123
 
 
124
class VSIArchiveEntryFileOffset
 
125
{
 
126
    public:
 
127
        virtual ~VSIArchiveEntryFileOffset();
 
128
};
 
129
 
 
130
typedef struct
 
131
{
 
132
    char         *fileName;
 
133
    vsi_l_offset  uncompressed_size;
 
134
    VSIArchiveEntryFileOffset*      file_pos;
 
135
    int           bIsDir;
 
136
    GIntBig       nModifiedTime;
 
137
} VSIArchiveEntry;
 
138
 
 
139
typedef struct
 
140
{
 
141
    int nEntries;
 
142
    VSIArchiveEntry* entries;
 
143
} VSIArchiveContent;
 
144
 
 
145
class VSIArchiveReader
 
146
{
 
147
    public:
 
148
        virtual ~VSIArchiveReader();
 
149
 
 
150
        virtual int GotoFirstFile() = 0;
 
151
        virtual int GotoNextFile() = 0;
 
152
        virtual VSIArchiveEntryFileOffset* GetFileOffset() = 0;
 
153
        virtual GUIntBig GetFileSize() = 0;
 
154
        virtual CPLString GetFileName() = 0;
 
155
        virtual GIntBig GetModifiedTime() = 0;
 
156
        virtual int GotoFileOffset(VSIArchiveEntryFileOffset* pOffset) = 0;
 
157
};
 
158
 
 
159
class VSIArchiveFilesystemHandler : public VSIFilesystemHandler 
 
160
{
 
161
protected:
 
162
    void* hMutex;
 
163
    /* We use a cache that contains the list of files containes in a VSIArchive file as */
 
164
    /* unarchive.c is quite inefficient in listing them. This speeds up access to VSIArchive files */
 
165
    /* containing ~1000 files like a CADRG product */
 
166
    std::map<CPLString,VSIArchiveContent*>   oFileList;
 
167
 
 
168
    virtual const char* GetPrefix() = 0;
 
169
    virtual std::vector<CPLString> GetExtensions() = 0;
 
170
    virtual VSIArchiveReader* CreateReader(const char* pszArchiveFileName) = 0;
 
171
 
 
172
public:
 
173
    VSIArchiveFilesystemHandler();
 
174
    virtual ~VSIArchiveFilesystemHandler();
 
175
 
 
176
    virtual int      Stat( const char *pszFilename, VSIStatBufL *pStatBuf, int nFlags );
 
177
    virtual int      Unlink( const char *pszFilename );
 
178
    virtual int      Rename( const char *oldpath, const char *newpath );
 
179
    virtual int      Mkdir( const char *pszDirname, long nMode );
 
180
    virtual int      Rmdir( const char *pszDirname );
 
181
    virtual char   **ReadDir( const char *pszDirname );
 
182
 
 
183
    virtual const VSIArchiveContent* GetContentOfArchive(const char* archiveFilename, VSIArchiveReader* poReader = NULL);
 
184
    virtual char* SplitFilename(const char *pszFilename, CPLString &osFileInArchive, int bCheckMainFileExists);
 
185
    virtual VSIArchiveReader* OpenArchiveFile(const char* archiveFilename, const char* fileInArchiveName);
 
186
    virtual int FindFileInArchive(const char* archiveFilename, const char* fileInArchiveName, const VSIArchiveEntry** archiveEntry);
 
187
};
 
188
 
 
189
VSIVirtualHandle* VSICreateBufferedReaderHandle(VSIVirtualHandle* poBaseHandle);
 
190
VSIVirtualHandle* VSICreateCachedFile( VSIVirtualHandle* poBaseHandle );
 
191
 
112
192
#endif /* ndef CPL_VSI_VIRTUAL_H_INCLUDED */