Coverage Report

Created: 2026-02-14 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/gcore/gdal_openinfo.h
Line
Count
Source
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
22
struct VSIVirtualHandle;
23
24
/* ******************************************************************** */
25
/*                             GDALOpenInfo                             */
26
/* ******************************************************************** */
27
28
/** Class for dataset open functions. */
29
class 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);
43
    ~GDALOpenInfo();
44
45
    /** Filename */
46
    char *pszFilename = nullptr;
47
48
    /** Result of CPLGetExtension(pszFilename); */
49
    std::string osExtension{};
50
51
    /** Open options */
52
    char **papszOpenOptions = nullptr;
53
54
    /** Access flag */
55
    GDALAccess eAccess = GA_ReadOnly;
56
    /** Open flags */
57
    int nOpenFlags = 0;
58
59
    /** Whether stat()'ing the file was successful */
60
    bool bStatOK = false;
61
    /** Whether the file is a directory */
62
    bool bIsDirectory = false;
63
64
    /** Pointer to the file */
65
    VSILFILE *fpL = nullptr;
66
67
    /** Number of bytes in pabyHeader */
68
    int nHeaderBytes = 0;
69
    /** Buffer with first bytes of the file */
70
    GByte *pabyHeader = nullptr;
71
72
    /** Allowed drivers (NULL for all) */
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
82
    /** Return whether the extension of the file is equal to pszExt, using
83
     * case-insensitive comparison.
84
     * @since 3.11 */
85
    inline bool IsExtensionEqualToCI(const char *pszExt) const
86
0
    {
87
0
        return EQUAL(osExtension.c_str(), pszExt);
88
0
    }
89
90
  private:
91
    CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo)
92
};
93
94
#endif