Skip to content

Commit

Permalink
Use readStruct more consistenly in nev event provider
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianFranzen committed Dec 13, 2015
1 parent a8bc924 commit db6ae46
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/neveventsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ int NEVEventsProvider::loadData(){
}

// Read basic header
qint64 bytesToRead = sizeof(NEVBasicHeader);
qint64 bytesRead = eventFile.read(reinterpret_cast<char*>(&(mBasicHeader)), bytesToRead);

if(bytesToRead != bytesRead) {
if(!readStruct<NEVBasicHeader>(eventFile, mBasicHeader)) {
eventFile.close();
return INCORRECT_CONTENT;
}

this->currentSamplingRate = mBasicHeader.global_time_resolution / 1000.0;
this->nbEvents = (eventFile.size() - mBasicHeader.header_size) / mBasicHeader.data_package_size;

Expand All @@ -53,11 +51,13 @@ int NEVEventsProvider::loadData(){
delete[] mExtensionHeaders;
mExtensionHeaders = new NEVExtensionHeader[mBasicHeader.extension_count];

bytesToRead = sizeof(NEVExtensionHeader);
for(int extension = 0; extension < mBasicHeader.extension_count; extension++) {
bytesRead = eventFile.read(reinterpret_cast<char*>(mExtensionHeaders + extension), bytesToRead);

if(bytesToRead != bytesRead) goto fail;
if(!readStruct<NEVExtensionHeader>(eventFile, mExtensionHeaders[extension])) {
eventFile.close();
delete[] mExtensionHeaders;
mExtensionHeaders = NULL;
return INCORRECT_CONTENT;
}
}

// Extension header information should be extracted here. Right now we do not use the information.
Expand Down

0 comments on commit db6ae46

Please sign in to comment.