From d734ff7d298d0abee4e6f75f94afd2d33e0c8fc6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 12 Aug 2012 16:52:53 +0900 Subject: Added new file allocation method called 'trunc' --file-allocation option can now take new value 'trunc'. 'trunc' uses ftruncate() system call or platform-specific counterpart to truncate a file to a specified length. --- src/TruncFileAllocationIterator.h | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/TruncFileAllocationIterator.h (limited to 'src/TruncFileAllocationIterator.h') diff --git a/src/TruncFileAllocationIterator.h b/src/TruncFileAllocationIterator.h new file mode 100644 index 00000000..79c34d88 --- /dev/null +++ b/src/TruncFileAllocationIterator.h @@ -0,0 +1,66 @@ +/* */ +#ifndef D_TRUNC_FILE_ALLOCATION_ITERATOR_H +#define D_TRUNC_FILE_ALLOCATION_ITERATOR_H + +#include "FileAllocationIterator.h" +#include "BinaryStream.h" + +namespace aria2 { + +// Use ftruncate() system call or platform-specific counterpart to set +// file length. This allocator may not allocate file space, it just +// changes file length information. +class TruncFileAllocationIterator:public FileAllocationIterator { +private: + BinaryStream* stream_; + int64_t offset_; + int64_t totalLength_; +public: + TruncFileAllocationIterator(BinaryStream* stream, int64_t offset, + int64_t totalLength); + + virtual void allocateChunk(); + + virtual bool finished(); + + virtual int64_t getCurrentLength(); + + virtual int64_t getTotalLength(); +}; + +} // namespace aria2 + +#endif // D_TRUNC_FILE_ALLOCATION_ITERATOR_H -- cgit