X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/da120f552639e7e742161a2a4d6f88ca5277df8e..refs/heads/master:/datread.cpp 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; +}