Skip to content

Commit

Permalink
Data consistency checks in vmsrawdump
Browse files Browse the repository at this point in the history
  • Loading branch information
pkubanek committed Jun 11, 2024
1 parent b1f4386 commit d7f7dd7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions utils/vmsrawdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,17 @@ void dump_file(const char *filename) {
std::cout << std::endl;

auto micros_d = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count();
long int old_micros = 0;

while (!file.eof()) {
file.read(reinterpret_cast<char *>(&micros_d), sizeof(micros_d));

if (old_micros >= micros_d) {
std::cerr << "Recorded timestamps in file " << filename << " aren't increasing ("
<< old_micros << " >= " << micros_d << "), skipping rest of the file!" << std::endl;
return;
}

microseconds micros(micros_d);
seconds sec = duration_cast<seconds>(micros);
micros -= sec;
Expand All @@ -159,6 +167,8 @@ void dump_file(const char *filename) {
}

std::cout << std::endl;

old_micros = micros_d;
}
} catch (const std::ios_base::failure &e) {
if (file.eof()) {
Expand Down

0 comments on commit d7f7dd7

Please sign in to comment.