LCOV - code coverage report
Current view: top level - port - cpl_vsi_virtual.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 79 124 63.7 %
Date: 2025-08-01 10:10:57 Functions: 36 58 62.1 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  VSI Virtual File System
       4             :  * Purpose:  Declarations for classes related to the virtual filesystem.
       5             :  *           These would only be normally required by applications implementing
       6             :  *           their own virtual file system classes which should be rare.
       7             :  *           The class interface may be fragile through versions.
       8             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       9             :  *
      10             :  ******************************************************************************
      11             :  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
      12             :  * Copyright (c) 2010-2014, Even Rouault <even dot rouault at spatialys.com>
      13             :  *
      14             :  * SPDX-License-Identifier: MIT
      15             :  ****************************************************************************/
      16             : 
      17             : #ifndef CPL_VSI_VIRTUAL_H_INCLUDED
      18             : #define CPL_VSI_VIRTUAL_H_INCLUDED
      19             : 
      20             : #include "cpl_progress.h"
      21             : #include "cpl_vsi.h"
      22             : #include "cpl_vsi_error.h"
      23             : #include "cpl_string.h"
      24             : #include "cpl_multiproc.h"
      25             : 
      26             : #include <cstdint>
      27             : #include <map>
      28             : #include <memory>
      29             : #include <vector>
      30             : #include <string>
      31             : 
      32             : // To avoid aliasing to GetDiskFreeSpace to GetDiskFreeSpaceA on Windows
      33             : #ifdef GetDiskFreeSpace
      34             : #undef GetDiskFreeSpace
      35             : #endif
      36             : 
      37             : // To avoid aliasing to CopyFile to CopyFileA on Windows
      38             : #ifdef CopyFile
      39             : #undef CopyFile
      40             : #endif
      41             : 
      42             : /************************************************************************/
      43             : /*                           VSIVirtualHandle                           */
      44             : /************************************************************************/
      45             : 
      46             : /** Virtual file handle */
      47             : struct CPL_DLL VSIVirtualHandle
      48             : {
      49             :   public:
      50             :     virtual int Seek(vsi_l_offset nOffset, int nWhence) = 0;
      51             :     virtual vsi_l_offset Tell() = 0;
      52             :     virtual size_t Read(void *pBuffer, size_t nSize, size_t nCount) = 0;
      53             :     virtual int ReadMultiRange(int nRanges, void **ppData,
      54             :                                const vsi_l_offset *panOffsets,
      55             :                                const size_t *panSizes);
      56             : 
      57             :     /** This method is called when code plans to access soon one or several
      58             :      * ranges in a file. Some file systems may be able to use this hint to
      59             :      * for example asynchronously start such requests.
      60             :      *
      61             :      * Offsets may be given in a non-increasing order, and may potentially
      62             :      * overlap.
      63             :      *
      64             :      * @param nRanges Size of the panOffsets and panSizes arrays.
      65             :      * @param panOffsets Array containing the start offset of each range.
      66             :      * @param panSizes Array containing the size (in bytes) of each range.
      67             :      * @since GDAL 3.7
      68             :      */
      69          91 :     virtual void AdviseRead(CPL_UNUSED int nRanges,
      70             :                             CPL_UNUSED const vsi_l_offset *panOffsets,
      71             :                             CPL_UNUSED const size_t *panSizes)
      72             :     {
      73          91 :     }
      74             : 
      75             :     /** Return the total maximum number of bytes that AdviseRead() can handle
      76             :      * at once.
      77             :      *
      78             :      * Some AdviseRead() implementations may give up if the sum of the values
      79             :      * in the panSizes[] array provided to AdviseRead() exceeds a limit.
      80             :      *
      81             :      * Callers might use that threshold to optimize the efficiency of
      82             :      * AdviseRead().
      83             :      *
      84             :      * A returned value of 0 indicates a unknown limit.
      85             :      * @since GDAL 3.9
      86             :      */
      87         219 :     virtual size_t GetAdviseReadTotalBytesLimit() const
      88             :     {
      89         219 :         return 0;
      90             :     }
      91             : 
      92             :     virtual size_t Write(const void *pBuffer, size_t nSize, size_t nCount) = 0;
      93             : 
      94             :     int Printf(CPL_FORMAT_STRING(const char *pszFormat), ...)
      95             :         CPL_PRINT_FUNC_FORMAT(2, 3);
      96             : 
      97             :     virtual void ClearErr() = 0;
      98             : 
      99             :     virtual int Eof() = 0;
     100             : 
     101             :     virtual int Error() = 0;
     102             : 
     103       35498 :     virtual int Flush()
     104             :     {
     105       35498 :         return 0;
     106             :     }
     107             : 
     108             :     virtual int Close() = 0;
     109             :     // Base implementation that only supports file extension.
     110             :     virtual int Truncate(vsi_l_offset nNewSize);
     111             : 
     112           9 :     virtual void *GetNativeFileDescriptor()
     113             :     {
     114           9 :         return nullptr;
     115             :     }
     116             : 
     117         151 :     virtual VSIRangeStatus GetRangeStatus(CPL_UNUSED vsi_l_offset nOffset,
     118             :                                           CPL_UNUSED vsi_l_offset nLength)
     119             :     {
     120         151 :         return VSI_RANGE_STATUS_UNKNOWN;
     121             :     }
     122             : 
     123             :     virtual bool HasPRead() const;
     124             :     virtual size_t PRead(void *pBuffer, size_t nSize,
     125             :                          vsi_l_offset nOffset) const;
     126             : 
     127             :     /** Ask current operations to be interrupted.
     128             :      * Implementations must be thread-safe, as this will typically be called
     129             :      * from another thread than the active one for this file.
     130             :      */
     131          42 :     virtual void Interrupt()
     132             :     {
     133          42 :     }
     134             : 
     135             :     /** For a file created with CreateOnlyVisibleAtCloseTime(), ask for the
     136             :      * file to not be created at all (if possible)
     137             :      */
     138          80 :     virtual void CancelCreation()
     139             :     {
     140          80 :     }
     141             : 
     142             :     // NOTE: when adding new methods, besides the "actual" implementations,
     143             :     // also consider the VSICachedFile and VSIVirtualHandleOnlyVisibleAtCloseTime one.
     144             : 
     145      318306 :     virtual ~VSIVirtualHandle()
     146      318306 :     {
     147      318306 :     }
     148             : };
     149             : 
     150             : /************************************************************************/
     151             : /*                        VSIVirtualHandleCloser                        */
     152             : /************************************************************************/
     153             : 
     154             : /** Helper close to use with a std:unique_ptr<VSIVirtualHandle>,
     155             :  *  such as VSIVirtualHandleUniquePtr. */
     156             : struct VSIVirtualHandleCloser
     157             : 
     158             : {
     159             :     /** Operator () that closes and deletes the file handle. */
     160       16492 :     void operator()(VSIVirtualHandle *poHandle)
     161             :     {
     162       16492 :         if (poHandle)
     163             :         {
     164       16474 :             poHandle->Close();
     165       16474 :             delete poHandle;
     166             :         }
     167       16492 :     }
     168             : };
     169             : 
     170             : /** Unique pointer of VSIVirtualHandle that calls the Close() method */
     171             : typedef std::unique_ptr<VSIVirtualHandle, VSIVirtualHandleCloser>
     172             :     VSIVirtualHandleUniquePtr;
     173             : 
     174             : /************************************************************************/
     175             : /*                        VSIProxyFileHandle                            */
     176             : /************************************************************************/
     177             : 
     178             : #ifndef DOXYGEN_SKIP
     179             : class VSIProxyFileHandle /* non final */ : public VSIVirtualHandle
     180             : {
     181             :   protected:
     182             :     VSIVirtualHandleUniquePtr m_nativeHandle{};
     183             : 
     184             :   public:
     185         667 :     explicit VSIProxyFileHandle(VSIVirtualHandleUniquePtr &&nativeHandle)
     186         667 :         : m_nativeHandle(std::move(nativeHandle))
     187             :     {
     188         667 :     }
     189             : 
     190         782 :     int Seek(vsi_l_offset nOffset, int nWhence) override
     191             :     {
     192         782 :         return m_nativeHandle->Seek(nOffset, nWhence);
     193             :     }
     194             : 
     195         710 :     vsi_l_offset Tell() override
     196             :     {
     197         710 :         return m_nativeHandle->Tell();
     198             :     }
     199             : 
     200         920 :     size_t Read(void *pBuffer, size_t nSize, size_t nCount) override
     201             :     {
     202         920 :         return m_nativeHandle->Read(pBuffer, nSize, nCount);
     203             :     }
     204             : 
     205           0 :     int ReadMultiRange(int nRanges, void **ppData,
     206             :                        const vsi_l_offset *panOffsets,
     207             :                        const size_t *panSizes) override
     208             :     {
     209           0 :         return m_nativeHandle->ReadMultiRange(nRanges, ppData, panOffsets,
     210           0 :                                               panSizes);
     211             :     }
     212             : 
     213           0 :     void AdviseRead(int nRanges, const vsi_l_offset *panOffsets,
     214             :                     const size_t *panSizes) override
     215             :     {
     216           0 :         return m_nativeHandle->AdviseRead(nRanges, panOffsets, panSizes);
     217             :     }
     218             : 
     219           0 :     size_t GetAdviseReadTotalBytesLimit() const override
     220             :     {
     221           0 :         return m_nativeHandle->GetAdviseReadTotalBytesLimit();
     222             :     }
     223             : 
     224       13380 :     size_t Write(const void *pBuffer, size_t nSize, size_t nCount) override
     225             :     {
     226       13380 :         return m_nativeHandle->Write(pBuffer, nSize, nCount);
     227             :     }
     228             : 
     229           0 :     void ClearErr() override
     230             :     {
     231           0 :         return m_nativeHandle->ClearErr();
     232             :     }
     233             : 
     234           0 :     int Eof() override
     235             :     {
     236           0 :         return m_nativeHandle->Eof();
     237             :     }
     238             : 
     239           0 :     int Error() override
     240             :     {
     241           0 :         return m_nativeHandle->Error();
     242             :     }
     243             : 
     244           2 :     int Flush() override
     245             :     {
     246           2 :         return m_nativeHandle->Flush();
     247             :     }
     248             : 
     249         667 :     int Close() override
     250             :     {
     251         667 :         return m_nativeHandle->Close();
     252             :     }
     253             : 
     254           0 :     int Truncate(vsi_l_offset nNewSize) override
     255             :     {
     256           0 :         return m_nativeHandle->Truncate(nNewSize);
     257             :     }
     258             : 
     259           0 :     void *GetNativeFileDescriptor() override
     260             :     {
     261           0 :         return m_nativeHandle->GetNativeFileDescriptor();
     262             :     }
     263             : 
     264           0 :     VSIRangeStatus GetRangeStatus(vsi_l_offset nOffset,
     265             :                                   vsi_l_offset nLength) override
     266             :     {
     267           0 :         return m_nativeHandle->GetRangeStatus(nOffset, nLength);
     268             :     }
     269             : 
     270           0 :     bool HasPRead() const override
     271             :     {
     272           0 :         return m_nativeHandle->HasPRead();
     273             :     }
     274             : 
     275           0 :     size_t PRead(void *pBuffer, size_t nSize,
     276             :                  vsi_l_offset nOffset) const override
     277             :     {
     278           0 :         return m_nativeHandle->PRead(pBuffer, nSize, nOffset);
     279             :     }
     280             : 
     281           0 :     void Interrupt() override
     282             :     {
     283           0 :         m_nativeHandle->Interrupt();
     284           0 :     }
     285             : 
     286             :     void CancelCreation() override;
     287             : };
     288             : #endif
     289             : 
     290             : /************************************************************************/
     291             : /*                         VSIFilesystemHandler                         */
     292             : /************************************************************************/
     293             : 
     294             : #ifndef DOXYGEN_SKIP
     295             : class CPL_DLL VSIFilesystemHandler
     296             : {
     297             : 
     298             :   public:
     299       32540 :     virtual ~VSIFilesystemHandler()
     300       32540 :     {
     301       32540 :     }
     302             : 
     303             :     VSIVirtualHandle *Open(const char *pszFilename, const char *pszAccess);
     304             : 
     305             :     virtual VSIVirtualHandle *Open(const char *pszFilename,
     306             :                                    const char *pszAccess, bool bSetError,
     307             :                                    CSLConstList papszOptions) = 0;
     308             : 
     309             :     virtual VSIVirtualHandle *
     310             :     CreateOnlyVisibleAtCloseTime(const char *pszFilename,
     311             :                                  bool bEmulationAllowed,
     312             :                                  CSLConstList papszOptions);
     313             : 
     314             :     virtual int Stat(const char *pszFilename, VSIStatBufL *pStatBuf,
     315             :                      int nFlags) = 0;
     316             : 
     317           2 :     virtual int Unlink(const char *pszFilename)
     318             :     {
     319             :         (void)pszFilename;
     320           2 :         errno = ENOENT;
     321           2 :         return -1;
     322             :     }
     323             : 
     324             :     virtual int *UnlinkBatch(CSLConstList papszFiles);
     325             : 
     326           0 :     virtual int Mkdir(const char *pszDirname, long nMode)
     327             :     {
     328             :         (void)pszDirname;
     329             :         (void)nMode;
     330           0 :         errno = ENOENT;
     331           0 :         return -1;
     332             :     }
     333             : 
     334           0 :     virtual int Rmdir(const char *pszDirname)
     335             :     {
     336             :         (void)pszDirname;
     337           0 :         errno = ENOENT;
     338           0 :         return -1;
     339             :     }
     340             : 
     341             :     virtual int RmdirRecursive(const char *pszDirname);
     342             : 
     343           5 :     char **ReadDir(const char *pszDirname)
     344             :     {
     345           5 :         return ReadDirEx(pszDirname, 0);
     346             :     }
     347             : 
     348           3 :     virtual char **ReadDirEx(const char * /*pszDirname*/, int /* nMaxFiles */)
     349             :     {
     350           3 :         return nullptr;
     351             :     }
     352             : 
     353       76813 :     virtual char **SiblingFiles(const char * /*pszFilename*/)
     354             :     {
     355       76813 :         return nullptr;
     356             :     }
     357             : 
     358           0 :     virtual int Rename(const char *oldpath, const char *newpath,
     359             :                        GDALProgressFunc pProgressFunc, void *pProgressData)
     360             :     {
     361             :         (void)oldpath;
     362             :         (void)newpath;
     363             :         (void)pProgressFunc;
     364             :         (void)pProgressData;
     365           0 :         errno = ENOENT;
     366           0 :         return -1;
     367             :     }
     368             : 
     369       28005 :     virtual int IsCaseSensitive(const char *pszFilename)
     370             :     {
     371             :         (void)pszFilename;
     372       28005 :         return TRUE;
     373             :     }
     374             : 
     375           0 :     virtual GIntBig GetDiskFreeSpace(const char * /* pszDirname */)
     376             :     {
     377           0 :         return -1;
     378             :     }
     379             : 
     380           0 :     virtual int SupportsSparseFiles(const char * /* pszPath */)
     381             :     {
     382           0 :         return FALSE;
     383             :     }
     384             : 
     385       15308 :     virtual int HasOptimizedReadMultiRange(const char * /* pszPath */)
     386             :     {
     387       15308 :         return FALSE;
     388             :     }
     389             : 
     390           1 :     virtual const char *GetActualURL(const char * /*pszFilename*/)
     391             :     {
     392           1 :         return nullptr;
     393             :     }
     394             : 
     395          14 :     virtual const char *GetOptions()
     396             :     {
     397          14 :         return nullptr;
     398             :     }
     399             : 
     400           1 :     virtual char *GetSignedURL(const char * /*pszFilename*/,
     401             :                                CSLConstList /* papszOptions */)
     402             :     {
     403           1 :         return nullptr;
     404             :     }
     405             : 
     406             :     virtual bool Sync(const char *pszSource, const char *pszTarget,
     407             :                       const char *const *papszOptions,
     408             :                       GDALProgressFunc pProgressFunc, void *pProgressData,
     409             :                       char ***ppapszOutputs);
     410             : 
     411             :     virtual int CopyFile(const char *pszSource, const char *pszTarget,
     412             :                          VSILFILE *fpSource, vsi_l_offset nSourceSize,
     413             :                          const char *const *papszOptions,
     414             :                          GDALProgressFunc pProgressFunc, void *pProgressData);
     415             : 
     416             :     virtual int
     417             :     CopyFileRestartable(const char *pszSource, const char *pszTarget,
     418             :                         const char *pszInputPayload, char **ppszOutputPayload,
     419             :                         CSLConstList papszOptions,
     420             :                         GDALProgressFunc pProgressFunc, void *pProgressData);
     421             : 
     422             :     virtual VSIDIR *OpenDir(const char *pszPath, int nRecurseDepth,
     423             :                             const char *const *papszOptions);
     424             : 
     425             :     virtual char **GetFileMetadata(const char *pszFilename,
     426             :                                    const char *pszDomain,
     427             :                                    CSLConstList papszOptions);
     428             : 
     429             :     virtual bool SetFileMetadata(const char *pszFilename,
     430             :                                  CSLConstList papszMetadata,
     431             :                                  const char *pszDomain,
     432             :                                  CSLConstList papszOptions);
     433             : 
     434             :     virtual bool
     435             :     MultipartUploadGetCapabilities(int *pbNonSequentialUploadSupported,
     436             :                                    int *pbParallelUploadSupported,
     437             :                                    int *pbAbortSupported, size_t *pnMinPartSize,
     438             :                                    size_t *pnMaxPartSize, int *pnMaxPartCount);
     439             : 
     440             :     virtual char *MultipartUploadStart(const char *pszFilename,
     441             :                                        CSLConstList papszOptions);
     442             : 
     443             :     virtual char *MultipartUploadAddPart(const char *pszFilename,
     444             :                                          const char *pszUploadId,
     445             :                                          int nPartNumber,
     446             :                                          vsi_l_offset nFileOffset,
     447             :                                          const void *pData, size_t nDataLength,
     448             :                                          CSLConstList papszOptions);
     449             : 
     450             :     virtual bool
     451             :     MultipartUploadEnd(const char *pszFilename, const char *pszUploadId,
     452             :                        size_t nPartIdsCount, const char *const *apszPartIds,
     453             :                        vsi_l_offset nTotalSize, CSLConstList papszOptions);
     454             : 
     455             :     virtual bool MultipartUploadAbort(const char *pszFilename,
     456             :                                       const char *pszUploadId,
     457             :                                       CSLConstList papszOptions);
     458             : 
     459           0 :     virtual bool AbortPendingUploads(const char * /*pszFilename*/)
     460             :     {
     461           0 :         return true;
     462             :     }
     463             : 
     464             :     virtual std::string
     465       26715 :     GetStreamingFilename(const std::string &osFilename) const
     466             :     {
     467       26715 :         return osFilename;
     468             :     }
     469             : 
     470             :     virtual std::string
     471        1514 :     GetNonStreamingFilename(const std::string &osFilename) const
     472             :     {
     473        1514 :         return osFilename;
     474             :     }
     475             : 
     476             :     /** Return the canonical filename.
     477             :      *
     478             :      * May be implemented by case-insensitive filesystems
     479             :      * (currently Win32 and MacOSX)
     480             :      * to return the filename with its actual case (i.e. the one that would
     481             :      * be used when listing the content of the directory).
     482             :      */
     483             :     virtual std::string
     484         248 :     GetCanonicalFilename(const std::string &osFilename) const
     485             :     {
     486         248 :         return osFilename;
     487             :     }
     488             : 
     489         107 :     virtual bool IsLocal(const char * /* pszPath */)
     490             :     {
     491         107 :         return true;
     492             :     }
     493             : 
     494          48 :     virtual bool SupportsSequentialWrite(const char * /* pszPath */,
     495             :                                          bool /* bAllowLocalTempFile */)
     496             :     {
     497          48 :         return true;
     498             :     }
     499             : 
     500         294 :     virtual bool SupportsRandomWrite(const char * /* pszPath */,
     501             :                                      bool /* bAllowLocalTempFile */)
     502             :     {
     503         294 :         return true;
     504             :     }
     505             : 
     506          43 :     virtual bool SupportsRead(const char * /* pszPath */)
     507             :     {
     508          43 :         return true;
     509             :     }
     510             : 
     511           2 :     virtual VSIFilesystemHandler *Duplicate(const char * /* pszPrefix */)
     512             :     {
     513           2 :         CPLError(CE_Failure, CPLE_NotSupported,
     514             :                  "Duplicate() not supported on this file "
     515             :                  "system");
     516           2 :         return nullptr;
     517             :     }
     518             : 
     519             :     /** Return the directory separator.
     520             :      *
     521             :      * Default is forward slash. The only exception currently is the Windows
     522             :      * file system which returns anti-slash, unless the specified path is of the
     523             :      * form "{drive_letter}:/{rest_of_the_path}".
     524             :      */
     525      922288 :     virtual const char *GetDirectorySeparator(CPL_UNUSED const char *pszPath)
     526             :     {
     527      922288 :         return "/";
     528             :     }
     529             : };
     530             : #endif /* #ifndef DOXYGEN_SKIP */
     531             : 
     532             : /************************************************************************/
     533             : /*                            VSIFileManager                            */
     534             : /************************************************************************/
     535             : 
     536             : #ifndef DOXYGEN_SKIP
     537             : class CPL_DLL VSIFileManager
     538             : {
     539             :   private:
     540             :     VSIFilesystemHandler *poDefaultHandler = nullptr;
     541             :     std::map<std::string, VSIFilesystemHandler *> oHandlers{};
     542             : 
     543             :     VSIFileManager();
     544             : 
     545             :     static VSIFileManager *Get();
     546             : 
     547             :     CPL_DISALLOW_COPY_ASSIGN(VSIFileManager)
     548             : 
     549             :   public:
     550             :     ~VSIFileManager();
     551             : 
     552             :     static VSIFilesystemHandler *GetHandler(const char *);
     553             :     static void InstallHandler(const std::string &osPrefix,
     554             :                                VSIFilesystemHandler *);
     555             :     static void RemoveHandler(const std::string &osPrefix);
     556             : 
     557             :     static char **GetPrefixes();
     558             : };
     559             : #endif /* #ifndef DOXYGEN_SKIP */
     560             : 
     561             : /************************************************************************/
     562             : /* ==================================================================== */
     563             : /*                       VSIArchiveFilesystemHandler                   */
     564             : /* ==================================================================== */
     565             : /************************************************************************/
     566             : 
     567             : #ifndef DOXYGEN_SKIP
     568             : 
     569             : class VSIArchiveEntryFileOffset
     570             : {
     571             :   public:
     572             :     virtual ~VSIArchiveEntryFileOffset();
     573             : };
     574             : 
     575             : typedef struct
     576             : {
     577             :     char *fileName;
     578             :     vsi_l_offset uncompressed_size;
     579             :     VSIArchiveEntryFileOffset *file_pos;
     580             :     int bIsDir;
     581             :     GIntBig nModifiedTime;
     582             : } VSIArchiveEntry;
     583             : 
     584             : class VSIArchiveContent
     585             : {
     586             :   public:
     587             :     time_t mTime = 0;
     588             :     vsi_l_offset nFileSize = 0;
     589             :     int nEntries = 0;
     590             :     VSIArchiveEntry *entries = nullptr;
     591             : 
     592             :     ~VSIArchiveContent();
     593             : };
     594             : 
     595             : class VSIArchiveReader
     596             : {
     597             :   public:
     598             :     virtual ~VSIArchiveReader();
     599             : 
     600             :     virtual int GotoFirstFile() = 0;
     601             :     virtual int GotoNextFile() = 0;
     602             :     virtual VSIArchiveEntryFileOffset *GetFileOffset() = 0;
     603             :     virtual GUIntBig GetFileSize() = 0;
     604             :     virtual CPLString GetFileName() = 0;
     605             :     virtual GIntBig GetModifiedTime() = 0;
     606             :     virtual int GotoFileOffset(VSIArchiveEntryFileOffset *pOffset) = 0;
     607             : };
     608             : 
     609             : class VSIArchiveFilesystemHandler : public VSIFilesystemHandler
     610             : {
     611             :     CPL_DISALLOW_COPY_ASSIGN(VSIArchiveFilesystemHandler)
     612             : 
     613             :   protected:
     614             :     CPLMutex *hMutex = nullptr;
     615             :     /* We use a cache that contains the list of files contained in a VSIArchive
     616             :      * file as */
     617             :     /* unarchive.c is quite inefficient in listing them. This speeds up access
     618             :      * to VSIArchive files */
     619             :     /* containing ~1000 files like a CADRG product */
     620             :     std::map<CPLString, VSIArchiveContent *> oFileList{};
     621             : 
     622             :     virtual const char *GetPrefix() = 0;
     623             :     virtual std::vector<CPLString> GetExtensions() = 0;
     624             :     virtual VSIArchiveReader *CreateReader(const char *pszArchiveFileName) = 0;
     625             : 
     626             :   public:
     627             :     VSIArchiveFilesystemHandler();
     628             :     virtual ~VSIArchiveFilesystemHandler();
     629             : 
     630             :     int Stat(const char *pszFilename, VSIStatBufL *pStatBuf,
     631             :              int nFlags) override;
     632             :     char **ReadDirEx(const char *pszDirname, int nMaxFiles) override;
     633             : 
     634             :     virtual const VSIArchiveContent *
     635             :     GetContentOfArchive(const char *archiveFilename,
     636             :                         VSIArchiveReader *poReader = nullptr);
     637             :     virtual char *SplitFilename(const char *pszFilename,
     638             :                                 CPLString &osFileInArchive,
     639             :                                 bool bCheckMainFileExists, bool bSetError);
     640             :     virtual VSIArchiveReader *OpenArchiveFile(const char *archiveFilename,
     641             :                                               const char *fileInArchiveName);
     642             :     virtual int FindFileInArchive(const char *archiveFilename,
     643             :                                   const char *fileInArchiveName,
     644             :                                   const VSIArchiveEntry **archiveEntry);
     645             : 
     646             :     virtual bool IsLocal(const char *pszPath) override;
     647             : 
     648             :     virtual bool
     649           0 :     SupportsSequentialWrite(const char * /* pszPath */,
     650             :                             bool /* bAllowLocalTempFile */) override
     651             :     {
     652           0 :         return false;
     653             :     }
     654             : 
     655           0 :     virtual bool SupportsRandomWrite(const char * /* pszPath */,
     656             :                                      bool /* bAllowLocalTempFile */) override
     657             :     {
     658           0 :         return false;
     659             :     }
     660             : };
     661             : 
     662             : /************************************************************************/
     663             : /*                              VSIDIR                                  */
     664             : /************************************************************************/
     665             : 
     666             : struct CPL_DLL VSIDIR
     667             : {
     668        3437 :     VSIDIR() = default;
     669             :     virtual ~VSIDIR();
     670             : 
     671             :     virtual const VSIDIREntry *NextDirEntry() = 0;
     672             : 
     673             :   private:
     674             :     VSIDIR(const VSIDIR &) = delete;
     675             :     VSIDIR &operator=(const VSIDIR &) = delete;
     676             : };
     677             : 
     678             : #endif /* #ifndef DOXYGEN_SKIP */
     679             : 
     680             : VSIVirtualHandle CPL_DLL *
     681             : VSICreateBufferedReaderHandle(VSIVirtualHandle *poBaseHandle);
     682             : VSIVirtualHandle *
     683             : VSICreateBufferedReaderHandle(VSIVirtualHandle *poBaseHandle,
     684             :                               const GByte *pabyBeginningContent,
     685             :                               vsi_l_offset nCheatFileSize);
     686             : constexpr int VSI_CACHED_DEFAULT_CHUNK_SIZE = 32768;
     687             : VSIVirtualHandle CPL_DLL *
     688             : VSICreateCachedFile(VSIVirtualHandle *poBaseHandle,
     689             :                     size_t nChunkSize = VSI_CACHED_DEFAULT_CHUNK_SIZE,
     690             :                     size_t nCacheSize = 0);
     691             : 
     692             : const int CPL_DEFLATE_TYPE_GZIP = 0;
     693             : const int CPL_DEFLATE_TYPE_ZLIB = 1;
     694             : const int CPL_DEFLATE_TYPE_RAW_DEFLATE = 2;
     695             : VSIVirtualHandle CPL_DLL *VSICreateGZipWritable(VSIVirtualHandle *poBaseHandle,
     696             :                                                 int nDeflateType,
     697             :                                                 int bAutoCloseBaseHandle);
     698             : 
     699             : VSIVirtualHandle *VSICreateGZipWritable(VSIVirtualHandle *poBaseHandle,
     700             :                                         int nDeflateType,
     701             :                                         bool bAutoCloseBaseHandle, int nThreads,
     702             :                                         size_t nChunkSize,
     703             :                                         size_t nSOZIPIndexEltSize,
     704             :                                         std::vector<uint8_t> *panSOZIPIndex);
     705             : 
     706             : VSIVirtualHandle *
     707             : VSICreateUploadOnCloseFile(VSIVirtualHandleUniquePtr &&poWritableHandle,
     708             :                            VSIVirtualHandleUniquePtr &&poTmpFile,
     709             :                            const std::string &osTmpFilename);
     710             : 
     711             : #endif /* ndef CPL_VSI_VIRTUAL_H_INCLUDED */

Generated by: LCOV version 1.14