X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/c819c7a5996c18a6b1c5501c1984245840ddc8ca..refs/heads/master:/datread.cpp?ds=inline diff --git a/datread.cpp b/datread.cpp index 4a0e31d..f4bf393 100644 --- a/datread.cpp +++ b/datread.cpp @@ -16,17 +16,20 @@ int datread::openFile (const string& filename) if ( ! infile.is_open() ) return -1; if( filename.substr(filename.size()-4) == ".dat" ) { - format = Format::DAT; + format = DAT; } else if( filename.substr(filename.size()-4) == "edat" ) { - format = Format::EDAT; + format = EDAT; } else if( filename.substr(filename.size()-4) == "sdat" ) { - format = Format::SDAT; + format = SDAT; getline(infile, parastring); } - inbuffer = unique_ptr(new boost::iostreams::filtering_istreambuf); + if ( inbuffer != NULL ) + delete inbuffer; + + inbuffer = new boost::iostreams::filtering_istreambuf; inbuffer->push( boost::iostreams::bzip2_decompressor() ); inbuffer->push(infile); @@ -121,7 +124,7 @@ int datread::readFullBlock (char *tmpData) return -4; /* try to read header */ - if ( format == Format::EDAT || format == Format::SDAT ) + if ( format == EDAT || format == SDAT ) if ( ! readAllHeaders() ) { infile.close(); return -1; @@ -173,3 +176,9 @@ void datread::closeFile () if ( infile.is_open() ) infile.close(); } + +datread::~datread () +{ + if ( inbuffer != NULL ) + delete inbuffer; +}