summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer/FileReadBytestream.cpp')
-rw-r--r--Swiften/FileTransfer/FileReadBytestream.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/Swiften/FileTransfer/FileReadBytestream.cpp b/Swiften/FileTransfer/FileReadBytestream.cpp
index c08747b..a8946a0 100644
--- a/Swiften/FileTransfer/FileReadBytestream.cpp
+++ b/Swiften/FileTransfer/FileReadBytestream.cpp
@@ -6,8 +6,10 @@
#include <boost/filesystem/fstream.hpp>
#include <cassert>
+#include <boost/smart_ptr/make_shared.hpp>
-#include "Swiften/FileTransfer/FileReadBytestream.h"
+#include <Swiften/FileTransfer/FileReadBytestream.h>
+#include <Swiften/Base/ByteArray.h>
namespace Swift {
@@ -21,15 +23,16 @@ FileReadBytestream::~FileReadBytestream() {
}
}
-ByteArray FileReadBytestream::read(size_t size) {
+boost::shared_ptr<ByteArray> FileReadBytestream::read(size_t size) {
if (!stream) {
stream = new boost::filesystem::ifstream(file, std::ios_base::in|std::ios_base::binary);
}
- ByteArray result;
- result.resize(size);
+ boost::shared_ptr<ByteArray> result = boost::make_shared<ByteArray>();
+ result->resize(size);
assert(stream->good());
- stream->read(reinterpret_cast<char*>(result.getData()), size);
- result.resize(stream->gcount());
+ stream->read(reinterpret_cast<char*>(vecptr(*result)), size);
+ result->resize(stream->gcount());
+ onRead(*result);
return result;
}