Coverage Report

Created: 2025-12-31 06:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/port/cpl_vsi_virtual.h
Line
Count
Source
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
25
#include <cstdint>
26
#include <map>
27
#include <memory>
28
#include <mutex>
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
    virtual void AdviseRead(CPL_UNUSED int nRanges,
70
                            CPL_UNUSED const vsi_l_offset *panOffsets,
71
                            CPL_UNUSED const size_t *panSizes)
72
0
    {
73
0
    }
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
    virtual size_t GetAdviseReadTotalBytesLimit() const
88
0
    {
89
0
        return 0;
90
0
    }
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
    virtual int Flush()
104
0
    {
105
0
        return 0;
106
0
    }
107
108
    virtual int Close() = 0;
109
    // Base implementation that only supports file extension.
110
    virtual int Truncate(vsi_l_offset nNewSize);
111
112
    virtual void *GetNativeFileDescriptor()
113
0
    {
114
0
        return nullptr;
115
0
    }
116
117
    virtual VSIRangeStatus GetRangeStatus(CPL_UNUSED vsi_l_offset nOffset,
118
                                          CPL_UNUSED vsi_l_offset nLength)
119
0
    {
120
0
        return VSI_RANGE_STATUS_UNKNOWN;
121
0
    }
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
    virtual void Interrupt()
132
0
    {
133
0
    }
134
135
    /** For a file created with CreateOnlyVisibleAtCloseTime(), ask for the
136
     * file to not be created at all (if possible)
137
     */
138
    virtual void CancelCreation()
139
0
    {
140
0
    }
141
142
    // NOTE: when adding new methods, besides the "actual" implementations,
143
    // also consider the VSICachedFile and VSIVirtualHandleOnlyVisibleAtCloseTime one.
144
145
    virtual ~VSIVirtualHandle()
146
13.1k
    {
147
13.1k
    }
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
    void operator()(VSIVirtualHandle *poHandle)
161
4.50k
    {
162
4.50k
        if (poHandle)
163
4.50k
        {
164
4.50k
            poHandle->Close();
165
4.50k
            delete poHandle;
166
4.50k
        }
167
4.50k
    }
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
    explicit VSIProxyFileHandle(VSIVirtualHandleUniquePtr &&nativeHandle)
186
0
        : m_nativeHandle(std::move(nativeHandle))
187
0
    {
188
0
    }
189
190
    int Seek(vsi_l_offset nOffset, int nWhence) override
191
0
    {
192
0
        return m_nativeHandle->Seek(nOffset, nWhence);
193
0
    }
194
195
    vsi_l_offset Tell() override
196
0
    {
197
0
        return m_nativeHandle->Tell();
198
0
    }
199
200
    size_t Read(void *pBuffer, size_t nSize, size_t nCount) override
201
0
    {
202
0
        return m_nativeHandle->Read(pBuffer, nSize, nCount);
203
0
    }
204
205
    int ReadMultiRange(int nRanges, void **ppData,
206
                       const vsi_l_offset *panOffsets,
207
                       const size_t *panSizes) override
208
0
    {
209
0
        return m_nativeHandle->ReadMultiRange(nRanges, ppData, panOffsets,
210
0
                                              panSizes);
211
0
    }
212
213
    void AdviseRead(int nRanges, const vsi_l_offset *panOffsets,
214
                    const size_t *panSizes) override
215
0
    {
216
0
        return m_nativeHandle->AdviseRead(nRanges, panOffsets, panSizes);
217
0
    }
218
219
    size_t GetAdviseReadTotalBytesLimit() const override
220
0
    {
221
0
        return m_nativeHandle->GetAdviseReadTotalBytesLimit();
222
0
    }
223
224
    size_t Write(const void *pBuffer, size_t nSize, size_t nCount) override
225
0
    {
226
0
        return m_nativeHandle->Write(pBuffer, nSize, nCount);
227
0
    }
228
229
    void ClearErr() override
230
0
    {
231
0
        return m_nativeHandle->ClearErr();
232
0
    }
233
234
    int Eof() override
235
0
    {
236
0
        return m_nativeHandle->Eof();
237
0
    }
238
239
    int Error() override
240
0
    {
241
0
        return m_nativeHandle->Error();
242
0
    }
243
244
    int Flush() override
245
0
    {
246
0
        return m_nativeHandle->Flush();
247
0
    }
248
249
    int Close() override
250
0
    {
251
0
        return m_nativeHandle->Close();
252
0
    }
253
254
    int Truncate(vsi_l_offset nNewSize) override
255
0
    {
256
0
        return m_nativeHandle->Truncate(nNewSize);
257
0
    }
258
259
    void *GetNativeFileDescriptor() override
260
0
    {
261
0
        return m_nativeHandle->GetNativeFileDescriptor();
262
0
    }
