boostorg / boostorg/iostreams

Forward seekable compressed streams

Open
#126 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
48
Forks
124
PR merge metrics
No merged PRs in 30d

Description

Using `boost::iostreams::filtering_istream` together with one of the decompression filters, e.g. `boost::iostreams::gzip_decompressor` results in `tellg` returning -1 and setting the bad bid and `seekg` not working.

However, at least forward seeking and telling the number read bytes would be possible and would make working with these streams much easier for certain use cases (e.g. reading custom binary files compressed with these methods).

i.e. this:

```

#include
#include
#include

namespace io = boost::iostreams;
int main() {
io::filtering_istream stream;
stream.push(io::gzip_decompressor());
stream.push(io::file_source("test.gzip"));

std::cout << stream.tellg() << std::endl; // should print 0, prints -1
stream.seekg(1000); // skip 1000 bytes
std::cout << stream.tellg() << std::endl; // should print 1000, prints -1

return 0;
}
```
See for example `gzseek`: https://refspecs.linuxbase.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/zlib-gzseek-1.html

and `gztell`: https://refspecs.linuxbase.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/zlib-gztell-1.html

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing filtering_istream with gzip_decompressor and file_source, focusing on how tellg and seekg are handled for decompressed streams. Compare the requested forward-seeking behavior with the linked gzseek and gztell references; done means the example reports positions and skips forward as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.