Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcount, tellg, seekg functions #21

Open
ferdymercury opened this issue Aug 12, 2020 · 3 comments
Open

gcount, tellg, seekg functions #21

ferdymercury opened this issue Aug 12, 2020 · 3 comments

Comments

@ferdymercury
Copy link
Collaborator

ferdymercury commented Aug 12, 2020

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

This comment has been minimized.

@sandsmark
Copy link
Contributor

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

81db815#diff-f957a3c12ea388ffadfa08b526d7ae5c52ce99fa70fce25fe583fbbadb27a624 (which is ironically the one that broke the test).

@ferdymercury ferdymercury changed the title close and gcount functions gcount, tellg, seekg functions Jun 21, 2021
@ferdymercury
Copy link
Collaborator Author

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>());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants