Clear EOF bits before seeking otherwise we get garbage data

This commit is contained in:
Guilhem Lavaux 2016-01-29 14:55:34 +01:00
parent 450a9a4185
commit ed602dad09
3 changed files with 5 additions and 2 deletions

View file

@ -78,6 +78,7 @@ int64_t UnformattedRead::position() const
void UnformattedRead::seek(int64_t pos)
{
f->clear();
f->seekg(pos, istream::beg);
checkPointRef = checkPointAccum = 0;
}

View file

@ -51,8 +51,9 @@ using namespace std;
void loadGadgetHeader(UnformattedRead *f, GadgetHeader& h, SimuData *data, int id)
{
f->beginCheckpoint();
for (int i = 0; i < 6; i++)
for (int i = 0; i < 6; i++) {
h.npart[i] = f->readInt32();
}
for (int i = 0; i < 6; i++)
h.mass[i] = f->readReal64();
data->time = h.time = f->readReal64();
@ -146,6 +147,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
f->endCheckpoint();
blockTable[block] = f->position();
f->skip(blocksize);
cout << "Got block '" << block << "', position = " << blockTable[block] << endl;
}
} catch (EndOfFileException&) {}