zstr icon indicating copy to clipboard operation
zstr copied to clipboard

gcount, tellg, seekg functions

Open ferdymercury opened this issue 3 years ago • 3 comments

tellg(), gcount() and seekg() functions might be helpful for estimating file size.

See https://stackoverflow.com/questions/2409504/using-c-filestreams-fstream-how-can-you-determine-the-size-of-a-file

ferdymercury avatar Aug 12 '20 16:08 ferdymercury

tellg

ferdymercury avatar Sep 23 '20 16:09 ferdymercury

I think tellg works in general now, I needed it for debugging some file format issues so I tried to fix it:

https://github.com/mateidavid/zstr/commit/81db81588d44549f3845ff6099a6fe28464eb285#diff-f957a3c12ea388ffadfa08b526d7ae5c52ce99fa70fce25fe583fbbadb27a624 (which is ironically the one that broke the test).

sandsmark avatar Nov 06 '20 17:11 sandsmark

instead of seekg to ios::end (or ios::ate) and tellg, an alternative way of getting the filesize would be: https://en.cppreference.com/w/cpp/filesystem/file_size

For the 'uncompressed' file size, it could be: std::distance(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());

ferdymercury avatar Jul 28 '21 20:07 ferdymercury