From 048a2cf59737f761876e81a77e8d064c45c752d7 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 11 Oct 2007 16:58:24 +0000 Subject: 2007-10-12 Tatsuhiro Tsujikawa 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. --- src/FileAllocationEntry.cc | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'src/FileAllocationEntry.cc') diff --git a/src/FileAllocationEntry.cc b/src/FileAllocationEntry.cc index 77690475..af9c67c1 100644 --- a/src/FileAllocationEntry.cc +++ b/src/FileAllocationEntry.cc @@ -33,22 +33,35 @@ */ /* copyright --> */ #include "FileAllocationEntry.h" +#include "FileAllocationIterator.h" +#include "DownloadEngine.h" +#include "RequestGroup.h" +#include "PieceStorage.h" +#include "DiskAdaptor.h" -#define BUFSIZE 16*1024 +FileAllocationEntry::FileAllocationEntry(RequestGroup* requestGroup, Command* nextCommand): + RequestGroupEntry(requestGroup, nextCommand), + _fileAllocationIterator(requestGroup->getPieceStorage()->getDiskAdaptor()->fileAllocationIterator()) +{} -void FileAllocationEntry::allocateChunk() +FileAllocationEntry:: ~FileAllocationEntry() {} + +int64_t FileAllocationEntry::getCurrentLength() +{ + return _fileAllocationIterator->getCurrentLength(); +} + +int64_t FileAllocationEntry::getTotalLength() { - int32_t bufSize = BUFSIZE; - char buf[BUFSIZE]; - memset(buf, 0, bufSize); - - _requestGroup->getSegmentMan()->diskWriter->writeData(buf, bufSize, _offset); - _offset += bufSize; + return _fileAllocationIterator->getTotalLength(); +} - int64_t totalLength = _requestGroup->getSegmentMan()->totalSize; - if(totalLength < _offset) { - _requestGroup->getSegmentMan()->diskWriter->truncate(totalLength); - _offset = totalLength; - } +bool FileAllocationEntry::finished() +{ + return _fileAllocationIterator->finished(); } +void FileAllocationEntry::allocateChunk() +{ + _fileAllocationIterator->allocateChunk(); +} -- cgit