X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Frawdata.cpp;h=de4d7c22bb6e9d1a195174451a08e4817f1b2c75;hp=b912a56d9b752a29439b00901d195f7b1ef04665;hb=83971ed7f55794a61e1d249c59867184a6eb97ba;hpb=52fb63aded47733fa67e871ce0bd360b9eea7468 diff --git a/source/rawdata.cpp b/source/rawdata.cpp index b912a56..de4d7c2 100644 --- a/source/rawdata.cpp +++ b/source/rawdata.cpp @@ -96,5 +96,30 @@ void RawData::load_into(void *buffer) in = nullptr; } +void RawData::write_io(IO::Base &io, bool compress) +{ + if(!data) + throw logic_error("no data"); + + io.write(signature, sizeof(signature)); + + for(unsigned i=56; i<64; i-=8) + io.put((size>>i)&0xFF); + + uint16_t flags = 0; + if(compress) + flags |= COMPRESSED; + io.put((flags>>8)&0xFF); + io.put(flags&0xFF); + + if(compress) + { + IO::ZlibCompressed z(io, IO::M_WRITE); + z.write(data, size); + } + else + io.write(data, size); +} + } // namespace DataFile } // namespace Msp