Coverage Report

Created: 2026-07-30 07:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poppler/poppler/FileSpec.h
Line
Count
Source
1
//========================================================================
2
//
3
// FileSpec.h
4
//
5
// All changes made under the Poppler project to this file are licensed
6
// under GPL version 2 or later
7
//
8
// Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
9
// Copyright (C) 2017-2019, 2021, 2024 Albert Astals Cid <aacid@kde.org>
10
// Copyright (C) 2024, 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
11
//
12
// To see a description of the changes please see the Changelog file that
13
// came with your tarball or type make ChangeLog if you are building from git
14
//
15
//========================================================================
16
17
#ifndef FILE_SPEC_H
18
#define FILE_SPEC_H
19
20
#include "Object.h"
21
#include "poppler_private_export.h"
22
23
class POPPLER_PRIVATE_EXPORT EmbFile
24
{
25
public:
26
    explicit EmbFile(Object &&efStream);
27
    ~EmbFile();
28
29
    EmbFile(const EmbFile &) = delete;
30
    EmbFile &operator=(const EmbFile &) = delete;
31
32
0
    int size() const { return m_size; }
33
0
    const GooString *modDate() const { return m_modDate.get(); }
34
0
    const GooString *createDate() const { return m_createDate.get(); }
35
0
    const GooString *checksum() const { return m_checksum.get(); }
36
0
    const GooString *mimeType() const { return m_mimetype.get(); }
37
0
    Object *streamObject() { return &m_objStr; }
38
0
    Stream *stream() { return isOk() ? m_objStr.getStream() : nullptr; }
39
0
    bool isOk() const { return m_objStr.isStream(); }
40
    bool save(const std::string &path);
41
42
private:
43
    bool save2(FILE *f);
44
45
    int m_size;
46
    std::unique_ptr<GooString> m_createDate;
47
    std::unique_ptr<GooString> m_modDate;
48
    std::unique_ptr<GooString> m_checksum;
49
    std::unique_ptr<GooString> m_mimetype;
50
    Object m_objStr;
51
};
52
53
class POPPLER_PRIVATE_EXPORT FileSpec
54
{
55
public:
56
    explicit FileSpec(const Object *fileSpec);
57
    ~FileSpec();
58
59
    FileSpec(const FileSpec &) = delete;
60
    FileSpec &operator=(const FileSpec &) = delete;
61
62
0
    bool isOk() const { return ok; }
63
64
0
    const GooString *getFileName() const { return fileName.get(); }
65
    GooString *getFileNameForPlatform();
66
0
    const GooString *getDescription() const { return desc.get(); }
67
    EmbFile *getEmbeddedFile();
68
69
    static Object newFileSpecObject(XRef *xref, GooFile *file, const std::string &fileName);
70
71
private:
72
    bool ok;
73
74
    Object fileSpec;
75
76
    std::unique_ptr<GooString> fileName; // F, UF, DOS, Mac, Unix
77
    std::unique_ptr<GooString> platformFileName;
78
    Object fileStream; // Ref to F entry in UF
79
    std::unique_ptr<EmbFile> embFile;
80
    std::unique_ptr<GooString> desc; // Desc
81
};
82
83
Object getFileSpecName(const Object *fileSpec);
84
Object POPPLER_PRIVATE_EXPORT getFileSpecNameForPlatform(const Object *fileSpec);
85
86
#endif /* FILE_SPEC_H */