Krita Source Code Documentation
Loading...
Searching...
No Matches
KisExiv2IODevice.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Sharaf Zaman <shzam@sdf.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef __KISEXIV2IODEVICE_H_
8#define __KISEXIV2IODEVICE_H_
9
10#include <QFile>
11
12#include <exiv2/exiv2.hpp>
13
14#include <kis_global.h>
15
16#include "kritaexifcommon_export.h"
17
18class KRITAEXIFCOMMON_EXPORT KisExiv2IODevice : public Exiv2::BasicIo
19{
20public:
21#if EXIV2_TEST_VERSION(0,28,0)
22 using ptr_type = Exiv2::BasicIo::UniquePtr;
23#else
24 using ptr_type = Exiv2::BasicIo::AutoPtr;
25#endif
26
27 KisExiv2IODevice(QString path);
28 ~KisExiv2IODevice() override;
29
30 int open() override;
31 int close() override;
32#if EXIV2_TEST_VERSION(0,28,0)
33 size_t write(const Exiv2::byte *data, size_t wcount) override;
34 size_t write(Exiv2::BasicIo &src) override;
35 int putb(Exiv2::byte data) override;
36 Exiv2::DataBuf read(size_t rcount) override;
37 size_t read(Exiv2::byte *buf, size_t rcount) override;
38#else
39 long write(const Exiv2::byte *data, long wcount) override;
40 long write(Exiv2::BasicIo &src) override;
41 int putb(Exiv2::byte data) override;
42 Exiv2::DataBuf read(long rcount) override;
43 long read(Exiv2::byte *buf, long rcount) override;
44#endif
45 int getb() override;
46 void transfer(BasicIo &src) override;
47#if defined(_MSC_VER) || EXIV2_TEST_VERSION(0,28,0)
48 int seek(int64_t offset, Position pos) override;
49#else
50 int seek(long offset, Position pos) override;
51#endif
52
53 Exiv2::byte *mmap(bool isWriteable = false) override;
54#if EXIV2_TEST_VERSION(0,28,0)
55 void populateFakeData() override;
56#endif
57 int munmap() override;
58#if EXIV2_TEST_VERSION(0,28,0)
59 size_t tell() const override;
60#else
61 long tell() const override;
62#endif
63 size_t size() const override;
64 bool isopen() const override;
65 int error() const override;
66 bool eof() const override;
67#if EXIV2_TEST_VERSION(0,28,0)
68 const std::string& path() const noexcept override;
69#else
70 std::string path() const override;
71#endif
72
73private:
74 bool open(QFile::OpenMode mode);
75 bool renameToCurrent(const QString srcPath);
76 QString filePathQString() const;
77
78 mutable QFile m_file;
79
80 Exiv2::byte *m_mappedArea;
81};
82
83#endif // __KISEXIV2IODEVICE_H_
Exiv2::byte * m_mappedArea
Exiv2::BasicIo::AutoPtr ptr_type