From eb82dbc7656075c466ce02ee8ffb7a8929173c09 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 5 May 2023 10:47:14 +0200 Subject: [PATCH] putil: Accept bytes in DatagramOutputFile::write_header() --- panda/src/putil/datagramOutputFile.cxx | 16 ++++++++++++++++ panda/src/putil/datagramOutputFile.h | 1 + 2 files changed, 17 insertions(+) diff --git a/panda/src/putil/datagramOutputFile.cxx b/panda/src/putil/datagramOutputFile.cxx index 407e1adfec..6d285a7f3e 100644 --- a/panda/src/putil/datagramOutputFile.cxx +++ b/panda/src/putil/datagramOutputFile.cxx @@ -86,6 +86,22 @@ close() { _error = false; } +/** + * Writes a sequence of bytes to the beginning of the datagram file. This may + * be called any number of times after the file has been opened and before the + * first datagram is written. It may not be called once the first datagram is + * written. + */ +bool DatagramOutputFile:: +write_header(const vector_uchar &header) { + nassertr(_out != nullptr, false); + nassertr(!_wrote_first_datagram, false); + + _out->write((const char *)&header[0], header.size()); + thread_consider_yield(); + return !_out->fail(); +} + /** * Writes a sequence of bytes to the beginning of the datagram file. This may * be called any number of times after the file has been opened and before the diff --git a/panda/src/putil/datagramOutputFile.h b/panda/src/putil/datagramOutputFile.h index 17402850b0..fbc88e0bcd 100644 --- a/panda/src/putil/datagramOutputFile.h +++ b/panda/src/putil/datagramOutputFile.h @@ -38,6 +38,7 @@ PUBLISHED: void close(); + bool write_header(const vector_uchar &header); bool write_header(const std::string &header); virtual bool put_datagram(const Datagram &data); virtual bool copy_datagram(SubfileInfo &result, const Filename &filename);