GDAL

cpl_vsi_virtual.h
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
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
69 virtual void AdviseRead(CPL_UNUSED int nRanges,
70 CPL_UNUSED const vsi_l_offset *panOffsets,
71 CPL_UNUSED const size_t *panSizes)
72 {
73 }
74
87 virtual size_t GetAdviseReadTotalBytesLimit() const
88 {
89 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 virtual int Flush()
104 {
105 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 virtual void *GetNativeFileDescriptor()
113 {
114 return nullptr;
115 }
116
117 virtual VSIRangeStatus GetRangeStatus(CPL_UNUSED vsi_l_offset nOffset,
118 CPL_UNUSED vsi_l_offset nLength)
119 {
120 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
131 virtual void Interrupt()
132 {
133 }
134
138 virtual void CancelCreation()
139 {
140 }
141
142 // NOTE: when adding new methods, besides the "actual" implementations,
143 // also consider the VSICachedFile and VSIVirtualHandleOnlyVisibleAtCloseTime one.
144
145 virtual ~VSIVirtualHandle()
146 {
147 }
148};
149
150/************************************************************************/
151/* VSIVirtualHandleCloser */
152/************************************************************************/
153
156 struct VSIVirtualHandleCloser
157
158{
160 void operator()(VSIVirtualHandle *poHandle)
161 {
162 if (poHandle)
163 {
164 poHandle->Close();
165 delete poHandle;
166 }
167 }
168};
169
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 : m_nativeHandle(std::move(nativeHandle))
187 {
188 }
189
190 int Seek(vsi_l_offset nOffset, int nWhence) override
191 {
192 return m_nativeHandle->Seek(nOffset, nWhence);
193 }
194
195 vsi_l_offset Tell() override
196 {
197 return m_nativeHandle->Tell();
198 }
199
200 size_t Read(void *pBuffer, size_t nSize, size_t nCount) override
201 {
202 return m_nativeHandle->Read(pBuffer, nSize, nCount);
203 }
204
205 int ReadMultiRange(int nRanges, void **ppData,
206 const vsi_l_offset *panOffsets,
207 const size_t *panSizes) override
208 {
209 return m_nativeHandle->ReadMultiRange(nRanges, ppData, panOffsets,
210 panSizes);
211 }
212
213 void AdviseRead(int nRanges, const vsi_l_offset *panOffsets,
214 const size_t *panSizes) override
215 {
216 return m_nativeHandle->AdviseRead(nRanges, panOffsets, panSizes);
217 }
218
219 size_t GetAdviseReadTotalBytesLimit() const override
220 {
221 return m_nativeHandle->GetAdviseReadTotalBytesLimit();
222 }
223
224 size_t Write(const void *pBuffer, size_t nSize, size_t nCount) override
225 {
226 return m_nativeHandle->Write(pBuffer, nSize, nCount);
227 }
228
229 void ClearErr() override
230 {
231 return m_nativeHandle->ClearErr();
232 }
233
234 int Eof() override
235 {
236 return m_nativeHandle->Eof();
237 }
238
239 int Error() override
240 {
241 return m_nativeHandle->Error();
242 }
243
244 int Flush() override
245 {
246 return m_nativeHandle->Flush();
247 }
248
249 int Close() override
250 {
251 return m_nativeHandle->Close();
252 }
253
254 int Truncate(vsi_l_offset nNewSize) override
255 {
256 return m_nativeHandle->Truncate(nNewSize);
257 }
258
259 void *GetNativeFileDescriptor() override
260 {
261 return m_nativeHandle->GetNativeFileDescriptor();
262 }
263
264 VSIRangeStatus GetRangeStatus(vsi_l_offset nOffset,
265 vsi_l_offset nLength) override
266 {
267 return m_nativeHandle->GetRangeStatus(nOffset, nLength);
268 }
269
270 bool HasPRead() const override
271 {
272 return m_nativeHandle->HasPRead();
273 }
274
275 size_t PRead(void *pBuffer, size_t nSize,
276 vsi_l_offset nOffset) const override
277 {
278 return m_nativeHandle->PRead(pBuffer, nSize, nOffset);
279 }
280
281 void Interrupt() override
282 {
283 m_nativeHandle->Interrupt();
284 }
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 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 {
319 (void)pszFilename;
320 errno = ENOENT;
321 return -1;
322 }
323
324 virtual int *UnlinkBatch(CSLConstList papszFiles);
325
326 virtual int Mkdir(const char *pszDirname, long nMode)
327 {
328 (void)pszDirname;
329 (void)nMode;
330 errno = ENOENT;
331 return -1;
332 }
333
334 virtual int Rmdir(const char *pszDirname)
335 {
336 (void)pszDirname;
337 errno = ENOENT;
338 return -1;
339 }
340
341 virtual int RmdirRecursive(const char *pszDirname);
342
343 char **ReadDir(const char *pszDirname)
344 {
345 return ReadDirEx(pszDirname, 0);
346 }
347
348 virtual char **ReadDirEx(const char * /*pszDirname*/, int /* nMaxFiles */)
349 {
350 return nullptr;
351 }
352
353 virtual char **SiblingFiles(const char * /*pszFilename*/)
354 {
355 return nullptr;
356 }
357
358 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 errno = ENOENT;
366 return -1;
367 }
368
369 virtual int IsCaseSensitive(const char *pszFilename)
370 {
371 (void)pszFilename;
372 return TRUE;
373 }
374
375 virtual GIntBig GetDiskFreeSpace(const char * /* pszDirname */)
376 {
377 return -1;
378 }
379
380 virtual int SupportsSparseFiles(const char * /* pszPath */)
381 {
382 return FALSE;
383 }
384
385 virtual int HasOptimizedReadMultiRange(const char * /* pszPath */)
386 {
387 return FALSE;
388 }
389
390 virtual const char *GetActualURL(const char * /*pszFilename*/)
391 {
392 return nullptr;
393 }
394
395 virtual const char *GetOptions()
396 {
397 return nullptr;
398 }
399
400 virtual char *GetSignedURL(const char * /*pszFilename*/,
401 CSLConstList /* papszOptions */)
402 {
403 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 virtual bool AbortPendingUploads(const char * /*pszFilename*/)
460 {
461 return true;
462 }
463
464 virtual std::string
465 GetStreamingFilename(const std::string &osFilename) const
466 {
467 return osFilename;
468 }
469
470 virtual std::string
471 GetNonStreamingFilename(const std::string &osFilename) const
472 {
473 return osFilename;
474 }
475
483 virtual std::string
484 GetCanonicalFilename(const std::string &osFilename) const
485 {
486 return osFilename;
487 }
488
489 virtual bool IsLocal(const char * /* pszPath */) const
490 {
491 return true;
492 }
493
494 virtual bool IsArchive(const char * /* pszPath */) const
495 {
496 return false;
497 }
498
499 virtual bool SupportsSequentialWrite(const char * /* pszPath */,
500 bool /* bAllowLocalTempFile */)
501 {
502 return true;
503 }
504
505 virtual bool SupportsRandomWrite(const char * /* pszPath */,
506 bool /* bAllowLocalTempFile */)
507 {
508 return true;
509 }
510
511 virtual bool SupportsRead(const char * /* pszPath */)
512 {
513 return true;
514 }
515
516 virtual VSIFilesystemHandler *Duplicate(const char * /* pszPrefix */)
517 {
518 CPLError(CE_Failure, CPLE_NotSupported,
519 "Duplicate() not supported on this file "
520 "system");
521 return nullptr;
522 }
523
530 virtual const char *GetDirectorySeparator(CPL_UNUSED const char *pszPath)
531 {
532 return "/";
533 }
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 VSIFilesystemHandler *poDefaultHandler = nullptr;
546 std::map<std::string, VSIFilesystemHandler *> oHandlers{};
547
548 VSIFileManager();
549
550 static VSIFileManager *Get();
551
552 CPL_DISALLOW_COPY_ASSIGN(VSIFileManager)
553
554 public:
555 ~VSIFileManager();
556
557 static VSIFilesystemHandler *GetHandler(const char *);
558 static void InstallHandler(const std::string &osPrefix,
559 VSIFilesystemHandler *);
560 static void RemoveHandler(const std::string &osPrefix);
561
562 static char **GetPrefixes();
563};
564#endif /* #ifndef DOXYGEN_SKIP */
565
566/************************************************************************/
567/* ==================================================================== */
568/* VSIArchiveFilesystemHandler */
569/* ==================================================================== */
570/************************************************************************/
571
572#ifndef DOXYGEN_SKIP
573
574 class VSIArchiveEntryFileOffset
575{
576 public:
577 virtual ~VSIArchiveEntryFileOffset();
578};
579
580 class VSIArchiveEntry
581{
582 public:
583 std::string fileName{};
584 vsi_l_offset uncompressed_size = 0;
585 std::unique_ptr<VSIArchiveEntryFileOffset> file_pos{};
586 bool bIsDir = false;
587 GIntBig nModifiedTime = 0;
588};
589
590 class VSIArchiveContent
591{
592 public:
593 time_t mTime = 0;
594 vsi_l_offset nFileSize = 0;
595 std::vector<VSIArchiveEntry> entries{};
596
597 // Store list of child indices for each directory
598 using DirectoryChildren = std::vector<int>;
599
600 std::map<std::string, DirectoryChildren> dirIndex{};
601
602 VSIArchiveContent() = default;
603
604 ~VSIArchiveContent();
605
606 private:
607 CPL_DISALLOW_COPY_ASSIGN(VSIArchiveContent)
608};
609
610 class VSIArchiveReader
611{
612 public:
613 virtual ~VSIArchiveReader();
614
615 virtual int GotoFirstFile() = 0;
616 virtual int GotoNextFile() = 0;
617 virtual VSIArchiveEntryFileOffset *GetFileOffset() = 0;
618 virtual GUIntBig GetFileSize() = 0;
619 virtual CPLString GetFileName() = 0;
620 virtual GIntBig GetModifiedTime() = 0;
621 virtual int GotoFileOffset(VSIArchiveEntryFileOffset *pOffset) = 0;
622};
623
624 class VSIArchiveFilesystemHandler /* non final */ : public VSIFilesystemHandler
625{
626 CPL_DISALLOW_COPY_ASSIGN(VSIArchiveFilesystemHandler)
627
628 bool FindFileInArchive(const char *archiveFilename,
629 const char *fileInArchiveName,
630 const VSIArchiveEntry **archiveEntry);
631
632 protected:
633 mutable std::recursive_mutex oMutex{};
634
635 /* We use a cache that contains the list of files contained in a VSIArchive
636 * file as */
637 /* unarchive.c is quite inefficient in listing them. This speeds up access
638 * to VSIArchive files */
639 /* containing ~1000 files like a CADRG product */
640 std::map<CPLString, std::unique_ptr<VSIArchiveContent>> oFileList{};
641
642 virtual const char *GetPrefix() const = 0;
643 virtual std::vector<CPLString> GetExtensions() const = 0;
644 virtual std::unique_ptr<VSIArchiveReader>
645 CreateReader(const char *pszArchiveFileName) = 0;
646
647 public:
648 VSIArchiveFilesystemHandler();
649 ~VSIArchiveFilesystemHandler() override;
650
651 int Stat(const char *pszFilename, VSIStatBufL *pStatBuf,
652 int nFlags) override;
653 char **ReadDirEx(const char *pszDirname, int nMaxFiles) override;
654
655 virtual const VSIArchiveContent *
656 GetContentOfArchive(const char *archiveFilename,
657 VSIArchiveReader *poReader = nullptr);
658 virtual char *SplitFilename(const char *pszFilename,
659 CPLString &osFileInArchive,
660 bool bCheckMainFileExists,
661 bool bSetError) const;
662 virtual std::unique_ptr<VSIArchiveReader>
663 OpenArchiveFile(const char *archiveFilename, const char *fileInArchiveName);
664
665 bool IsLocal(const char *pszPath) const override;
666
667 bool IsArchive(const char *pszPath) const override;
668
669 bool SupportsSequentialWrite(const char * /* pszPath */,
670 bool /* bAllowLocalTempFile */) override
671 {
672 return false;
673 }
674
675 bool SupportsRandomWrite(const char * /* pszPath */,
676 bool /* bAllowLocalTempFile */) override
677 {
678 return false;
679 }
680};
681
682/************************************************************************/
683/* VSIDIR */
684/************************************************************************/
685
686 struct CPL_DLL VSIDIR
687{
688 VSIDIR() = default;
689 virtual ~VSIDIR();
690
691 virtual const VSIDIREntry *NextDirEntry() = 0;
692
693 private:
694 VSIDIR(const VSIDIR &) = delete;
695 VSIDIR &operator=(const VSIDIR &) = delete;
696};
697
698#endif /* #ifndef DOXYGEN_SKIP */
699
700 VSIVirtualHandle CPL_DLL *
701VSICreateBufferedReaderHandle(VSIVirtualHandle *poBaseHandle);
702 VSIVirtualHandle *
703VSICreateBufferedReaderHandle(VSIVirtualHandle *poBaseHandle,
704 const GByte *pabyBeginningContent,
705 vsi_l_offset nCheatFileSize);
706 constexpr int VSI_CACHED_DEFAULT_CHUNK_SIZE = 32768;
707 VSIVirtualHandle CPL_DLL *
708VSICreateCachedFile(VSIVirtualHandle *poBaseHandle,
709 size_t nChunkSize = VSI_CACHED_DEFAULT_CHUNK_SIZE,
710 size_t nCacheSize = 0);
711
712 const int CPL_DEFLATE_TYPE_GZIP = 0;
713 const int CPL_DEFLATE_TYPE_ZLIB = 1;
714 const int CPL_DEFLATE_TYPE_RAW_DEFLATE = 2;
715 VSIVirtualHandle CPL_DLL *VSICreateGZipWritable(VSIVirtualHandle *poBaseHandle,
716 int nDeflateType,
717 int bAutoCloseBaseHandle);
718
719 VSIVirtualHandle *VSICreateGZipWritable(VSIVirtualHandle *poBaseHandle,
720 int nDeflateType,
721 bool bAutoCloseBaseHandle, int nThreads,
722 size_t nChunkSize,
723 size_t nSOZIPIndexEltSize,
724 std::vector<uint8_t> *panSOZIPIndex);
725
726 VSIVirtualHandle *
727VSICreateUploadOnCloseFile(VSIVirtualHandleUniquePtr &&poWritableHandle,
728 VSIVirtualHandleUniquePtr &&poTmpFile,
729 const std::string &osTmpFilename);
730
731#endif /* ndef CPL_VSI_VIRTUAL_H_INCLUDED */
CPLString
Convenient string class based on std::string.
Definition cpl_string.h:320
CPLE_NotSupported
#define CPLE_NotSupported
Not supported.
Definition cpl_error.h:95
GUIntBig
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition cpl_port.h:208
CPL_UNUSED
#define CPL_UNUSED
Qualifier for an argument that is unused.
Definition cpl_port.h:879
CPL_FORMAT_STRING
#define CPL_FORMAT_STRING(arg)
Macro into which to wrap the format argument of a printf-like function.
Definition cpl_port.h:860
CPL_PRINT_FUNC_FORMAT
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition cpl_port.h:844
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:936
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
GByte
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
cpl_string.h
Various convenience functions for working with strings and string lists.
cpl_vsi.h
Standard C Covers.
VSIStatBufL
#define VSIStatBufL
Type for VSIStatL()
Definition cpl_vsi.h:195
VSIRangeStatus
VSIRangeStatus
Range status.
Definition cpl_vsi.h:174
VSI_RANGE_STATUS_UNKNOWN
@ VSI_RANGE_STATUS_UNKNOWN
Unknown.
Definition cpl_vsi.h:175
VSIDIR
struct VSIDIR VSIDIR
Opaque type for a directory iterator.
Definition cpl_vsi.h:396
vsi_l_offset
GUIntBig vsi_l_offset
Type for a file offset.
Definition cpl_vsi.h:136
VSIDIREntry
Directory entry.
Definition cpl_vsi.h:408
VSIVirtualHandleCloser
Helper close to use with a std:unique_ptr<VSIVirtualHandle>, such as VSIVirtualHandleUniquePtr.
Definition cpl_vsi_virtual.h:158
VSIVirtualHandleCloser::operator()
void operator()(VSIVirtualHandle *poHandle)
Operator () that closes and deletes the file handle.
Definition cpl_vsi_virtual.h:160
VSIVirtualHandle
Virtual file handle.
Definition cpl_vsi_virtual.h:48
VSIVirtualHandle::PRead
virtual size_t PRead(void *pBuffer, size_t nSize, vsi_l_offset nOffset) const
Do a parallel-compatible read operation.
Definition cpl_vsil.cpp:4418
VSIVirtualHandle::CancelCreation
virtual void CancelCreation()
For a file created with CreateOnlyVisibleAtCloseTime(), ask for the file to not be created at all (if...
Definition cpl_vsi_virtual.h:138
VSIVirtualHandle::Error
virtual int Error()=0
Test the error indicator.
VSIVirtualHandle::Flush
virtual int Flush()
Flush pending writes to disk.
Definition cpl_vsi_virtual.h:103
VSIVirtualHandle::HasPRead
virtual bool HasPRead() const
Returns whether this file handle supports the PRead() method.
Definition cpl_vsil.cpp:4392
VSIVirtualHandle::Close
virtual int Close()=0
Close file.
VSIVirtualHandle::GetRangeStatus
virtual VSIRangeStatus GetRangeStatus(vsi_l_offset nOffset, vsi_l_offset nLength)
Return if a given file range contains data or holes filled with zeroes.
Definition cpl_vsi_virtual.h:117
VSIVirtualHandle::Tell
virtual vsi_l_offset Tell()=0
Tell current file offset.
VSIVirtualHandle::Seek
virtual int Seek(vsi_l_offset nOffset, int nWhence)=0
Seek to requested offset.
VSIVirtualHandle::Read
virtual size_t Read(void *pBuffer, size_t nSize, size_t nCount)=0
Read bytes from file.
VSIVirtualHandle::GetNativeFileDescriptor
virtual void * GetNativeFileDescriptor()
Returns the "native" file descriptor for the virtual handle.
Definition cpl_vsi_virtual.h:112
VSIVirtualHandle::GetAdviseReadTotalBytesLimit
virtual size_t GetAdviseReadTotalBytesLimit() const
Return the total maximum number of bytes that AdviseRead() can handle at once.
Definition cpl_vsi_virtual.h:87
VSIVirtualHandle::AdviseRead
virtual void AdviseRead(int nRanges, const vsi_l_offset *panOffsets, const size_t *panSizes)
This method is called when code plans to access soon one or several ranges in a file.
Definition cpl_vsi_virtual.h:69
VSIVirtualHandle::ReadMultiRange
virtual int ReadMultiRange(int nRanges, void **ppData, const vsi_l_offset *panOffsets, const size_t *panSizes)
Read several ranges of bytes from file.
VSIVirtualHandle::Write
virtual size_t Write(const void *pBuffer, size_t nSize, size_t nCount)=0
Write bytes to file.
VSIVirtualHandle::Eof
virtual int Eof()=0
Test for end of file.
VSIVirtualHandle::Interrupt
virtual void Interrupt()
Ask current operations to be interrupted.
Definition cpl_vsi_virtual.h:131
VSIVirtualHandle::Truncate
virtual int Truncate(vsi_l_offset nNewSize)
Truncate/expand the file to the specified size.
VSIVirtualHandle::ClearErr
virtual void ClearErr()=0
Reset the error and end-of-file indicators.