Skip to content

Commit 9a60306

Browse files
authored
Update toolbox.cpp
1 parent a6ed95b commit 9a60306

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/rp/toolbox.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,15 @@ std::string verbosity_to_string(const VerbosityLevel lvl) {
3030

3131
// Get the size of an open file without changing its position
3232
std::streampos get_file_size(std::ifstream &file) {
33-
34-
// Save the current file ptr position
3533
std::streampos backup = file.tellg();
3634

37-
// Move the ptr to the end
38-
file.seekg(0, std::ios::end);
39-
40-
// Get the current file ptr position ( start = 0 + EOF )
35+
file.seekg(0, std::ios::beg);
4136
std::streampos fsize = file.tellg();
4237

43-
// Restore the previous ptr position
44-
file.seekg(backup);
38+
file.seekg(0, std::ios::end);
39+
fsize = file.tellg() - fsize;
4540

41+
file.seekg(backup);
4642
return fsize;
4743
}
4844

0 commit comments

Comments
 (0)