diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-10-11 16:58:24 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-10-11 16:58:24 +0000 |
| commit | 048a2cf59737f761876e81a77e8d064c45c752d7 (patch) | |
| tree | 65c9d5498aafe6a8c8e640ddfcc43c7013504d0d /src/DefaultDiskWriter.cc | |
| parent | e26bbbb9eee140ba24402fe872a752b42f0077de (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/DefaultDiskWriter.cc')
| -rw-r--r-- | src/DefaultDiskWriter.cc | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/src/DefaultDiskWriter.cc b/src/DefaultDiskWriter.cc index 4ddef412..4334391e 100644 --- a/src/DefaultDiskWriter.cc +++ b/src/DefaultDiskWriter.cc @@ -33,10 +33,7 @@ */ /* copyright --> */ #include "DefaultDiskWriter.h" -#include "DlAbortEx.h" #include "message.h" -#include "DefaultFileAllocator.h" -#include "GlowFileAllocator.h" #include "prefs.h" #include "Util.h" #include <errno.h> @@ -48,38 +45,7 @@ DefaultDiskWriter::~DefaultDiskWriter() {} void DefaultDiskWriter::initAndOpenFile(const string& filename, int64_t totalLength) + throw(DlAbortEx*) { createFile(filename); - try { - if(totalLength > 0) { - if(fileAllocator.isNull()) { - ftruncate(fd, 0); - } else { - logger->notice(MSG_ALLOCATING_FILE, - filename.c_str(), - Util::ullitos(totalLength).c_str()); - fileAllocator->allocate(fd, totalLength); - } - } - } catch(RecoverableException *e) { - throw new DlAbortEx(e, EX_FILE_WRITE, filename.c_str(), strerror(errno)); - } -} - -DefaultDiskWriter* DefaultDiskWriter::createNewDiskWriter(const Option* option) -{ - DefaultDiskWriter* diskWriter = new DefaultDiskWriter(); - if(option->get(PREF_FILE_ALLOCATION) == V_PREALLOC) { - DefaultFileAllocatorHandle allocator = new DefaultFileAllocator(); - allocator->setFileAllocationMonitor(FileAllocationMonitorFactory::getFactory()->createNewMonitor()); - diskWriter->setFileAllocator(allocator); - - GlowFileAllocatorHandle glowAllocator = new GlowFileAllocator(); - glowAllocator->setFileAllocationMonitor(FileAllocationMonitorFactory::getFactory()->createNewMonitor()); - diskWriter->setGlowFileAllocator(glowAllocator); - } else { - diskWriter->setFileAllocator(0); - diskWriter->setGlowFileAllocator(0); - } - return diskWriter; } |
