#include <KisExiv2IODevice.h>
|
| using | ptr_type = Exiv2::BasicIo::AutoPtr |
| |
|
| int | close () override |
| |
| bool | eof () const override |
| |
| int | error () const override |
| |
| int | getb () override |
| |
| bool | isopen () const override |
| |
| | KisExiv2IODevice (QString path) |
| |
| Exiv2::byte * | mmap (bool isWriteable=false) override |
| |
| int | munmap () override |
| |
| int | open () override |
| |
| std::string | path () const override |
| |
| int | putb (Exiv2::byte data) override |
| |
| long | read (Exiv2::byte *buf, long rcount) override |
| |
| Exiv2::DataBuf | read (long rcount) override |
| |
| int | seek (long offset, Position pos) override |
| |
| size_t | size () const override |
| |
| long | tell () const override |
| |
| void | transfer (BasicIo &src) override |
| |
| long | write (const Exiv2::byte *data, long wcount) override |
| |
| long | write (Exiv2::BasicIo &src) override |
| |
| | ~KisExiv2IODevice () override |
| |
Definition at line 18 of file KisExiv2IODevice.h.
◆ ptr_type
◆ KisExiv2IODevice()
| KisExiv2IODevice::KisExiv2IODevice |
( |
QString | path | ) |
|
◆ ~KisExiv2IODevice()
| KisExiv2IODevice::~KisExiv2IODevice |
( |
| ) |
|
|
override |
◆ close()
| int KisExiv2IODevice::close |
( |
| ) |
|
|
override |
◆ eof()
| bool KisExiv2IODevice::eof |
( |
| ) |
const |
|
override |
◆ error()
| int KisExiv2IODevice::error |
( |
| ) |
const |
|
override |
◆ filePathQString()
| QString KisExiv2IODevice::filePathQString |
( |
| ) |
const |
|
private |
◆ getb()
| int KisExiv2IODevice::getb |
( |
| ) |
|
|
override |
◆ isopen()
| bool KisExiv2IODevice::isopen |
( |
| ) |
const |
|
override |
◆ mmap()
| Exiv2::byte * KisExiv2IODevice::mmap |
( |
bool | isWriteable = false | ) |
|
|
override |
Definition at line 199 of file KisExiv2IODevice.cpp.
200{
201 Q_UNUSED(isWriteable);
202
204 qWarning() << "KisExiv2IODevice::mmap: Couldn't unmap the mapped file";
205 return nullptr;
206 }
207
210
211 qWarning() <<
"KisExiv2IODevice::mmap: Couldn't map the file" <<
m_file.fileName();
212 }
214}
size_t size() const override
References m_file, m_mappedArea, munmap(), and size().
◆ munmap()
| int KisExiv2IODevice::munmap |
( |
| ) |
|
|
override |
◆ open() [1/2]
| int KisExiv2IODevice::open |
( |
| ) |
|
|
override |
◆ open() [2/2]
| bool KisExiv2IODevice::open |
( |
QFile::OpenMode | mode | ) |
|
|
private |
◆ path()
| std::string KisExiv2IODevice::path |
( |
| ) |
const |
|
override |
◆ putb()
| int KisExiv2IODevice::putb |
( |
Exiv2::byte | data | ) |
|
|
override |
Definition at line 86 of file KisExiv2IODevice.cpp.
87{
88 if (!
m_file.isWritable()) {
89 qWarning() << "KisExiv2IODevice: File not open for writing.";
90 return 0;
91 }
92 if (
m_file.putChar(data)) {
93 return data;
94 } else {
95 return EOF;
96 }
97}
References m_file.
◆ read() [1/2]
| long KisExiv2IODevice::read |
( |
Exiv2::byte * | buf, |
|
|
long | rcount ) |
|
override |
Definition at line 119 of file KisExiv2IODevice.cpp.
121{
122 const qint64 bytesRead =
m_file.read(
reinterpret_cast<char *
>(buf), rcount);
123 if (bytesRead > 0) {
124 return bytesRead;
125 } else {
126 qWarning() <<
"KisExiv2IODevice: Couldn't read file:" <<
m_file.errorString();
127
128 return 0;
129 }
130}
◆ read() [2/2]
| Exiv2::DataBuf KisExiv2IODevice::read |
( |
long | rcount | ) |
|
|
override |
Definition at line 102 of file KisExiv2IODevice.cpp.
104{
105 Exiv2::DataBuf buf(rcount);
106#if EXIV2_TEST_VERSION(0,28,0)
107 const size_t readCount =
read(buf.data(), buf.size());
108 buf.resize(readCount);
109#else
110 const long readCount =
read(buf.pData_, buf.size_);
111 buf.size_ = readCount;
112#endif
113 return buf;
114}
Exiv2::DataBuf read(long rcount) override
◆ renameToCurrent()
| bool KisExiv2IODevice::renameToCurrent |
( |
const QString | srcPath | ) |
|
|
private |
◆ seek()
| int KisExiv2IODevice::seek |
( |
long | offset, |
|
|
Position | pos ) |
|
override |
Definition at line 181 of file KisExiv2IODevice.cpp.
183{
184 qint64 pos = 0;
185 switch (position) {
186 case Exiv2::BasicIo::beg:
187 pos = offset;
188 break;
189 case Exiv2::BasicIo::cur:
190 pos =
tell() + offset;
191 break;
192 case Exiv2::BasicIo::end:
193 pos =
size() + offset;
194 break;
195 }
197}
long tell() const override
◆ size()
| size_t KisExiv2IODevice::size |
( |
| ) |
const |
|
override |
◆ tell()
| long KisExiv2IODevice::tell |
( |
| ) |
const |
|
override |
◆ transfer()
| void KisExiv2IODevice::transfer |
( |
BasicIo & | src | ) |
|
|
override |
Definition at line 142 of file KisExiv2IODevice.cpp.
143{
144 bool isFileBased = (
dynamic_cast<Exiv2::FileIo *
>(&
src) ||
dynamic_cast<KisExiv2IODevice *
>(&src));
145 bool useFallback = false;
146
147 if (isFileBased) {
148 const QString srcPath = QString::fromStdString(
src.path());
149
151 }
152
153 if (!isFileBased || useFallback) {
154 const bool wasOpen =
isopen();
155 const QIODevice::OpenMode oldMode =
m_file.openMode();
156
157
158 if (
src.open() != 0) {
159 qWarning() <<
"KisExiv2IODevice::transfer: Couldn't open src file" << QString::fromStdString(
src.path());
160 return;
161 }
162
163 if (!
open(QIODevice::ReadWrite | QIODevice::Truncate)) {
164 qWarning() <<
"KisExiv2IODevice::transfer: Couldn't open dest file" <<
filePathQString();
165 return;
166 }
169
170 if (wasOpen) {
172 } else {
174 }
175 }
176}
long write(const Exiv2::byte *data, long wcount) override
bool isopen() const override
bool renameToCurrent(const QString srcPath)
References close(), filePathQString(), isopen(), m_file, open(), renameToCurrent(), and write().
◆ write() [1/2]
| long KisExiv2IODevice::write |
( |
const Exiv2::byte * | data, |
|
|
long | wcount ) |
|
override |
Definition at line 45 of file KisExiv2IODevice.cpp.
47{
48 if (!
m_file.isWritable()) {
49 qWarning() << "KisExiv2IODevice: File not open for writing.";
50 return 0;
51 }
52 const qint64 writeCount =
m_file.write(
reinterpret_cast<const char *
>(data), wcount);
53 if (writeCount > 0) {
54 return writeCount;
55 }
56
57 return 0;
58}
◆ write() [2/2]
| long KisExiv2IODevice::write |
( |
Exiv2::BasicIo & | src | ) |
|
|
override |
Definition at line 63 of file KisExiv2IODevice.cpp.
65{
66 if (static_cast<BasicIo *>(this) == &src) {
67 return 0;
68 }
70 return 0;
71 }
72 if (!
m_file.isWritable()) {
73 qWarning() << "KisExiv2IODevice: File not open for writing.";
74 return 0;
75 }
76 Exiv2::byte buffer[4096];
77 long readCount = 0;
78 long totalWriteCount = 0;
79 while ((readCount =
src.read(buffer,
sizeof(buffer))) != 0) {
80 totalWriteCount +=
write(buffer, readCount);
81 }
82
83 return totalWriteCount;
84}
◆ m_file
| QFile KisExiv2IODevice::m_file |
|
mutableprivate |
◆ m_mappedArea
| Exiv2::byte* KisExiv2IODevice::m_mappedArea |
|
private |
The documentation for this class was generated from the following files: