20 #if (QT_VERSION >= 0x050100)
21 #define QUAZIP_QSAVEFILE_BUG_WORKAROUND
23 #ifdef QUAZIP_QSAVEFILE_BUG_WORKAROUND
61 uLong offsetTruncated = (uLong)
offset;
62 if (offsetTruncated !=
offset)
66 filestream, offsetTruncated,
79 if ((tell_uLong) == ((uLong)-1))
87 struct QIODevice_descriptor {
90 inline QIODevice_descriptor() : pos(0) {}
97 QIODevice_descriptor *d =
reinterpret_cast<QIODevice_descriptor *
>(opaque);
98 QIODevice *iodevice =
reinterpret_cast<QIODevice *
>(file);
99 QIODevice::OpenMode desiredMode;
101 desiredMode = QIODevice::ReadOnly;
103 desiredMode = QIODevice::ReadWrite;
105 desiredMode = QIODevice::WriteOnly;
106 if (iodevice->isOpen()) {
107 if ((iodevice->openMode() & desiredMode) == desiredMode) {
108 if (desiredMode != QIODevice::WriteOnly &&
109 iodevice->isSequential()) {
114 if ((desiredMode & QIODevice::WriteOnly) != 0) {
116 if (!iodevice->isSequential()) {
119 d->pos = iodevice->pos();
129 iodevice->open(desiredMode);
130 if (iodevice->isOpen()) {
131 if (desiredMode != QIODevice::WriteOnly && iodevice->isSequential()) {
149 QIODevice_descriptor *d =
reinterpret_cast<QIODevice_descriptor *
>(opaque);
150 QIODevice *iodevice =
reinterpret_cast<QIODevice *
>(stream);
151 qint64 ret64 = iodevice->read((
char *)buf,
size);
164 QIODevice_descriptor *d =
reinterpret_cast<QIODevice_descriptor *
>(opaque);
165 QIODevice *iodevice =
reinterpret_cast<QIODevice *
>(stream);
167 qint64 ret64 = iodevice->write((
char *)buf,
size);
176 QIODevice_descriptor *d =
reinterpret_cast<QIODevice_descriptor *
>(opaque);
177 QIODevice *iodevice =
reinterpret_cast<QIODevice *
>(stream);
180 if (iodevice->isSequential()) {
183 ret64 = iodevice->pos();
185 ret =
static_cast<uLong
>(ret64);
190 QIODevice_descriptor *d =
reinterpret_cast<QIODevice_descriptor *
>(opaque);
191 QIODevice *iodevice =
reinterpret_cast<QIODevice *
>(stream);
193 if (iodevice->isSequential()) {
196 ret = iodevice->pos();
205 QIODevice *iodevice =
reinterpret_cast<QIODevice *
>(stream);
206 if (iodevice->isSequential()) {
211 qWarning(
"qiodevice_seek_file_func() called for sequential device");
215 uLong qiodevice_seek_result = 0;
219 qiodevice_seek_result = ((QIODevice *)stream)->pos() +
offset;
222 qiodevice_seek_result = ((QIODevice *)stream)->size() -
offset;
225 qiodevice_seek_result =
offset;
230 ret = !iodevice->seek(qiodevice_seek_result);
238 QIODevice *iodevice =
reinterpret_cast<QIODevice *
>(stream);
239 if (iodevice->isSequential()) {
244 qWarning(
"qiodevice_seek_file_func() called for sequential device");
248 qint64 qiodevice_seek_result = 0;
252 qiodevice_seek_result = ((QIODevice *)stream)->pos() +
offset;
255 qiodevice_seek_result = ((QIODevice *)stream)->size() -
offset;
258 qiodevice_seek_result =
offset;
263 ret = !iodevice->seek(qiodevice_seek_result);
268 QIODevice_descriptor *d =
reinterpret_cast<QIODevice_descriptor *
>(opaque);
270 QIODevice *device =
reinterpret_cast<QIODevice *
>(stream);
271 #ifdef QUAZIP_QSAVEFILE_BUG_WORKAROUND
274 QSaveFile *file = qobject_cast<QSaveFile *>(device);
277 return file->commit() ? 0 : -1;
285 QIODevice_descriptor *d =
reinterpret_cast<QIODevice_descriptor *
>(opaque);
304 pzlib_filefunc_def->
opaque =
new QIODevice_descriptor;
316 pzlib_filefunc_def->
opaque =
new QIODevice_descriptor;
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER
#define ZLIB_FILEFUNC_MODE_EXISTING
#define ZLIB_FILEFUNC_SEEK_CUR
#define ZLIB_FILEFUNC_SEEK_SET
#define ZLIB_FILEFUNC_MODE_CREATE
#define ZLIB_FILEFUNC_SEEK_END
#define ZLIB_FILEFUNC_MODE_READ
unsigned long long int ZPOS64_T
int qiodevice_seek_file_func(voidpf, voidpf stream, uLong offset, int origin)
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
voidpf call_zopen64(const zlib_filefunc64_32_def *pfilefunc, voidpf file, int mode)
voidpf qiodevice_open_file_func(voidpf opaque, voidpf file, int mode)
int qiodevice_close_file_func(voidpf opaque, voidpf stream)
void fill_qiodevice64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
uLong qiodevice_tell_file_func(voidpf opaque, voidpf stream)
int qiodevice_error_file_func(voidpf, voidpf)
uLong qiodevice_write_file_func(voidpf opaque, voidpf stream, const void *buf, uLong size)
ZPOS64_T qiodevice64_tell_file_func(voidpf opaque, voidpf stream)
int qiodevice64_seek_file_func(voidpf, voidpf stream, ZPOS64_T offset, int origin)
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream)
void fill_qiodevice_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
int call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, ZPOS64_T offset, int origin)
uLong qiodevice_read_file_func(voidpf opaque, voidpf stream, void *buf, uLong size)
int qiodevice_fakeclose_file_func(voidpf opaque, voidpf)
seek_file_func zseek32_file
zlib_filefunc64_def zfile_func64
open_file_func zopen32_file
tell_file_func ztell32_file
write_file_func zwrite_file
open64_file_func zopen64_file
close_file_func zfakeclose_file
read_file_func zread_file
tell64_file_func ztell64_file
close_file_func zclose_file
seek64_file_func zseek64_file
testerror_file_func zerror_file
seek_file_func zseek_file
open_file_func zopen_file
testerror_file_func zerror_file
write_file_func zwrite_file
read_file_func zread_file
close_file_func zclose_file
tell_file_func ztell_file