263
264
    VSIRangeStatus GetRangeStatus(vsi_l_offset nOffset,
265
                                  vsi_l_offset nLength) override
266
0
    {
267
0
        return m_nativeHandle->GetRangeStatus(nOffset, nLength);
268
0
    }
269
270
    bool HasPRead() const override
271
0
    {
272
0
        return m_nativeHandle->HasPRead();
273
0
    }
274
275
    size_t PRead(void *pBuffer, size_t nSize,
276
                 vsi_l_offset nOffset) const override
277
0
    {
278
0
        return m_nativeHandle->PRead(pBuffer, nSize, nOffset);
279
0
    }
280
281
    void Interrupt() override
282
0
    {
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
0
    virtual ~VSIFilesystemHandler() = default;
300
301
    static VSIVirtualHandleUniquePtr
302
    OpenStatic(const char *pszFilename, const char *pszAccess,
303
               bool bSetError = false, CSLConstList papszOptions = nullptr);
304
305
    virtual VSIVirtualHandleUniquePtr
306
    Open(const char *pszFilename, const char *pszAccess, bool bSetError = false,
307
         CSLConstList papszOptions = nullptr) = 0;
308
309
    virtual VSIVirtualHandleUniquePtr
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
    virtual int Unlink(const char *pszFilename)
318
0
    {
319
0
        (void)pszFilename;
320
0
        errno = ENOENT;
321
0
        return -1;
322
0
    }
323
324
    virtual int *UnlinkBatch(CSLConstList papszFiles);
325
326
    virtual int Mkdir(const char *pszDirname, long nMode)
327
0
    {
328
0
        (void)pszDirname;
329
0
        (void)nMode;
330
0
        errno = ENOENT;
331
0
        return -1;
332
0
    }
333
334
    virtual int Rmdir(const char *pszDirname)
335
0
    {
336
0
        (void)pszDirname;
337
0
        errno = ENOENT;
338
0
        return -1;
339
0
    }
340
341
    virtual int RmdirRecursive(const char *pszDirname);
342
343
    char **ReadDir(const char *pszDirname)
344
0
    {
345
0
        return ReadDirEx(pszDirname, 0);
346
0
    }
347
348
    virtual char **ReadDirEx(const char * /*pszDirname*/, int /* nMaxFiles */)
349
0
    {
350
0
        return nullptr;
351
0
    }
352
353
    virtual char **SiblingFiles(const char * /*pszFilename*/)
354
0
    {
355
0
        return nullptr;
356
0
    }
357
358
    virtual int Rename(const char *oldpath, const char *newpath,
359
                       GDALProgressFunc pProgressFunc, void *pProgressData)
360
0
    {
361
0
        (void)oldpath;
362
0
        (void)newpath;
363
0
        (void)pProgressFunc;
364
0
        (void)pProgressData;
365
0
        errno = ENOENT;
366
0
        return -1;
367
0
    }
368
369
    virtual int IsCaseSensitive(const char *pszFilename)
370
0
    {
371
0
        (void)pszFilename;
372
0
        return TRUE;
373
0
    }
374
375
    virtual GIntBig GetDiskFreeSpace(const char * /* pszDirname */)
376
0
    {
377
0
        return -1;
378
0
    }
379
380
    virtual int SupportsSparseFiles(const char * /* pszPath */)
381
0
    {
382
0
        return FALSE;
383
0
    }
384
385
    virtual int HasOptimizedReadMultiRange(const char * /* pszPath */)
386
0
    {
387
0
        return FALSE;
388
0
    }
389
390
    virtual const char *GetActualURL(const char * /*pszFilename*/)
391
0
    {
392
0
        return nullptr;
393
0
    }
394
395
    virtual const char *GetOptions()
396
0
    {
397
0
        return nullptr;
398
0
    }
399
400
    virtual char *GetSignedURL(const char * /*pszFilename*/,
401
                               CSLConstList /* papszOptions */)
402
0
    {
403
0
        return nullptr;
404
0
    }
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
    virtual bool AbortPendingUploads(const char * /*pszFilename*/)
460
0
    {
461
0
        return true;
462
0
    }
463
464
    virtual std::string
465
    GetStreamingFilename(const std::string &osFilename) const
466
0
    {
467
0
        return osFilename;
468
0
    }
469
470
    virtual std::string
471
    GetNonStreamingFilename(const std::string &osFilename) const
472
0
    {
473
0
        return osFilename;
474
0
    }
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
    GetCanonicalFilename(const std::string &osFilename) const
485
0
    {
486
0
        return osFilename;
487
0
    }
488
489
    virtual bool IsLocal(const char * /* pszPath */) const
490
0
    {
491
0
        return true;
492
0
    }
493
494
    virtual bool IsArchive(const char * /* pszPath */) const
495
0
    {
496
0
        return false;
497
0
    }
498
499
    virtual bool SupportsSequentialWrite(const char * /* pszPath */,
500
                                         bool /* bAllowLocalTempFile */)
501
0
    {
502
0
        return true;
503
0
    }
504
505
    virtual bool SupportsRandomWrite(const char * /* pszPath */,
506
                                     bool /* bAllowLocalTempFile */)
507
0
    {
508
0
        return true;
509
0
    }
510
511
    virtual bool SupportsRead(const char * /* pszPath */)
512
0
    {
513
0
        return true;
514
0
    }
515
516
    virtual VSIFilesystemHandler *Duplicate(const char * /* pszPrefix */)
517
0
    {
518
0
        CPLError(CE_Failure, CPLE_NotSupported,
519
0
                 "Duplicate() not supported on this file "
520
0
                 "system");
521
0
        return nullptr;
522
0
    }
523
524
    /** Return the directory separator.
525
     *
526
     * Default is forward slash. The only exception currently is the Windows
527
     * file system which returns anti-slash, unless the specified path is of the
528
     * form "{drive_letter}:/{rest_of_the_path}".
529
     */
530
    virtual const char *GetDirectorySeparator(CPL_UNUSED const char *pszPath)
531
22.2k
    {
532
22.2k
        return "/";
533
22.2k
    }
534
};
535
#endif /* #ifndef DOXYGEN_SKIP */
536
537
/************************************************************************/
538
/*                            VSIFileManager                            */
539
/************************************************************************/
540
541
#ifndef DOXYGEN_SKIP
542
class CPL_DLL VSIFileManager
543
{
544
  private:
545
    std::shared_ptr<VSIFilesystemHandler> m_poDefaultHandler{};
546
    std::map<std::string, std::shared_ptr<VSIFilesystemHandler>>
547
        m_apoHandlers{};
548
549
    VSIFileManager();
550
551
    static VSIFileManager *Get();
552
553
    CPL_DISALLOW_COPY_ASSIGN(VSIFileManager)
554
555
  public:
556
    ~VSIFileManager();
557
558
    static VSIFilesystemHandler *GetHandler(const char *);
559
    static void InstallHandler(const std::string &osPrefix,
560
                               const std::shared_ptr<VSIFilesystemHandler> &);
561
    static void InstallHandler(const std::string &osPrefix,
562
                               VSIFilesystemHandler *)
563
        CPL_WARN_DEPRECATED("Use version with std::shared_ptr<> instead");
564
    static void RemoveHandler(const std::string &osPrefix);
565
566
    static char **GetPrefixes();
567
};
568
#endif /* #ifndef DOXYGEN_SKIP */
569
570
/************************************************************************/
571
/* ==================================================================== */
572
/*                       VSIArchiveFilesystemHandler                   */
573
/* ==================================================================== */
574
/************************************************************************/
575
576
#ifndef DOXYGEN_SKIP
577
578
class VSIArchiveEntryFileOffset
579
{
580
  public:
581
    virtual ~VSIArchiveEntryFileOffset();
582
};
583
584
class VSIArchiveEntry
585
{
586
  public:
587
    std::string fileName{};
588
    vsi_l_offset uncompressed_size = 0;
589
    std::unique_ptr<VSIArchiveEntryFileOffset> file_pos{};
590
    bool bIsDir = false;
591
    GIntBig nModifiedTime = 0;
592
};
593
594
class VSIArchiveContent
595
{
596
  public:
597
    time_t mTime = 0;
598
    vsi_l_offset nFileSize = 0;
599
    std::vector<VSIArchiveEntry> entries{};
600
601
    // Store list of child indices for each directory
602
    using DirectoryChildren = std::vector<int>;
603
604
    std::map<std::string, DirectoryChildren> dirIndex{};
605
606
0
    VSIArchiveContent() = default;
607
608
    ~VSIArchiveContent();
609
610
  private:
611
    CPL_DISALLOW_COPY_ASSIGN(VSIArchiveContent)
612
};
613
614
class VSIArchiveReader
615
{
616
  public:
617
    virtual ~VSIArchiveReader();
618
619
    virtual int GotoFirstFile() = 0;
620
    virtual int GotoNextFile() = 0;
621
    virtual VSIArchiveEntryFileOffset *GetFileOffset() = 0;
622
    virtual GUIntBig GetFileSize() = 0;
623
    virtual CPLString GetFileName() = 0;
624
    virtual GIntBig GetModifiedTime() = 0;
625
    virtual int GotoFileOffset(VSIArchiveEntryFileOffset *pOffset) = 0;
626
};
627
628
class VSIArchiveFilesystemHandler /* non final */ : public VSIFilesystemHandler
629
{
630
    CPL_DISALLOW_COPY_ASSIGN(VSIArchiveFilesystemHandler)
631
632
    bool FindFileInArchive(const char *archiveFilename,
633
                           const char *fileInArchiveName,
634
                           const VSIArchiveEntry **archiveEntry);
635
636
  protected:
637
    mutable std::recursive_mutex oMutex{};
638
639
    /* We use a cache that contains the list of files contained in a VSIArchive
640
     * file as */
641
    /* unarchive.c is quite inefficient in listing them. This speeds up access
642
     * to VSIArchive files */
643
    /* containing ~1000 files like a CADRG product */
644
    std::map<CPLString, std::unique_ptr<VSIArchiveContent>> oFileList{};
645
646
    virtual const char *GetPrefix() const = 0;
647
    virtual std::vector<CPLString> GetExtensions() const = 0;
648
    virtual std::unique_ptr<VSIArchiveReader>
649
    CreateReader(const char *pszArchiveFileName) = 0;
650
651
  public:
652
    VSIArchiveFilesystemHandler();
653
    ~VSIArchiveFilesystemHandler() override;
654
655
    int Stat(const char *pszFilename, VSIStatBufL *pStatBuf,
656
             int nFlags) override;
657
    char **ReadDirEx(const char *pszDirname, int nMaxFiles) override;
658
659
    virtual const VSIArchiveContent *
660
    GetContentOfArchive(const char *archiveFilename,
661
                        VSIArchiveReader *poReader = nullptr);
662
    virtual char *SplitFilename(const char *pszFilename,
663
                                CPLString &osFileInArchive,
664
                                bool bCheckMainFileExists,
665
                                bool bSetError) const;
666
    virtual std::unique_ptr<VSIArchiveReader>
667
    OpenArchiveFile(const char *archiveFilename, const char *fileInArchiveName);
668
669
    bool IsLocal(const char *pszPath) const override;
670
671
    bool IsArchive(const char *pszPath) const override;
672
673
    bool SupportsSequentialWrite(const char * /* pszPath */,
674
                                 bool /* bAllowLocalTempFile */) override
675
0
    {
676
0
        return false;
677
0
    }
678
679
    bool SupportsRandomWrite(const char * /* pszPath */,
680
                             bool /* bAllowLocalTempFile */) override
681
0
    {
682
0
        return false;
683
0
    }
684
};
685
686
/************************************************************************/
687
/*                              VSIDIR                                  */
688
/************************************************************************/
689
690
struct CPL_DLL VSIDIR
691
{
692
0
    VSIDIR() = default;
693
    virtual ~VSIDIR();
694
695
    virtual const VSIDIREntry *NextDirEntry() = 0;
696
697
  private:
698
    VSIDIR(const VSIDIR &) = delete;
699
    VSIDIR &operator=(const VSIDIR &) = delete;
700
};
701
702
#endif /* #ifndef DOXYGEN_SKIP */
703
704
VSIVirtualHandle CPL_DLL *
705
VSICreateBufferedReaderHandle(VSIVirtualHandle *poBaseHandle);
706
VSIVirtualHandle *
707
VSICreateBufferedReaderHandle(VSIVirtualHandle *poBaseHandle,
708
                              const GByte *pabyBeginningContent,
709
                              vsi_l_offset nCheatFileSize);
710
constexpr int VSI_CACHED_DEFAULT_CHUNK_SIZE = 32768;
711
VSIVirtualHandle CPL_DLL *
712
VSICreateCachedFile(VSIVirtualHandle *poBaseHandle,
713
                    size_t nChunkSize = VSI_CACHED_DEFAULT_CHUNK_SIZE,
714
                    size_t nCacheSize = 0);
715
716
const int CPL_DEFLATE_TYPE_GZIP = 0;
717
const int CPL_DEFLATE_TYPE_ZLIB = 1;
718
const int CPL_DEFLATE_TYPE_RAW_DEFLATE = 2;
719
VSIVirtualHandle CPL_DLL *VSICreateGZipWritable(VSIVirtualHandle *poBaseHandle,
720
                                                int nDeflateType,
721
                                                int bAutoCloseBaseHandle);
722
723
VSIVirtualHandle *VSICreateGZipWritable(VSIVirtualHandle *poBaseHandle,
724
                                        int nDeflateType,
725
                                        bool bAutoCloseBaseHandle, int nThreads,
726
                                        size_t nChunkSize,
727
                                        size_t nSOZIPIndexEltSize,
728
                                        std::vector<uint8_t> *panSOZIPIndex);
729
730
VSIVirtualHandle *
731
VSICreateUploadOnCloseFile(VSIVirtualHandleUniquePtr &&poWritableHandle,
732
                           VSIVirtualHandleUniquePtr &&poTmpFile,
733
                           const std::string &osTmpFilename);
734
735
#endif /* ndef CPL_VSI_VIRTUAL_H_INCLUDED */