diff options
author | José Fonseca <jose.r.fonseca@gmail.com> | 2011-10-08 11:48:47 +0100 |
---|---|---|
committer | José Fonseca <jose.r.fonseca@gmail.com> | 2011-10-08 17:13:26 +0100 |
commit | f6548d1c7accc959ef53f8c08c1d7a71f94c7f53 (patch) | |
tree | 0bfe6bb7d0801a18e210f2aba8cf3ed00b8b254b /common/trace_file.cpp | |
parent | 834d14c3574c47225ddc31484ea144b9d1a1dffa (diff) |
Upgrade bundled zlib to 1.2.5 again.
Diffstat (limited to 'common/trace_file.cpp')
-rw-r--r-- | common/trace_file.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/common/trace_file.cpp b/common/trace_file.cpp index f48c1aa9..8eb3bd46 100644 --- a/common/trace_file.cpp +++ b/common/trace_file.cpp @@ -32,6 +32,7 @@ #include <string.h> #include <zlib.h> +#include <gzguts.h> #include "os.hpp" @@ -92,13 +93,6 @@ bool File::isSnappyCompressed(const std::string &filename) return (byte1 == SNAPPY_BYTE1 && byte2 == SNAPPY_BYTE2); } -typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ -} gz_dummy_stream; - ZLibFile::ZLibFile(const std::string &filename, File::Mode mode) : File(filename, mode), @@ -120,11 +114,10 @@ bool ZLibFile::rawOpen(const std::string &filename, File::Mode mode) // SEEK_END or we could've done: //m_endOffset = gzseek(m_gzFile, 0, SEEK_END); //gzrewind(m_gzFile); - gz_dummy_stream *stream = (gz_dummy_stream *)m_gzFile; - long loc = ftell(stream->file); - fseek(stream->file,0,SEEK_END); - m_endOffset = ftell(stream->file); - fseek(stream->file, loc, SEEK_SET); + gz_state *state = (gz_state *)m_gzFile; + off_t loc = lseek(state->fd, 0, SEEK_CUR); + m_endOffset = lseek(state->fd, 0, SEEK_END); + lseek(state->fd, loc, SEEK_SET); } return m_gzFile != NULL; @@ -175,6 +168,6 @@ bool ZLibFile::rawSkip(size_t) int ZLibFile::rawPercentRead() { - gz_dummy_stream *stream = (gz_dummy_stream *)m_gzFile; - return 100 * (ftell(stream->file) / m_endOffset); + gz_state *state = (gz_state *)m_gzFile; + return 100 * (lseek(state->fd, 0, SEEK_CUR) / m_endOffset); } |