From: barnett Date: Fri, 8 Jan 2010 18:42:30 +0000 (+0000) Subject: Added empty block EOF to BGZF::Close X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b5a48a0f4227c39c4cea4e67a427059a3e952cd6;p=bamtools.git Added empty block EOF to BGZF::Close git-svn-id: svn+ssh://gene.bc.edu/home/subversion/Derek/BamTools/trunk@36 9efb377e-2e27-44b9-b91a-ec4abb80ed8b --- diff --git a/BGZF.cpp b/BGZF.cpp index 651fe81..ea2da8d 100644 --- a/BGZF.cpp +++ b/BGZF.cpp @@ -47,12 +47,17 @@ BgzfData::~BgzfData(void) { // closes BGZF file void BgzfData::Close(void) { + // skip if file not open, otherwise set flag if (!IsOpen) { return; } IsOpen = false; - // flush the BGZF block + // flush the current BGZF block if ( IsWriteOnly ) { FlushBlock(); } + // write an empty block (as EOF marker) + int blockLength = DeflateBlock(); + fwrite(CompressedBlock, 1, blockLength, Stream); + // flush and close fflush(Stream); fclose(Stream); diff --git a/BamAux.h b/BamAux.h index eec5556..68f9e88 100644 Binary files a/BamAux.h and b/BamAux.h differ