Skip to content
Snippets Groups Projects
Commit 35fa0110 authored by Paul Best's avatar Paul Best
Browse files

skip empty files

parent 6f776c41
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -144,6 +144,13 @@ int main(int argc, char* argv[]){
printf("Failed to open input file\n");
return 0;
}
fseek(logfile, 0, SEEK_END);
long filesize = ftell(logfile);
if(filesize == 0){
printf("skipped empty file : %s\n", argv[1]);
return 0;
}
fseek(logfile, 0, SEEK_SET);
int verbose = 0;
if(argc==5){
verbose = *argv[4]=='1';
......@@ -152,8 +159,7 @@ int main(int argc, char* argv[]){
parseLogFileHeader(logfile, &hdr, verbose);
int resolutionBytes = hdr.resolutionBits/8;
// get file size then move to start of data
fseek(logfile, 0, SEEK_END);
long filesize = ftell(logfile);
long dataBlockSampleSize = hdr.dmaBlockSize / ( hdr.numberOfChan * resolutionBytes);
if(verbose){
printf("file size (bytes) %ld \n", filesize);
......@@ -203,7 +209,6 @@ int main(int argc, char* argv[]){
int ichan, isample;
long pos = 0;
bool isFirst = true;
fseek(logfile, hdr.headerSize + 4, SEEK_SET); // move past the logfile header
// read each dataBlock
do{
fread(additionnalDataBlock, hdr.sizeOfAdditionnalDataBuffer, 1, logfile);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment