Am 07.11.2011 16:59, schrieb Carson Dunbar:
If I do have a bundle, let's say the received.bundle from local, is there a way to split up its payload into smaller payloads and make each new payload its own bundle? My objective is to send in a file and then break it up into smaller payloads then choose among them to send to other nodes.
If the received.bundle variable is a object of type dtn::data::Bundle (if not you have to load the bundle from the database first) you can access the payload like this:
dtn::data::PayloadBlock &payload = bundle.getBlockdtn::data::PayloadBlock();
To get the data itself you need to allocate and lock the stream associated with it...
// get BLOB reference ibrcommon::BLOB::Reference ref = b.getData();
// lock the stream - while we are between the curlies, the stream is locked. { ibrcommon::BLOB::iostream stream = ref.iostream(); [ ... read from / write to the stream .... ] }
Once you got the stream you can do standard C++ streaming operations on it. In your case I would read the from the stream continuously and generate a bundle for each chunk while reading the stream.
Kind regards, Johannes