bool ZipFile::seek(int64_t offset, int whence /* = SEEK_SET */) { assert(m_gzFile); if (whence == SEEK_CUR) { off_t result = gzseek(m_gzFile, 0, SEEK_CUR); if (result != (off_t)-1) { offset += result - (bufferedLen() + getPosition()); } if (offset > 0 && offset < bufferedLen()) { setReadPosition(getReadPosition() + offset); setPosition(getPosition() + offset); return true; } offset += getPosition(); whence = SEEK_SET; } // invalidate the current buffer setWritePosition(0); setReadPosition(0); setEof(false); gzclearerr(m_gzFile); flush(); off_t result = gzseek(m_gzFile, offset, whence); setPosition(result); return result != (off_t)-1; }
void IFile::reset(bool reset){ eof = reset; err = reset; if(!reset && fp) clearerr(fp); #ifdef __PLUMED_HAS_ZLIB if(!reset && gzfp) gzclearerr(gzFile(gzfp)); #endif return; }