summaryrefslogtreecommitdiff
path: root/src/AdaptiveFileAllocationIterator.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-07-23 21:36:24 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-07-23 21:42:47 +0900
commit860f4dd06ace859470e118d4b9a8d10ddf92d076 (patch)
tree1effdc3fd73160b57f5d6d109662a66e33050d08 /src/AdaptiveFileAllocationIterator.cc
parentf56743b0833551aa6845d0a4f1d05da02cb52175 (diff)
Use int64_t instead of off_t
Using off_t, at least, in DiskAdaptor layer is problematic because torrent can contain under 2GiB files but total sum of those files may exceed 2GiB limit, which makes off_t overflow in 32 bit system without large file support. So we use int64_t in API. We'll check the file length before download so that it does not exceed max off_t.
Diffstat (limited to 'src/AdaptiveFileAllocationIterator.cc')
-rw-r--r--src/AdaptiveFileAllocationIterator.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/AdaptiveFileAllocationIterator.cc b/src/AdaptiveFileAllocationIterator.cc
index a96c9f4a..c343af1e 100644
--- a/src/AdaptiveFileAllocationIterator.cc
+++ b/src/AdaptiveFileAllocationIterator.cc
@@ -45,7 +45,7 @@
namespace aria2 {
AdaptiveFileAllocationIterator::AdaptiveFileAllocationIterator
-(BinaryStream* stream, off_t offset, off_t totalLength)
+(BinaryStream* stream, int64_t offset, int64_t totalLength)
: stream_(stream),
offset_(offset),
totalLength_(totalLength)
@@ -60,7 +60,8 @@ void AdaptiveFileAllocationIterator::allocateChunk()
try {
A2_LOG_DEBUG("Testing file system supports fallocate.");
if(offset_ < totalLength_) {
- off_t len = std::min(totalLength_-offset_, static_cast<off_t>(4096));
+ int64_t len = std::min(totalLength_-offset_,
+ static_cast<int64_t>(4096));
stream_->allocate(offset_, len);
offset_ += len;
}
@@ -95,7 +96,7 @@ bool AdaptiveFileAllocationIterator::finished()
}
}
-off_t AdaptiveFileAllocationIterator::getCurrentLength()
+int64_t AdaptiveFileAllocationIterator::getCurrentLength()
{
if(!allocator_) {
return offset_;
@@ -104,7 +105,7 @@ off_t AdaptiveFileAllocationIterator::getCurrentLength()
}
}
-off_t AdaptiveFileAllocationIterator::getTotalLength()
+int64_t AdaptiveFileAllocationIterator::getTotalLength()
{
return totalLength_;
}