GDAL
gdal_openinfo.h
1/******************************************************************************
2 *
3 * Name: gdal_openinfo.h
4 * Project: GDAL Core
5 * Purpose: Declaration of GDALOpenInfo class
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1998, Frank Warmerdam
10 * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef GDALOPENINFO_H_INCLUDED
16#define GDALOPENINFO_H_INCLUDED
17
18#include "cpl_port.h"
19
20#include "gdal.h"
21
22struct VSIVirtualHandle;
23
24/* ******************************************************************** */
25/* GDALOpenInfo */
26/* ******************************************************************** */
27
29class CPL_DLL GDALOpenInfo
30{
31 bool bHasGotSiblingFiles = false;
32 char **papszSiblingFiles = nullptr;
33 int nHeaderBytesTried = 0;
34
35 void Init(const char *const *papszSiblingFilesIn,
36 std::unique_ptr<VSIVirtualHandle> poFile);
37
38 public:
39 GDALOpenInfo(const char *pszFile, int nOpenFlagsIn,
40 const char *const *papszSiblingFilesIn = nullptr);
41 GDALOpenInfo(const char *pszFile, int nOpenFlagsIn,
42 std::unique_ptr<VSIVirtualHandle> poFile);
44
46 char *pszFilename = nullptr;
47
49 std::string osExtension{};
50
52 char **papszOpenOptions = nullptr;
53
57 int nOpenFlags = 0;
58
60 bool bStatOK = false;
62 bool bIsDirectory = false;
63
65 VSILFILE *fpL = nullptr;
66
68 int nHeaderBytes = 0;
70 GByte *pabyHeader = nullptr;
71
73 const char *const *papszAllowedDrivers = nullptr;
74
75 int TryToIngest(int nBytes);
76 char **GetSiblingFiles();
77 char **StealSiblingFiles();
78 bool AreSiblingFilesLoaded() const;
79
80 bool IsSingleAllowedDriver(const char *pszDriverName) const;
81
85 inline bool IsExtensionEqualToCI(const char *pszExt) const
86 {
87 return EQUAL(osExtension.c_str(), pszExt);
88 }
89
90 private:
92};
93
94#endif
Class for dataset open functions.
Definition gdal_openinfo.h:30
GByte * pabyHeader
Buffer with first bytes of the file.
Definition gdal_openinfo.h:70
bool bIsDirectory
Whether the file is a directory.
Definition gdal_openinfo.h:62
char ** GetSiblingFiles()
Return sibling files.
Definition gdalopeninfo.cpp:436
GDALOpenInfo(const char *pszFile, int nOpenFlagsIn, const char *const *papszSiblingFilesIn=nullptr)
Constructor/.
Definition gdalopeninfo.cpp:153
char ** papszOpenOptions
Open options.
Definition gdal_openinfo.h:52
GDALAccess eAccess
Access flag.
Definition gdal_openinfo.h:55
int nOpenFlags
Open flags.
Definition gdal_openinfo.h:57
bool IsExtensionEqualToCI(const char *pszExt) const
Return whether the extension of the file is equal to pszExt, using case-insensitive comparison.
Definition gdal_openinfo.h:85
bool AreSiblingFilesLoaded() const
Return whether sibling files have been loaded.
Definition gdalopeninfo.cpp:489
std::string osExtension
Result of CPLGetExtension(pszFilename);.
Definition gdal_openinfo.h:49
VSILFILE * fpL
Pointer to the file.
Definition gdal_openinfo.h:65
char * pszFilename
Filename.
Definition gdal_openinfo.h:46
bool bStatOK
Whether stat()'ing the file was successful.
Definition gdal_openinfo.h:60
int TryToIngest(int nBytes)
Ingest bytes from the file.
Definition gdalopeninfo.cpp:502
char ** StealSiblingFiles()
Return sibling files and steal reference.
Definition gdalopeninfo.cpp:475
bool IsSingleAllowedDriver(const char *pszDriverName) const
Returns true if the driver name is the single in the list of allowed drivers.
Definition gdalopeninfo.cpp:530
int nHeaderBytes
Number of bytes in pabyHeader.
Definition gdal_openinfo.h:68
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all).
Definition gdal_openinfo.h:73
Core portability definitions for CPL.
#define EQUAL(a, b)
Alias for strcasecmp() == 0.
Definition cpl_port.h:532
#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:1101
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:165
struct VSIVirtualHandle VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition cpl_vsi.h:141
Public (C callable) GDAL entry points.
GDALAccess
Definition gdal.h:120
@ GA_ReadOnly
Definition gdal.h:121
Virtual file handle.
Definition cpl_vsi_virtual.h:48