26 #include <boost/scoped_array.hpp>
27 #include <boost/scoped_ptr.hpp>
34 #include "vfs/raw/rawdata.h"
36 #include "util/base/exception.h"
38 #include "rawdatadat2.h"
45 boost::scoped_ptr<RawData> input (vfs->
open(datfile));
46 input->setIndex(info.offset);
49 boost::scoped_array<uint8_t> compressed(
new uint8_t[info.packedLength]);
50 input->readInto(compressed.get(), info.packedLength);
52 uLongf dstlen = info.unpackedLength;
53 if (uncompress(
getRawData(), &dstlen, compressed.get(), info.packedLength) != Z_OK || dstlen != info.unpackedLength) {
54 throw InvalidFormat(
"failed to decompress " + info.name +
" (inside: " + datfile +
")");
57 input->readInto(
getRawData(), info.unpackedLength);