summaryrefslogtreecommitdiff
path: root/src/FileAllocationEntry.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FileAllocationEntry.cc')
-rw-r--r--src/FileAllocationEntry.cc39
1 files changed, 26 insertions, 13 deletions
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();
+}