/* */ #include "FallocFileAllocationIterator.h" #include "DlAbortEx.h" namespace aria2 { FallocFileAllocationIterator::FallocFileAllocationIterator (BinaryStream* stream, off_t offset, uint64_t totalLength): stream_(stream), offset_(offset), totalLength_(totalLength) {} void FallocFileAllocationIterator::allocateChunk() { if(static_cast(offset_) < totalLength_) { stream_->allocate(offset_, totalLength_-offset_); offset_ = totalLength_; } else { stream_->truncate(totalLength_); offset_ = totalLength_; } } bool FallocFileAllocationIterator::finished() { return static_cast(offset_) == totalLength_; } off_t FallocFileAllocationIterator::getCurrentLength() { return offset_; } uint64_t FallocFileAllocationIterator::getTotalLength() { return totalLength_; } } // namespace aria2