Skip to content

Commit

Permalink
Merge pull request #31 from sandsmark/master
Browse files Browse the repository at this point in the history
Allow people to get the position in the underlying stream
  • Loading branch information
ferdymercury authored Aug 13, 2021
2 parents 946ab40 + 7abde35 commit 80e311f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ Alternatives to this library include:

- The [[http://www.boost.org/doc/libs/release/libs/iostreams/][Boost IOStreams]] library. The library does not auto-detect input compression (by default, though that can be easily implemented with filters), and more importantly, it is not a header-only Boost library.

- The [[https://github.com/tmaklin/bxzstr][bxzstr]] library.
- The [[https://github.com/tmaklin/bxzstr][bxzstr]] library, if you want support for BZ2 and/or LZMA as well.

For an example usage, see [[examples/ztxtpipe.cpp]] and [[examples/zc.cpp]].

It is compatible with [[https://github.com/richgel999/miniz][miniz]] in case you don't want to get frustrated with zlib e. g. on Windows.

**** Input Auto-detection

For input access, the library seamlessly auto-detects whether the source stream is compressed or not. The following compressed streams are detected:
Expand Down
12 changes: 12 additions & 0 deletions src/zstr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ class ifstream
{
if (rdbuf()) delete rdbuf();
}

/// Return the position within the compressed file (wrapped filestream)
std::streampos compressed_tellg()
{
return _fs.tellg();
}
}; // class ifstream

class ofstream
Expand Down Expand Up @@ -477,6 +483,12 @@ class ofstream
{
if (rdbuf()) delete rdbuf();
}

// Return the position within the compressed file (wrapped filestream)
std::streampos compressed_tellp()
{
return _fs.tellp();
}
}; // class ofstream

} // namespace zstr
Expand Down

0 comments on commit 80e311f

Please sign in to comment.