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 Albert Astals Cid <aacid@kde.org> |
10 | // Copyright (C) 2024 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 | int size() const { return m_size; } |
33 | const GooString *modDate() const { return m_modDate; } |
34 | const GooString *createDate() const { return m_createDate; } |
35 | const GooString *checksum() const { return m_checksum; } |
36 | const GooString *mimeType() const { return m_mimetype; } |
37 | Object *streamObject() { return &m_objStr; } |
38 | Stream *stream() { return isOk() ? m_objStr.getStream() : nullptr; } |
39 | 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 | GooString *m_createDate; |
47 | GooString *m_modDate; |
48 | GooString *m_checksum; |
49 | 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 | bool isOk() const { return ok; } |
63 | |
64 | const GooString *getFileName() const { return fileName; } |
65 | GooString *getFileNameForPlatform(); |
66 | const GooString *getDescription() const { return desc; } |
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 | GooString *fileName; // F, UF, DOS, Mac, Unix |
77 | GooString *platformFileName; |
78 | Object fileStream; // Ref to F entry in UF |
79 | EmbFile *embFile; |
80 | 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 */ |
87 | |