diff --git a/log2wav b/log2wav index 306bdaeb081e7de54002e9853746a7ec90fad9f5..5f5b42937e968ae3cb904a40677f2f07f389694b 100755 Binary files a/log2wav and b/log2wav differ diff --git a/log2wav.c b/log2wav.c index 725984ee780e5c4f4afb6b194edc45aa27e49c94..b1a9d7788e97450b863cdd28c28555e48ccad320 100755 --- a/log2wav.c +++ b/log2wav.c @@ -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);