summaryrefslogtreecommitdiff
path: root/src/ByteArrayDiskWriter.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-11 16:58:24 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-11 16:58:24 +0000
commit048a2cf59737f761876e81a77e8d064c45c752d7 (patch)
tree65c9d5498aafe6a8c8e640ddfcc43c7013504d0d /src/ByteArrayDiskWriter.cc
parente26bbbb9eee140ba24402fe872a752b42f0077de (diff)
2007-10-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented BitTorrent/http/ftp integrated download. I've rewritten lots of files and now some headers have forward class declarations to reduce compile time. The implementation is extremely alpha stage, I recommend to use this for testing purpose only.
Diffstat (limited to 'src/ByteArrayDiskWriter.cc')
-rw-r--r--src/ByteArrayDiskWriter.cc32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/ByteArrayDiskWriter.cc b/src/ByteArrayDiskWriter.cc
index 0e8c2151..864d167c 100644
--- a/src/ByteArrayDiskWriter.cc
+++ b/src/ByteArrayDiskWriter.cc
@@ -38,34 +38,35 @@
ByteArrayDiskWriter::ByteArrayDiskWriter() {
}
-ByteArrayDiskWriter::~ByteArrayDiskWriter() {
- closeFile();
-}
+ByteArrayDiskWriter::~ByteArrayDiskWriter() {}
-void ByteArrayDiskWriter::clear() {
+void ByteArrayDiskWriter::clear()
+{
buf.str("");
}
void ByteArrayDiskWriter::initAndOpenFile(const string& filename,
- int64_t totalLength) {
+ int64_t totalLength)
+{
clear();
}
void ByteArrayDiskWriter::openFile(const string& filename,
- int64_t totalLength) {
- initAndOpenFile(filename);
+ int64_t totalLength)
+{
}
-void ByteArrayDiskWriter::closeFile() {
- clear();
-}
+void ByteArrayDiskWriter::closeFile()
+{}
void ByteArrayDiskWriter::openExistingFile(const string& filename,
- int64_t totalLength) {
+ int64_t totalLength)
+{
openFile(filename);
}
-void ByteArrayDiskWriter::writeData(const char* data, int32_t dataLength, int64_t position) {
+void ByteArrayDiskWriter::writeData(const unsigned char* data, int32_t dataLength, int64_t position)
+{
if(size() < position) {
buf.seekg(0, ios::end);
for(int32_t i = size(); i < position; ++i) {
@@ -74,12 +75,13 @@ void ByteArrayDiskWriter::writeData(const char* data, int32_t dataLength, int64_
} else {
buf.seekg(position, ios::beg);
}
- buf.write(data, dataLength);
+ buf.write(reinterpret_cast<const char*>(data), dataLength);
}
-int32_t ByteArrayDiskWriter::readData(char* data, int32_t len, int64_t position) {
+int32_t ByteArrayDiskWriter::readData(unsigned char* data, int32_t len, int64_t position)
+{
buf.seekg(position, ios::beg);
- buf.read(data, len);
+ buf.read(reinterpret_cast<char*>(data), len);
// TODO we have to call buf.clear() here? YES
buf.clear();
return buf.gcount();