FileSpec.h 2.24 KB
Newer Older
1 2 3 4 5 6 7 8
//========================================================================
//
// FileSpec.h
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
9
// Copyright (C) 2017-2019 Albert Astals Cid <aacid@kde.org>
10 11 12 13 14 15 16 17 18 19 20
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
//
//========================================================================

#ifndef FILE_SPEC_H
#define FILE_SPEC_H

#include "Object.h"

21 22
class EmbFile {
public:
23
  EmbFile(Object &&efStream);
24 25
  ~EmbFile();

26 27 28
  EmbFile(const EmbFile &) = delete;
  EmbFile& operator=(const EmbFile &) = delete;

Albert Astals Cid's avatar
Albert Astals Cid committed
29 30 31 32 33
  int size() const { return m_size; }
  const GooString *modDate() const { return m_modDate; }
  const GooString *createDate() const { return m_createDate; }
  const GooString *checksum() const { return m_checksum; }
  const GooString *mimeType() const { return m_mimetype; }
34
  Object *streamObject() { return &m_objStr; }
Albert Astals Cid's avatar
Albert Astals Cid committed
35
  Stream *stream() { return isOk() ? m_objStr.getStream() : nullptr; }
36 37
  bool isOk() const { return m_objStr.isStream(); }
  bool save(const char *path);
38 39

private:
40
  bool save2(FILE *f);
41

42 43 44 45 46 47 48 49 50 51
  int m_size;
  GooString *m_createDate;
  GooString *m_modDate;
  GooString *m_checksum;
  GooString *m_mimetype;
  Object m_objStr;
};

class FileSpec {
public:
Albert Astals Cid's avatar
Albert Astals Cid committed
52
  FileSpec(const Object *fileSpec);
53 54
  ~FileSpec();

55 56 57
  FileSpec(const FileSpec &) = delete;
  FileSpec& operator=(const FileSpec &) = delete;

58
  bool isOk() const { return ok; }
59

Albert Astals Cid's avatar
Albert Astals Cid committed
60
  const GooString *getFileName() const { return fileName; }
61
  GooString *getFileNameForPlatform();
Albert Astals Cid's avatar
Albert Astals Cid committed
62
  const GooString *getDescription() const { return desc; }
63 64
  EmbFile *getEmbeddedFile();

Albert Astals Cid's avatar
Albert Astals Cid committed
65 66
  static Object newFileSpecObject(XRef *xref, GooFile *file, const std::string &fileName);

67
private:
68
  bool ok;
69 70 71 72 73 74 75 76 77 78

  Object fileSpec;

  GooString *fileName;         // F, UF, DOS, Mac, Unix
  GooString *platformFileName;
  Object fileStream;           // Ref to F entry in UF
  EmbFile *embFile;
  GooString *desc;             // Desc
};

Albert Astals Cid's avatar
Albert Astals Cid committed
79 80
Object getFileSpecName (const Object *fileSpec);
Object getFileSpecNameForPlatform (const Object *fileSpec);
81 82

#endif /* FILE_SPEC_H */