off_t _vfzSeek(struct VFile* vf, off_t offset, int whence) { struct VFileZip* vfz = (struct VFileZip*) vf; int64_t currentPos = unztell64(vfz->z); int64_t pos; switch (whence) { case SEEK_SET: pos = 0; break; case SEEK_CUR: pos = unztell64(vfz->z); break; case SEEK_END: pos = vfz->fileSize; break; default: return -1; } if (pos < 0 || pos + offset < 0) { return -1; } pos += offset; if (currentPos > pos) { unzCloseCurrentFile(vfz->z); unzOpenCurrentFile(vfz->z); currentPos = 0; } while (currentPos < pos) { char tempBuf[1024]; ssize_t toRead = sizeof(tempBuf); if (toRead > pos - currentPos) { toRead = pos - currentPos; } ssize_t read = vf->read(vf, tempBuf, toRead); if (read < toRead) { return -1; } currentPos += read; } return unztell64(vfz->z); }
Position GetPos(void) const { return unztell64(handle); }
qint64 UnzipFile::pos() const { return unztell64(d->archive->d->unzip); }