Replaced uint64_t with off_t or int64_t.

Since off_t is int64_t with LFS, we cannot take advantage of extra
capacity of uint64_t.
pull/4/head
Tatsuhiro Tsujikawa 2011-12-07 22:57:34 +09:00
parent f25e67b017
commit 12988e5282
127 changed files with 457 additions and 490 deletions

View File

@ -62,7 +62,7 @@ AbstractDiskWriter::~AbstractDiskWriter()
closeFile(); closeFile();
} }
void AbstractDiskWriter::openFile(uint64_t totalLength) void AbstractDiskWriter::openFile(off_t totalLength)
{ {
try { try {
openExistingFile(totalLength); openExistingFile(totalLength);
@ -83,7 +83,7 @@ void AbstractDiskWriter::closeFile()
} }
} }
void AbstractDiskWriter::openExistingFile(uint64_t totalLength) void AbstractDiskWriter::openExistingFile(off_t totalLength)
{ {
int flags = O_BINARY; int flags = O_BINARY;
if(readOnly_) { if(readOnly_) {
@ -197,7 +197,7 @@ ssize_t AbstractDiskWriter::readData(unsigned char* data, size_t len, off_t offs
return ret; return ret;
} }
void AbstractDiskWriter::truncate(uint64_t length) void AbstractDiskWriter::truncate(off_t length)
{ {
if(fd_ == -1) { if(fd_ == -1) {
throw DL_ABORT_EX("File not opened."); throw DL_ABORT_EX("File not opened.");
@ -223,7 +223,7 @@ void AbstractDiskWriter::truncate(uint64_t length)
#endif #endif
} }
void AbstractDiskWriter::allocate(off_t offset, uint64_t length) void AbstractDiskWriter::allocate(off_t offset, off_t length)
{ {
#ifdef HAVE_SOME_FALLOCATE #ifdef HAVE_SOME_FALLOCATE
if(fd_ == -1) { if(fd_ == -1) {
@ -272,7 +272,7 @@ void AbstractDiskWriter::allocate(off_t offset, uint64_t length)
#endif // HAVE_SOME_FALLOCATE #endif // HAVE_SOME_FALLOCATE
} }
uint64_t AbstractDiskWriter::size() off_t AbstractDiskWriter::size()
{ {
return File(filename_).size(); return File(filename_).size();
} }

View File

@ -57,22 +57,22 @@ public:
AbstractDiskWriter(const std::string& filename); AbstractDiskWriter(const std::string& filename);
virtual ~AbstractDiskWriter(); virtual ~AbstractDiskWriter();
virtual void openFile(uint64_t totalLength = 0); virtual void openFile(off_t totalLength = 0);
virtual void closeFile(); virtual void closeFile();
virtual void openExistingFile(uint64_t totalLength = 0); virtual void openExistingFile(off_t totalLength = 0);
virtual void writeData(const unsigned char* data, size_t len, off_t offset); virtual void writeData(const unsigned char* data, size_t len, off_t offset);
virtual ssize_t readData(unsigned char* data, size_t len, off_t offset); virtual ssize_t readData(unsigned char* data, size_t len, off_t offset);
virtual void truncate(uint64_t length); virtual void truncate(off_t length);
// File must be opened before calling this function. // File must be opened before calling this function.
virtual void allocate(off_t offset, uint64_t length); virtual void allocate(off_t offset, off_t length);
virtual uint64_t size(); virtual off_t size();
virtual void enableReadOnly(); virtual void enableReadOnly();

View File

@ -85,12 +85,12 @@ bool AbstractSingleDiskAdaptor::fileExists()
return File(getFilePath()).exists(); return File(getFilePath()).exists();
} }
uint64_t AbstractSingleDiskAdaptor::size() off_t AbstractSingleDiskAdaptor::size()
{ {
return File(getFilePath()).size(); return File(getFilePath()).size();
} }
void AbstractSingleDiskAdaptor::truncate(uint64_t length) void AbstractSingleDiskAdaptor::truncate(off_t length)
{ {
diskWriter_->truncate(length); diskWriter_->truncate(length);
} }
@ -139,7 +139,7 @@ void AbstractSingleDiskAdaptor::setDiskWriter
diskWriter_ = diskWriter; diskWriter_ = diskWriter;
} }
void AbstractSingleDiskAdaptor::setTotalLength(const uint64_t& totalLength) void AbstractSingleDiskAdaptor::setTotalLength(const off_t& totalLength)
{ {
totalLength_ = totalLength; totalLength_ = totalLength;
} }

View File

@ -45,7 +45,7 @@ class FileAllocationIterator;
class AbstractSingleDiskAdaptor : public DiskAdaptor { class AbstractSingleDiskAdaptor : public DiskAdaptor {
private: private:
SharedHandle<DiskWriter> diskWriter_; SharedHandle<DiskWriter> diskWriter_;
uint64_t totalLength_; off_t totalLength_;
bool readOnly_; bool readOnly_;
public: public:
AbstractSingleDiskAdaptor(); AbstractSingleDiskAdaptor();
@ -67,9 +67,9 @@ public:
virtual bool fileExists(); virtual bool fileExists();
virtual uint64_t size(); virtual off_t size();
virtual void truncate(uint64_t length); virtual void truncate(off_t length);
virtual SharedHandle<FileAllocationIterator> fileAllocationIterator(); virtual SharedHandle<FileAllocationIterator> fileAllocationIterator();
@ -92,9 +92,9 @@ public:
return diskWriter_; return diskWriter_;
} }
void setTotalLength(const uint64_t& totalLength); void setTotalLength(const off_t& totalLength);
uint64_t getTotalLength() const off_t getTotalLength() const
{ {
return totalLength_; return totalLength_;
} }

View File

@ -45,7 +45,7 @@
namespace aria2 { namespace aria2 {
AdaptiveFileAllocationIterator::AdaptiveFileAllocationIterator AdaptiveFileAllocationIterator::AdaptiveFileAllocationIterator
(BinaryStream* stream, off_t offset, uint64_t totalLength) (BinaryStream* stream, off_t offset, off_t totalLength)
: stream_(stream), : stream_(stream),
offset_(offset), offset_(offset),
totalLength_(totalLength) totalLength_(totalLength)
@ -59,8 +59,8 @@ void AdaptiveFileAllocationIterator::allocateChunk()
#ifdef HAVE_FALLOCATE #ifdef HAVE_FALLOCATE
try { try {
A2_LOG_DEBUG("Testing file system supports fallocate."); A2_LOG_DEBUG("Testing file system supports fallocate.");
if(static_cast<uint64_t>(offset_) < totalLength_) { if(offset_ < totalLength_) {
off_t len = std::min(totalLength_-offset_, static_cast<uint64_t>(4096)); off_t len = std::min(totalLength_-offset_, static_cast<off_t>(4096));
stream_->allocate(offset_, len); stream_->allocate(offset_, len);
offset_ += len; offset_ += len;
} }
@ -89,7 +89,7 @@ void AdaptiveFileAllocationIterator::allocateChunk()
bool AdaptiveFileAllocationIterator::finished() bool AdaptiveFileAllocationIterator::finished()
{ {
if(!allocator_) { if(!allocator_) {
return (uint64_t)offset_ == totalLength_; return offset_ == totalLength_;
} else { } else {
return allocator_->finished(); return allocator_->finished();
} }
@ -104,7 +104,7 @@ off_t AdaptiveFileAllocationIterator::getCurrentLength()
} }
} }
uint64_t AdaptiveFileAllocationIterator::getTotalLength() off_t AdaptiveFileAllocationIterator::getTotalLength()
{ {
return totalLength_; return totalLength_;
} }

View File

@ -50,10 +50,10 @@ private:
off_t offset_; off_t offset_;
uint64_t totalLength_; off_t totalLength_;
public: public:
AdaptiveFileAllocationIterator AdaptiveFileAllocationIterator
(BinaryStream* stream, off_t offset, uint64_t totalLength); (BinaryStream* stream, off_t offset, off_t totalLength);
virtual ~AdaptiveFileAllocationIterator(); virtual ~AdaptiveFileAllocationIterator();
@ -63,7 +63,7 @@ public:
virtual off_t getCurrentLength(); virtual off_t getCurrentLength();
virtual uint64_t getTotalLength(); virtual off_t getTotalLength();
}; };
} // namespace aria2 } // namespace aria2

View File

@ -53,11 +53,11 @@ public:
// Truncates a file to given length. The default implementation does // Truncates a file to given length. The default implementation does
// nothing. // nothing.
virtual void truncate(uint64_t length) {} virtual void truncate(off_t length) {}
// Allocates given length bytes of disk space from given offset. The // Allocates given length bytes of disk space from given offset. The
// default implementation does nothing. // default implementation does nothing.
virtual void allocate(off_t offset, uint64_t length) {} virtual void allocate(off_t offset, off_t length) {}
}; };
typedef SharedHandle<BinaryStream> BinaryStreamHandle; typedef SharedHandle<BinaryStream> BinaryStreamHandle;

View File

@ -44,7 +44,7 @@ using namespace aria2::expr;
namespace aria2 { namespace aria2 {
BitfieldMan::BitfieldMan(size_t blockLength, uint64_t totalLength) BitfieldMan::BitfieldMan(size_t blockLength, off_t totalLength)
:blockLength_(blockLength), :blockLength_(blockLength),
totalLength_(totalLength), totalLength_(totalLength),
bitfieldLength_(0), bitfieldLength_(0),
@ -275,8 +275,8 @@ bool getSparseMissingUnusedIndex
} else { } else {
if((!bitfield::test(useBitfield, blocks, maxRange.startIndex-1) && if((!bitfield::test(useBitfield, blocks, maxRange.startIndex-1) &&
bitfield::test(bitfield, blocks, maxRange.startIndex-1)) || bitfield::test(bitfield, blocks, maxRange.startIndex-1)) ||
((uint64_t)(maxRange.endIndex-maxRange.startIndex)*blockLength_ (static_cast<uint64_t>(maxRange.endIndex-maxRange.startIndex)*
>= minSplitSize)) { blockLength_ >= minSplitSize)) {
index = maxRange.startIndex; index = maxRange.startIndex;
return true; return true;
} else { } else {
@ -663,7 +663,7 @@ void BitfieldMan::ensureFilterBitfield()
} }
} }
void BitfieldMan::addFilter(uint64_t offset, uint64_t length) { void BitfieldMan::addFilter(off_t offset, off_t length) {
ensureFilterBitfield(); ensureFilterBitfield();
if(length > 0) { if(length > 0) {
size_t startBlock = offset/blockLength_; size_t startBlock = offset/blockLength_;
@ -675,7 +675,7 @@ void BitfieldMan::addFilter(uint64_t offset, uint64_t length) {
updateCache(); updateCache();
} }
void BitfieldMan::removeFilter(uint64_t offset, uint64_t length) { void BitfieldMan::removeFilter(off_t offset, off_t length) {
ensureFilterBitfield(); ensureFilterBitfield();
if(length > 0) { if(length > 0) {
size_t startBlock = offset/blockLength_; size_t startBlock = offset/blockLength_;
@ -687,7 +687,7 @@ void BitfieldMan::removeFilter(uint64_t offset, uint64_t length) {
updateCache(); updateCache();
} }
void BitfieldMan::addNotFilter(uint64_t offset, uint64_t length) void BitfieldMan::addNotFilter(off_t offset, off_t length)
{ {
ensureFilterBitfield(); ensureFilterBitfield();
if(length > 0 && blocks_ > 0) { if(length > 0 && blocks_ > 0) {
@ -726,7 +726,7 @@ void BitfieldMan::clearFilter() {
updateCache(); updateCache();
} }
uint64_t BitfieldMan::getFilteredTotalLengthNow() const { off_t BitfieldMan::getFilteredTotalLengthNow() const {
if(!filterBitfield_) { if(!filterBitfield_) {
return 0; return 0;
} }
@ -735,13 +735,13 @@ uint64_t BitfieldMan::getFilteredTotalLengthNow() const {
return 0; return 0;
} }
if(bitfield::test(filterBitfield_, blocks_, blocks_-1)) { if(bitfield::test(filterBitfield_, blocks_, blocks_-1)) {
return ((uint64_t)filteredBlocks-1)*blockLength_+getLastBlockLength(); return ((off_t)filteredBlocks-1)*blockLength_+getLastBlockLength();
} else { } else {
return ((uint64_t)filteredBlocks)*blockLength_; return ((off_t)filteredBlocks)*blockLength_;
} }
} }
uint64_t BitfieldMan::getCompletedLength(bool useFilter) const { off_t BitfieldMan::getCompletedLength(bool useFilter) const {
unsigned char* temp; unsigned char* temp;
if(useFilter) { if(useFilter) {
temp = new unsigned char[bitfieldLength_]; temp = new unsigned char[bitfieldLength_];
@ -755,14 +755,15 @@ uint64_t BitfieldMan::getCompletedLength(bool useFilter) const {
temp = bitfield_; temp = bitfield_;
} }
size_t completedBlocks = bitfield::countSetBit(temp, blocks_); size_t completedBlocks = bitfield::countSetBit(temp, blocks_);
uint64_t completedLength = 0; off_t completedLength = 0;
if(completedBlocks == 0) { if(completedBlocks == 0) {
completedLength = 0; completedLength = 0;
} else { } else {
if(bitfield::test(temp, blocks_, blocks_-1)) { if(bitfield::test(temp, blocks_, blocks_-1)) {
completedLength = ((uint64_t)completedBlocks-1)*blockLength_+getLastBlockLength(); completedLength =
((off_t)completedBlocks-1)*blockLength_+getLastBlockLength();
} else { } else {
completedLength = ((uint64_t)completedBlocks)*blockLength_; completedLength = ((off_t)completedBlocks)*blockLength_;
} }
} }
if(useFilter) { if(useFilter) {
@ -771,11 +772,11 @@ uint64_t BitfieldMan::getCompletedLength(bool useFilter) const {
return completedLength; return completedLength;
} }
uint64_t BitfieldMan::getCompletedLengthNow() const { off_t BitfieldMan::getCompletedLengthNow() const {
return getCompletedLength(false); return getCompletedLength(false);
} }
uint64_t BitfieldMan::getFilteredCompletedLengthNow() const { off_t BitfieldMan::getFilteredCompletedLengthNow() const {
return getCompletedLength(true); return getCompletedLength(true);
} }
@ -814,7 +815,7 @@ void BitfieldMan::setBitRange(size_t startIndex, size_t endIndex)
updateCache(); updateCache();
} }
bool BitfieldMan::isBitSetOffsetRange(uint64_t offset, uint64_t length) const bool BitfieldMan::isBitSetOffsetRange(off_t offset, off_t length) const
{ {
if(length <= 0) { if(length <= 0) {
return false; return false;
@ -835,11 +836,11 @@ bool BitfieldMan::isBitSetOffsetRange(uint64_t offset, uint64_t length) const
return true; return true;
} }
uint64_t BitfieldMan::getOffsetCompletedLength off_t BitfieldMan::getOffsetCompletedLength
(uint64_t offset, (off_t offset,
uint64_t length) const off_t length) const
{ {
uint64_t res = 0; off_t res = 0;
if(length == 0 || totalLength_ <= offset) { if(length == 0 || totalLength_ <= offset) {
return 0; return 0;
} }
@ -868,12 +869,12 @@ uint64_t BitfieldMan::getOffsetCompletedLength
return res; return res;
} }
uint64_t BitfieldMan::getMissingUnusedLength(size_t startingIndex) const off_t BitfieldMan::getMissingUnusedLength(size_t startingIndex) const
{ {
if(startingIndex < 0 || blocks_ <= startingIndex) { if(startingIndex < 0 || blocks_ <= startingIndex) {
return 0; return 0;
} }
uint64_t length = 0; off_t length = 0;
for(size_t i = startingIndex; i < blocks_; ++i) { for(size_t i = startingIndex; i < blocks_; ++i) {
if(isBitSet(i) || isUseBitSet(i)) { if(isBitSet(i) || isUseBitSet(i)) {
break; break;

View File

@ -46,7 +46,7 @@ namespace aria2 {
class BitfieldMan { class BitfieldMan {
private: private:
size_t blockLength_; size_t blockLength_;
uint64_t totalLength_; off_t totalLength_;
size_t bitfieldLength_; size_t bitfieldLength_;
size_t blocks_; size_t blocks_;
bool filterEnabled_; bool filterEnabled_;
@ -57,9 +57,9 @@ private:
// for caching // for caching
size_t cachedNumMissingBlock_; size_t cachedNumMissingBlock_;
size_t cachedNumFilteredBlock_; size_t cachedNumFilteredBlock_;
uint64_t cachedCompletedLength_; off_t cachedCompletedLength_;
uint64_t cachedFilteredCompletedLength_; off_t cachedFilteredCompletedLength_;
uint64_t cachedFilteredTotalLength_; off_t cachedFilteredTotalLength_;
bool setBitInternal(unsigned char* bitfield, size_t index, bool on); bool setBitInternal(unsigned char* bitfield, size_t index, bool on);
bool setFilterBit(size_t index); bool setFilterBit(size_t index);
@ -67,7 +67,7 @@ private:
size_t getStartIndex(size_t index) const; size_t getStartIndex(size_t index) const;
size_t getEndIndex(size_t index) const; size_t getEndIndex(size_t index) const;
uint64_t getCompletedLength(bool useFilter) const; off_t getCompletedLength(bool useFilter) const;
// If filterBitfield_ is 0, allocate bitfieldLength_ bytes to it and // If filterBitfield_ is 0, allocate bitfieldLength_ bytes to it and
// set 0 to all bytes. // set 0 to all bytes.
@ -84,7 +84,7 @@ public:
bool operator==(const Range& range) const; bool operator==(const Range& range) const;
}; };
public: public:
BitfieldMan(size_t blockLength, uint64_t totalLength); BitfieldMan(size_t blockLength, off_t totalLength);
BitfieldMan(const BitfieldMan& bitfieldMan); BitfieldMan(const BitfieldMan& bitfieldMan);
~BitfieldMan(); ~BitfieldMan();
@ -99,7 +99,7 @@ public:
size_t getBlockLength(size_t index) const; size_t getBlockLength(size_t index) const;
uint64_t getTotalLength() const { return totalLength_; } off_t getTotalLength() const { return totalLength_; }
// Returns true iff there is a bit index which is set in bitfield_, // Returns true iff there is a bit index which is set in bitfield_,
// but not set in this object. // but not set in this object.
@ -238,10 +238,10 @@ public:
void clearAllUseBit(); void clearAllUseBit();
void setAllUseBit(); void setAllUseBit();
void addFilter(uint64_t offset, uint64_t length); void addFilter(off_t offset, off_t length);
void removeFilter(uint64_t offset, uint64_t length); void removeFilter(off_t offset, off_t length);
// Add filter not in the range of [offset, offset+length) bytes // Add filter not in the range of [offset, offset+length) bytes
void addNotFilter(uint64_t offset, uint64_t length); void addNotFilter(off_t offset, off_t length);
// Clears filter and disables filter // Clears filter and disables filter
void clearFilter(); void clearFilter();
@ -254,29 +254,29 @@ public:
} }
// affected by filter // affected by filter
uint64_t getFilteredTotalLength() const off_t getFilteredTotalLength() const
{ {
return cachedFilteredTotalLength_; return cachedFilteredTotalLength_;
} }
// affected by filter // affected by filter
uint64_t getFilteredTotalLengthNow() const; off_t getFilteredTotalLengthNow() const;
uint64_t getCompletedLength() const off_t getCompletedLength() const
{ {
return cachedCompletedLength_; return cachedCompletedLength_;
} }
uint64_t getCompletedLengthNow() const; off_t getCompletedLengthNow() const;
// affected by filter // affected by filter
uint64_t getFilteredCompletedLength() const off_t getFilteredCompletedLength() const
{ {
return cachedFilteredCompletedLength_; return cachedFilteredCompletedLength_;
} }
// affected by filter // affected by filter
uint64_t getFilteredCompletedLengthNow() const; off_t getFilteredCompletedLengthNow() const;
void updateCache(); void updateCache();
@ -286,13 +286,13 @@ public:
void setBitRange(size_t startIndex, size_t endIndex); void setBitRange(size_t startIndex, size_t endIndex);
bool isBitSetOffsetRange(uint64_t offset, uint64_t length) const; bool isBitSetOffsetRange(off_t offset, off_t length) const;
// Returns completed length in bytes in range [offset, // Returns completed length in bytes in range [offset,
// offset+length). This function will not affected by filter. // offset+length). This function will not affected by filter.
uint64_t getOffsetCompletedLength(uint64_t offset, uint64_t length) const; off_t getOffsetCompletedLength(off_t offset, off_t length) const;
uint64_t getMissingUnusedLength(size_t startingIndex) const; off_t getMissingUnusedLength(size_t startingIndex) const;
const unsigned char* getFilterBitfield() const const unsigned char* getFilterBitfield() const
{ {

View File

@ -42,7 +42,7 @@ namespace aria2 {
class BtRuntime { class BtRuntime {
private: private:
uint64_t uploadLengthAtStartup_; off_t uploadLengthAtStartup_;
bool halt_; bool halt_;
unsigned int connections_; unsigned int connections_;
bool ready_; bool ready_;
@ -60,11 +60,11 @@ public:
~BtRuntime(); ~BtRuntime();
uint64_t getUploadLengthAtStartup() const { off_t getUploadLengthAtStartup() const {
return uploadLengthAtStartup_; return uploadLengthAtStartup_;
} }
void setUploadLengthAtStartup(uint64_t length) { void setUploadLengthAtStartup(off_t length) {
uploadLengthAtStartup_ = length; uploadLengthAtStartup_ = length;
} }

View File

@ -50,16 +50,16 @@ void ByteArrayDiskWriter::clear()
buf_.str(A2STR::NIL); buf_.str(A2STR::NIL);
} }
void ByteArrayDiskWriter::initAndOpenFile(uint64_t totalLength) void ByteArrayDiskWriter::initAndOpenFile(off_t totalLength)
{ {
clear(); clear();
} }
void ByteArrayDiskWriter::openFile(uint64_t totalLength) {} void ByteArrayDiskWriter::openFile(off_t totalLength) {}
void ByteArrayDiskWriter::closeFile() {} void ByteArrayDiskWriter::closeFile() {}
void ByteArrayDiskWriter::openExistingFile(uint64_t totalLength) void ByteArrayDiskWriter::openExistingFile(off_t totalLength)
{ {
openFile(); openFile();
} }
@ -70,10 +70,10 @@ void ByteArrayDiskWriter::writeData(const unsigned char* data, size_t dataLength
throw DL_ABORT_EX(fmt("Maximum length(%lu) exceeded.", throw DL_ABORT_EX(fmt("Maximum length(%lu) exceeded.",
static_cast<unsigned long>(maxLength_))); static_cast<unsigned long>(maxLength_)));
} }
uint64_t length = size(); off_t length = size();
if(length < (uint64_t)position) { if(length < position) {
buf_.seekp(length, std::ios::beg); buf_.seekp(length, std::ios::beg);
for(uint64_t i = length; i < (uint64_t)position; ++i) { for(off_t i = length; i < position; ++i) {
buf_.put('\0'); buf_.put('\0');
} }
} else { } else {
@ -90,7 +90,7 @@ ssize_t ByteArrayDiskWriter::readData(unsigned char* data, size_t len, off_t pos
return buf_.gcount(); return buf_.gcount();
} }
uint64_t ByteArrayDiskWriter::size() off_t ByteArrayDiskWriter::size()
{ {
buf_.seekg(0, std::ios::end); buf_.seekg(0, std::ios::end);
buf_.clear(); buf_.clear();

View File

@ -49,18 +49,18 @@ public:
ByteArrayDiskWriter(size_t maxLength = 5*1024*1024); ByteArrayDiskWriter(size_t maxLength = 5*1024*1024);
virtual ~ByteArrayDiskWriter(); virtual ~ByteArrayDiskWriter();
virtual void initAndOpenFile(uint64_t totalLength = 0); virtual void initAndOpenFile(off_t totalLength = 0);
virtual void openFile(uint64_t totalLength = 0); virtual void openFile(off_t totalLength = 0);
virtual void closeFile(); virtual void closeFile();
virtual void openExistingFile(uint64_t totalLength = 0); virtual void openExistingFile(off_t totalLength = 0);
virtual void writeData(const unsigned char* data, size_t len, off_t position); virtual void writeData(const unsigned char* data, size_t len, off_t position);
virtual ssize_t readData(unsigned char* data, size_t len, off_t position); virtual ssize_t readData(unsigned char* data, size_t len, off_t position);
virtual uint64_t size(); virtual off_t size();
void setString(const std::string& s); void setString(const std::string& s);

View File

@ -56,7 +56,7 @@ void CheckIntegrityEntry::validateChunk()
validator_->validateChunk(); validator_->validateChunk();
} }
uint64_t CheckIntegrityEntry::getTotalLength() off_t CheckIntegrityEntry::getTotalLength()
{ {
if(!validator_) { if(!validator_) {
return 0; return 0;

View File

@ -61,7 +61,7 @@ public:
virtual ~CheckIntegrityEntry(); virtual ~CheckIntegrityEntry();
virtual uint64_t getTotalLength(); virtual off_t getTotalLength();
virtual off_t getCurrentLength(); virtual off_t getCurrentLength();

View File

@ -56,9 +56,9 @@ bool ChunkChecksum::validateChunk
return !digest.empty() && actualDigest == digest; return !digest.empty() && actualDigest == digest;
} }
uint64_t ChunkChecksum::getEstimatedDataLength() const off_t ChunkChecksum::getEstimatedDataLength() const
{ {
return static_cast<uint64_t>(pieceLength_)*pieceHashes_.size(); return static_cast<off_t>(pieceLength_)*pieceHashes_.size();
} }
size_t ChunkChecksum::countPieceHash() const size_t ChunkChecksum::countPieceHash() const

View File

@ -60,7 +60,7 @@ public:
bool validateChunk(const std::string& actualDigest, bool validateChunk(const std::string& actualDigest,
size_t index) const; size_t index) const;
uint64_t getEstimatedDataLength() const; off_t getEstimatedDataLength() const;
size_t countPieceHash() const; size_t countPieceHash() const;

View File

@ -96,8 +96,11 @@ bool ChunkedDecodingStreamFilter::readChunkSize
if(extPos == std::string::npos || crlfPos < extPos) { if(extPos == std::string::npos || crlfPos < extPos) {
extPos = crlfPos; extPos = crlfPos;
} }
chunkSize_ = util::parseULLInt chunkSize_ = util::parseLLInt
(std::string(buf_.begin(), buf_.begin()+extPos), 16); (std::string(buf_.begin(), buf_.begin()+extPos), 16);
if(chunkSize_ < 0) {
throw DL_ABORT_EX("Chunk size must be positive");
}
assert(crlfPos+2 > pbufSize); assert(crlfPos+2 > pbufSize);
inbufOffset += crlfPos+2-pbufSize; inbufOffset += crlfPos+2-pbufSize;
buf_.clear(); buf_.clear();
@ -155,8 +158,8 @@ bool ChunkedDecodingStreamFilter::readData
const SharedHandle<BinaryStream>& out, const SharedHandle<BinaryStream>& out,
const SharedHandle<Segment>& segment) const SharedHandle<Segment>& segment)
{ {
uint64_t readlen = off_t readlen =
std::min(chunkSize_, static_cast<uint64_t>(inlen-inbufOffset)); std::min(chunkSize_, static_cast<off_t>(inlen-inbufOffset));
outlen += getDelegate()->transform(out, segment, inbuf+inbufOffset, readlen); outlen += getDelegate()->transform(out, segment, inbuf+inbufOffset, readlen);
chunkSize_ -= readlen; chunkSize_ -= readlen;
inbufOffset += readlen; inbufOffset += readlen;

View File

@ -59,7 +59,7 @@ private:
std::string buf_; std::string buf_;
uint64_t chunkSize_; off_t chunkSize_;
size_t bytesProcessed_; size_t bytesProcessed_;

View File

@ -142,7 +142,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() {
numWant = 0; numWant = 0;
} }
TransferStat stat = peerStorage_->calculateStat(); TransferStat stat = peerStorage_->calculateStat();
uint64_t left = off_t left =
pieceStorage_->getTotalLength()-pieceStorage_->getCompletedLength(); pieceStorage_->getTotalLength()-pieceStorage_->getCompletedLength();
// Use last 8 bytes of peer ID as a key // Use last 8 bytes of peer ID as a key
const size_t keyLen = 8; const size_t keyLen = 8;

View File

@ -275,7 +275,7 @@ void DefaultBtProgressInfoFile::load()
if(version >= 1) { if(version >= 1) {
totalLength = ntoh64(totalLength); totalLength = ntoh64(totalLength);
} }
if(totalLength != dctx_->getTotalLength()) { if(totalLength != static_cast<uint64_t>(dctx_->getTotalLength())) {
throw DL_ABORT_EX throw DL_ABORT_EX
(fmt("total length mismatch. expected: %lld, actual: %lld", (fmt("total length mismatch. expected: %lld, actual: %lld",
static_cast<long long int>(dctx_->getTotalLength()), static_cast<long long int>(dctx_->getTotalLength()),

View File

@ -41,7 +41,7 @@ DefaultDiskWriter::DefaultDiskWriter(const std::string& filename):
DefaultDiskWriter::~DefaultDiskWriter() {} DefaultDiskWriter::~DefaultDiskWriter() {}
void DefaultDiskWriter::initAndOpenFile(uint64_t totalLength) void DefaultDiskWriter::initAndOpenFile(off_t totalLength)
{ {
createFile(); createFile();
} }

View File

@ -45,7 +45,7 @@ public:
virtual ~DefaultDiskWriter(); virtual ~DefaultDiskWriter();
virtual void initAndOpenFile(uint64_t totalLength = 0); virtual void initAndOpenFile(off_t totalLength = 0);
}; };
typedef SharedHandle<DefaultDiskWriter> DefaultDiskWriterHandle; typedef SharedHandle<DefaultDiskWriter> DefaultDiskWriterHandle;

View File

@ -60,8 +60,8 @@ const size_t MAX_PEER_LIST_UPDATE = 100;
DefaultPeerStorage::DefaultPeerStorage() DefaultPeerStorage::DefaultPeerStorage()
: maxPeerListSize_(MAX_PEER_LIST_SIZE), : maxPeerListSize_(MAX_PEER_LIST_SIZE),
removedPeerSessionDownloadLength_(0), removedPeerSessionDownloadLength_(0LL),
removedPeerSessionUploadLength_(0), removedPeerSessionUploadLength_(0LL),
seederStateChoke_(new BtSeederStateChoke()), seederStateChoke_(new BtSeederStateChoke()),
leecherStateChoke_(new BtLeecherStateChoke()), leecherStateChoke_(new BtLeecherStateChoke()),
lastTransferStatMapUpdated_(0) lastTransferStatMapUpdated_(0)

View File

@ -56,8 +56,8 @@ private:
size_t maxPeerListSize_; size_t maxPeerListSize_;
std::deque<SharedHandle<Peer> > peers_; std::deque<SharedHandle<Peer> > peers_;
std::deque<SharedHandle<Peer> > droppedPeers_; std::deque<SharedHandle<Peer> > droppedPeers_;
uint64_t removedPeerSessionDownloadLength_; int64_t removedPeerSessionDownloadLength_;
uint64_t removedPeerSessionUploadLength_; int64_t removedPeerSessionUploadLength_;
BtSeederStateChoke* seederStateChoke_; BtSeederStateChoke* seederStateChoke_;
BtLeecherStateChoke* leecherStateChoke_; BtLeecherStateChoke* leecherStateChoke_;

View File

@ -518,28 +518,28 @@ bool DefaultPieceStorage::isPieceUsed(size_t index)
return bitfieldMan_->isUseBitSet(index); return bitfieldMan_->isUseBitSet(index);
} }
uint64_t DefaultPieceStorage::getTotalLength() off_t DefaultPieceStorage::getTotalLength()
{ {
return bitfieldMan_->getTotalLength(); return bitfieldMan_->getTotalLength();
} }
uint64_t DefaultPieceStorage::getFilteredTotalLength() off_t DefaultPieceStorage::getFilteredTotalLength()
{ {
return bitfieldMan_->getFilteredTotalLength(); return bitfieldMan_->getFilteredTotalLength();
} }
uint64_t DefaultPieceStorage::getCompletedLength() off_t DefaultPieceStorage::getCompletedLength()
{ {
uint64_t completedLength = off_t completedLength =
bitfieldMan_->getCompletedLength()+getInFlightPieceCompletedLength(); bitfieldMan_->getCompletedLength()+getInFlightPieceCompletedLength();
uint64_t totalLength = getTotalLength(); off_t totalLength = getTotalLength();
if(completedLength > totalLength) { if(completedLength > totalLength) {
completedLength = totalLength; completedLength = totalLength;
} }
return completedLength; return completedLength;
} }
uint64_t DefaultPieceStorage::getFilteredCompletedLength() off_t DefaultPieceStorage::getFilteredCompletedLength()
{ {
return bitfieldMan_->getFilteredCompletedLength()+ return bitfieldMan_->getFilteredCompletedLength()+
getInFlightPieceCompletedLength(); getInFlightPieceCompletedLength();
@ -712,7 +712,7 @@ void DefaultPieceStorage::markAllPiecesDone()
bitfieldMan_->setAllBit(); bitfieldMan_->setAllBit();
} }
void DefaultPieceStorage::markPiecesDone(uint64_t length) void DefaultPieceStorage::markPiecesDone(off_t length)
{ {
if(length == bitfieldMan_->getTotalLength()) { if(length == bitfieldMan_->getTotalLength()) {
bitfieldMan_->setAllBit(); bitfieldMan_->setAllBit();

View File

@ -187,13 +187,13 @@ public:
virtual bool isPieceUsed(size_t index); virtual bool isPieceUsed(size_t index);
virtual uint64_t getTotalLength(); virtual off_t getTotalLength();
virtual uint64_t getFilteredTotalLength(); virtual off_t getFilteredTotalLength();
virtual uint64_t getCompletedLength(); virtual off_t getCompletedLength();
virtual uint64_t getFilteredCompletedLength(); virtual off_t getFilteredCompletedLength();
virtual void initStorage(); virtual void initStorage();
@ -246,7 +246,7 @@ public:
virtual void markAllPiecesDone(); virtual void markAllPiecesDone();
virtual void markPiecesDone(uint64_t length); virtual void markPiecesDone(off_t length);
virtual void markPieceMissing(size_t index); virtual void markPieceMissing(size_t index);

View File

@ -66,7 +66,7 @@ public:
virtual bool fileExists() = 0; virtual bool fileExists() = 0;
virtual uint64_t size() = 0; virtual off_t size() = 0;
template<typename InputIterator> template<typename InputIterator>
void setFileEntries(InputIterator first, InputIterator last) void setFileEntries(InputIterator first, InputIterator last)

View File

@ -51,9 +51,9 @@ public:
/** /**
* Opens file. If the file exists, then it is truncated to 0 length. * Opens file. If the file exists, then it is truncated to 0 length.
*/ */
virtual void initAndOpenFile(uint64_t totalLength = 0) = 0; virtual void initAndOpenFile(off_t totalLength = 0) = 0;
virtual void openFile(uint64_t totalLength = 0) = 0; virtual void openFile(off_t totalLength = 0) = 0;
/** /**
* Closes this output stream. * Closes this output stream.
@ -65,10 +65,10 @@ public:
* Opens a file. If the file doesnot exists, an exception may be * Opens a file. If the file doesnot exists, an exception may be
* thrown. * thrown.
*/ */
virtual void openExistingFile(uint64_t totalLength = 0) = 0; virtual void openExistingFile(off_t totalLength = 0) = 0;
// Returns file length // Returns file length
virtual uint64_t size() = 0; virtual off_t size() = 0;
// Enables read-only mode. After this call, openExistingFile() opens // Enables read-only mode. After this call, openExistingFile() opens
// file in read-only mode. This is an optional functionality. The // file in read-only mode. This is an optional functionality. The

View File

@ -146,8 +146,8 @@ bool DownloadCommand::executeInternal() {
size_t bufSize; size_t bufSize;
if(sinkFilterOnly_) { if(sinkFilterOnly_) {
if(segment->getLength() > 0) { if(segment->getLength() > 0) {
if(static_cast<uint64_t>(segment->getPosition()+segment->getLength()) <= if(static_cast<off_t>(segment->getPosition()+segment->getLength()) <=
static_cast<uint64_t>(getFileEntry()->getLastOffset())) { getFileEntry()->getLastOffset()) {
bufSize = std::min(segment->getLength()-segment->getWrittenLength(), bufSize = std::min(segment->getLength()-segment->getWrittenLength(),
getSocketRecvBuffer()->getBufferLength()); getSocketRecvBuffer()->getBufferLength());
} else { } else {

View File

@ -57,7 +57,7 @@ DownloadContext::DownloadContext():
metalinkServerContacted_(false) {} metalinkServerContacted_(false) {}
DownloadContext::DownloadContext(size_t pieceLength, DownloadContext::DownloadContext(size_t pieceLength,
uint64_t totalLength, off_t totalLength,
const std::string& path): const std::string& path):
pieceLength_(pieceLength), pieceLength_(pieceLength),
checksumVerified_(false), checksumVerified_(false),
@ -98,9 +98,7 @@ SharedHandle<FileEntry>
DownloadContext::findFileEntryByOffset(off_t offset) const DownloadContext::findFileEntryByOffset(off_t offset) const
{ {
if(fileEntries_.empty() || if(fileEntries_.empty() ||
(offset > 0 && (offset > 0 && fileEntries_.back()->getLastOffset() <= offset)) {
fileEntries_.back()->getOffset()+fileEntries_.back()->getLength() <=
static_cast<uint64_t>(offset))){
return SharedHandle<FileEntry>(); return SharedHandle<FileEntry>();
} }
@ -200,7 +198,7 @@ size_t DownloadContext::getNumPieces() const
} }
} }
uint64_t DownloadContext::getTotalLength() const off_t DownloadContext::getTotalLength() const
{ {
if(fileEntries_.empty()) { if(fileEntries_.empty()) {
return 0; return 0;

View File

@ -93,7 +93,7 @@ public:
// Convenient constructor that creates single file download. path // Convenient constructor that creates single file download. path
// should be escaped with util::escapePath(...). // should be escaped with util::escapePath(...).
DownloadContext(size_t pieceLength, DownloadContext(size_t pieceLength,
uint64_t totalLength, off_t totalLength,
const std::string& path = A2STR::NIL); const std::string& path = A2STR::NIL);
~DownloadContext(); ~DownloadContext();
@ -114,7 +114,7 @@ public:
pieceHashes_.assign(first, last); pieceHashes_.assign(first, last);
} }
uint64_t getTotalLength() const; off_t getTotalLength() const;
bool knowsTotalLength() const { return knowsTotalLength_; } bool knowsTotalLength() const { return knowsTotalLength_; }

View File

@ -79,11 +79,11 @@ struct DownloadResult
SharedHandle<MetadataInfo> metadataInfo; SharedHandle<MetadataInfo> metadataInfo;
uint64_t totalLength; off_t totalLength;
uint64_t completedLength; off_t completedLength;
uint64_t uploadLength; off_t uploadLength;
std::string bitfield; std::string bitfield;

View File

@ -38,12 +38,12 @@
namespace aria2 { namespace aria2 {
FallocFileAllocationIterator::FallocFileAllocationIterator FallocFileAllocationIterator::FallocFileAllocationIterator
(BinaryStream* stream, off_t offset, uint64_t totalLength): (BinaryStream* stream, off_t offset, off_t totalLength):
stream_(stream), offset_(offset), totalLength_(totalLength) {} stream_(stream), offset_(offset), totalLength_(totalLength) {}
void FallocFileAllocationIterator::allocateChunk() void FallocFileAllocationIterator::allocateChunk()
{ {
if(static_cast<uint64_t>(offset_) < totalLength_) { if(offset_ < totalLength_) {
stream_->allocate(offset_, totalLength_-offset_); stream_->allocate(offset_, totalLength_-offset_);
offset_ = totalLength_; offset_ = totalLength_;
} else { } else {
@ -54,7 +54,7 @@ void FallocFileAllocationIterator::allocateChunk()
bool FallocFileAllocationIterator::finished() bool FallocFileAllocationIterator::finished()
{ {
return static_cast<uint64_t>(offset_) == totalLength_; return offset_ == totalLength_;
} }
off_t FallocFileAllocationIterator::getCurrentLength() off_t FallocFileAllocationIterator::getCurrentLength()
@ -62,7 +62,7 @@ off_t FallocFileAllocationIterator::getCurrentLength()
return offset_; return offset_;
} }
uint64_t FallocFileAllocationIterator::getTotalLength() off_t FallocFileAllocationIterator::getTotalLength()
{ {
return totalLength_; return totalLength_;
} }

View File

@ -45,10 +45,10 @@ class FallocFileAllocationIterator:public FileAllocationIterator {
private: private:
BinaryStream* stream_; BinaryStream* stream_;
off_t offset_; off_t offset_;
uint64_t totalLength_; off_t totalLength_;
public: public:
FallocFileAllocationIterator(BinaryStream* stream, off_t offset, FallocFileAllocationIterator(BinaryStream* stream, off_t offset,
uint64_t totalLength); off_t totalLength);
virtual void allocateChunk(); virtual void allocateChunk();
@ -56,7 +56,7 @@ public:
virtual off_t getCurrentLength(); virtual off_t getCurrentLength();
virtual uint64_t getTotalLength(); virtual off_t getTotalLength();
}; };
} // namespace aria2 } // namespace aria2

View File

@ -103,7 +103,7 @@ bool File::remove() {
} }
} }
uint64_t File::size() { off_t File::size() {
a2_struct_stat fstat; a2_struct_stat fstat;
if(fillStat(fstat) < 0) { if(fillStat(fstat) < 0) {
return 0; return 0;

View File

@ -94,7 +94,7 @@ public:
*/ */
bool mkdirs(); bool mkdirs();
uint64_t size(); off_t size();
mode_t mode(); mode_t mode();

View File

@ -54,7 +54,7 @@ off_t FileAllocationEntry::getCurrentLength()
return fileAllocationIterator_->getCurrentLength(); return fileAllocationIterator_->getCurrentLength();
} }
uint64_t FileAllocationEntry::getTotalLength() off_t FileAllocationEntry::getTotalLength()
{ {
return fileAllocationIterator_->getTotalLength(); return fileAllocationIterator_->getTotalLength();
} }

View File

@ -56,7 +56,7 @@ public:
virtual off_t getCurrentLength(); virtual off_t getCurrentLength();
virtual uint64_t getTotalLength(); virtual off_t getTotalLength();
virtual bool finished(); virtual bool finished();

View File

@ -52,7 +52,7 @@ public:
virtual off_t getCurrentLength() = 0; virtual off_t getCurrentLength() = 0;
virtual uint64_t getTotalLength() = 0; virtual off_t getTotalLength() = 0;
}; };
} // namespace aria2 } // namespace aria2

View File

@ -53,7 +53,7 @@ namespace aria2 {
FileEntry::FileEntry FileEntry::FileEntry
(const std::string& path, (const std::string& path,
uint64_t length, off_t length,
off_t offset, off_t offset,
const std::vector<std::string>& uris) const std::vector<std::string>& uris)
: path_(path), : path_(path),

View File

@ -61,7 +61,7 @@ private:
std::string path_; std::string path_;
std::deque<std::string> uris_; std::deque<std::string> uris_;
std::deque<std::string> spentUris_; std::deque<std::string> spentUris_;
uint64_t length_; off_t length_;
off_t offset_; off_t offset_;
bool requested_; bool requested_;
std::deque<SharedHandle<Request> > requestPool_; std::deque<SharedHandle<Request> > requestPool_;
@ -79,7 +79,7 @@ private:
public: public:
FileEntry(); FileEntry();
FileEntry(const std::string& path, uint64_t length, off_t offset, FileEntry(const std::string& path, off_t length, off_t offset,
const std::vector<std::string>& uris = std::vector<std::string>()); const std::vector<std::string>& uris = std::vector<std::string>());
~FileEntry(); ~FileEntry();
@ -94,9 +94,9 @@ public:
void setPath(const std::string& path); void setPath(const std::string& path);
uint64_t getLength() const { return length_; } off_t getLength() const { return length_; }
void setLength(uint64_t length) { length_ = length; } void setLength(off_t length) { length_ = length; }
off_t getOffset() const { return offset_; } off_t getOffset() const { return offset_; }

View File

@ -400,14 +400,17 @@ unsigned int FtpConnection::receiveResponse()
# define ULONGLONG_SCANF "%Lu" # define ULONGLONG_SCANF "%Lu"
#endif // __MINGW32__ #endif // __MINGW32__
unsigned int FtpConnection::receiveSizeResponse(uint64_t& size) unsigned int FtpConnection::receiveSizeResponse(off_t& size)
{ {
std::pair<unsigned int, std::string> response; std::pair<unsigned int, std::string> response;
if(bulkReceiveResponse(response)) { if(bulkReceiveResponse(response)) {
if(response.first == 213) { if(response.first == 213) {
std::pair<Sip, Sip> rp; std::pair<Sip, Sip> rp;
util::divide(rp, response.second.begin(), response.second.end(), ' '); util::divide(rp, response.second.begin(), response.second.end(), ' ');
size = util::parseULLInt(std::string(rp.second.first, rp.second.second)); size = util::parseLLInt(std::string(rp.second.first, rp.second.second));
if(size < 0) {
throw DL_ABORT_EX("Size must be positive");
}
} }
return response.first; return response.first;
} else { } else {

View File

@ -102,7 +102,7 @@ public:
bool sendRetr(); bool sendRetr();
unsigned int receiveResponse(); unsigned int receiveResponse();
unsigned int receiveSizeResponse(uint64_t& size); unsigned int receiveSizeResponse(off_t& size);
// Returns status code of MDTM reply. If the status code is 213, parses // Returns status code of MDTM reply. If the status code is 213, parses
// time-val and store it in time. // time-val and store it in time.
// If a code other than 213 is returned, time is not touched. // If a code other than 213 is returned, time is not touched.

View File

@ -364,7 +364,7 @@ bool FtpNegotiationCommand::sendSize() {
return false; return false;
} }
bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength) bool FtpNegotiationCommand::onFileSizeDetermined(off_t totalLength)
{ {
getFileEntry()->setLength(totalLength); getFileEntry()->setLength(totalLength);
if(getFileEntry()->getPath().empty()) { if(getFileEntry()->getPath().empty()) {
@ -464,7 +464,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
} }
bool FtpNegotiationCommand::recvSize() { bool FtpNegotiationCommand::recvSize() {
uint64_t size = 0; off_t size = 0;
unsigned int status = ftp_->receiveSizeResponse(size); unsigned int status = ftp_->receiveSizeResponse(size);
if(status == 0) { if(status == 0) {
return false; return false;

View File

@ -137,7 +137,7 @@ private:
void poolConnection() const; void poolConnection() const;
bool onFileSizeDetermined(uint64_t totalLength); bool onFileSizeDetermined(off_t totalLength);
void onDryRunFileFound(); void onDryRunFileFound();

View File

@ -108,16 +108,23 @@ HttpHeader::equalRange(const std::string& name) const
return table_.equal_range(name); return table_.equal_range(name);
} }
unsigned int HttpHeader::findAsUInt(const std::string& name) const { int32_t HttpHeader::findAsInt(const std::string& name) const
return findAsULLInt(name); {
}
uint64_t HttpHeader::findAsULLInt(const std::string& name) const {
const std::string& value = find(name); const std::string& value = find(name);
if(value.empty()) { if(value.empty()) {
return 0; return 0;
} else { } else {
return util::parseULLInt(value); return util::parseInt(value);
}
}
int64_t HttpHeader::findAsLLInt(const std::string& name) const
{
const std::string& value = find(name);
if(value.empty()) {
return 0;
} else {
return util::parseLLInt(value);
} }
} }
@ -129,7 +136,10 @@ RangeHandle HttpHeader::getRange() const
if(clenStr.empty()) { if(clenStr.empty()) {
return SharedHandle<Range>(new Range()); return SharedHandle<Range>(new Range());
} else { } else {
uint64_t contentLength = util::parseULLInt(clenStr); off_t contentLength = util::parseLLInt(clenStr);
if(contentLength < 0) {
throw DL_ABORT_EX("Content-Length must be positive");
}
if(contentLength == 0) { if(contentLength == 0) {
return SharedHandle<Range>(new Range()); return SharedHandle<Range>(new Range());
} else { } else {
@ -168,8 +178,11 @@ RangeHandle HttpHeader::getRange() const
} }
off_t startByte = util::parseLLInt(std::string(byteRangeSpec, minus)); off_t startByte = util::parseLLInt(std::string(byteRangeSpec, minus));
off_t endByte = util::parseLLInt(std::string(minus+1, slash)); off_t endByte = util::parseLLInt(std::string(minus+1, slash));
uint64_t entityLength = off_t entityLength =
util::parseULLInt(std::string(slash+1, rangeStr.end())); util::parseLLInt(std::string(slash+1, rangeStr.end()));
if(startByte < 0 || endByte < 0 || entityLength < 0) {
throw DL_ABORT_EX("byte-range-spec must be positive");
}
return SharedHandle<Range>(new Range(startByte, endByte, entityLength)); return SharedHandle<Range>(new Range(startByte, endByte, entityLength));
} }

View File

@ -73,8 +73,8 @@ public:
std::pair<std::multimap<std::string, std::string>::const_iterator, std::pair<std::multimap<std::string, std::string>::const_iterator,
std::multimap<std::string, std::string>::const_iterator> std::multimap<std::string, std::string>::const_iterator>
equalRange(const std::string& name) const; equalRange(const std::string& name) const;
unsigned int findAsUInt(const std::string& name) const; int32_t findAsInt(const std::string& name) const;
uint64_t findAsULLInt(const std::string& name) const; int64_t findAsLLInt(const std::string& name) const;
SharedHandle<Range> getRange() const; SharedHandle<Range> getRange() const;

View File

@ -368,7 +368,7 @@ const SharedHandle<AuthConfig>& HttpRequest::getAuthConfig() const
return authConfig_; return authConfig_;
} }
uint64_t HttpRequest::getEntityLength() const off_t HttpRequest::getEntityLength() const
{ {
assert(fileEntry_); assert(fileEntry_);
return fileEntry_->getLength(); return fileEntry_->getLength();

View File

@ -105,7 +105,7 @@ public:
void setRequest(const SharedHandle<Request>& request); void setRequest(const SharedHandle<Request>& request);
uint64_t getEntityLength() const; off_t getEntityLength() const;
const std::string& getHost() const; const std::string& getHost() const;

View File

@ -86,7 +86,7 @@ SharedHandle<HttpRequest>
createHttpRequest(const SharedHandle<Request>& req, createHttpRequest(const SharedHandle<Request>& req,
const SharedHandle<FileEntry>& fileEntry, const SharedHandle<FileEntry>& fileEntry,
const SharedHandle<Segment>& segment, const SharedHandle<Segment>& segment,
uint64_t totalLength, off_t totalLength,
const SharedHandle<Option>& option, const SharedHandle<Option>& option,
const RequestGroup* rg, const RequestGroup* rg,
const SharedHandle<CookieStorage>& cookieStorage, const SharedHandle<CookieStorage>& cookieStorage,

View File

@ -227,7 +227,7 @@ SharedHandle<StreamFilter> HttpResponse::getContentEncodingStreamFilter() const
return filter; return filter;
} }
uint64_t HttpResponse::getContentLength() const off_t HttpResponse::getContentLength() const
{ {
if(!httpHeader_) { if(!httpHeader_) {
return 0; return 0;
@ -236,7 +236,7 @@ uint64_t HttpResponse::getContentLength() const
} }
} }
uint64_t HttpResponse::getEntityLength() const off_t HttpResponse::getEntityLength() const
{ {
if(!httpHeader_) { if(!httpHeader_) {
return 0; return 0;
@ -279,7 +279,7 @@ bool HttpResponse::hasRetryAfter() const
time_t HttpResponse::getRetryAfter() const time_t HttpResponse::getRetryAfter() const
{ {
return httpHeader_->findAsUInt(HttpHeader::RETRY_AFTER); return httpHeader_->findAsInt(HttpHeader::RETRY_AFTER);
} }
Time HttpResponse::getLastModifiedTime() const Time HttpResponse::getLastModifiedTime() const

View File

@ -96,9 +96,9 @@ public:
SharedHandle<StreamFilter> getContentEncodingStreamFilter() const; SharedHandle<StreamFilter> getContentEncodingStreamFilter() const;
uint64_t getContentLength() const; off_t getContentLength() const;
uint64_t getEntityLength() const; off_t getEntityLength() const;
// Returns type "/" subtype. The parameter is removed. // Returns type "/" subtype. The parameter is removed.
std::string getContentType() const; std::string getContentType() const;

View File

@ -180,7 +180,7 @@ bool HttpResponseCommand::executeInternal()
int statusCode = httpResponse->getStatusCode(); int statusCode = httpResponse->getStatusCode();
if(statusCode == 304) { if(statusCode == 304) {
uint64_t totalLength = httpResponse->getEntityLength(); off_t totalLength = httpResponse->getEntityLength();
getFileEntry()->setLength(totalLength); getFileEntry()->setLength(totalLength);
getRequestGroup()->initPieceStorage(); getRequestGroup()->initPieceStorage();
getPieceStorage()->markAllPiecesDone(); getPieceStorage()->markAllPiecesDone();
@ -245,7 +245,7 @@ bool HttpResponseCommand::executeInternal()
} }
if(!getPieceStorage()) { if(!getPieceStorage()) {
util::removeMetalinkContentTypes(getRequestGroup()); util::removeMetalinkContentTypes(getRequestGroup());
uint64_t totalLength = httpResponse->getEntityLength(); off_t totalLength = httpResponse->getEntityLength();
getFileEntry()->setLength(totalLength); getFileEntry()->setLength(totalLength);
if(getFileEntry()->getPath().empty()) { if(getFileEntry()->getPath().empty()) {
getFileEntry()->setPath getFileEntry()->setPath

View File

@ -90,7 +90,10 @@ SharedHandle<HttpHeader> HttpServer::receiveRequest()
lastBody_.clear(); lastBody_.clear();
lastBody_.str(""); lastBody_.str("");
lastContentLength_ = lastContentLength_ =
lastRequestHeader_->findAsUInt(HttpHeader::CONTENT_LENGTH); lastRequestHeader_->findAsLLInt(HttpHeader::CONTENT_LENGTH);
if(lastContentLength_ < 0) {
throw DL_ABORT_EX("Content-Length must be positive.");
}
headerProcessor_->clear(); headerProcessor_->clear();
const std::string& connection = const std::string& connection =
@ -144,7 +147,7 @@ bool HttpServer::receiveBody()
lastBody_.write(reinterpret_cast<const char*>(socketRecvBuffer_->getBuffer()), lastBody_.write(reinterpret_cast<const char*>(socketRecvBuffer_->getBuffer()),
length); length);
socketRecvBuffer_->shiftBuffer(length); socketRecvBuffer_->shiftBuffer(length);
return lastContentLength_ == static_cast<uint64_t>(lastBody_.tellp()); return lastContentLength_ == lastBody_.tellp();
} }
std::string HttpServer::getBody() const std::string HttpServer::getBody() const

View File

@ -60,7 +60,7 @@ private:
DownloadEngine* e_; DownloadEngine* e_;
SharedHandle<HttpHeaderProcessor> headerProcessor_; SharedHandle<HttpHeaderProcessor> headerProcessor_;
SharedHandle<HttpHeader> lastRequestHeader_; SharedHandle<HttpHeader> lastRequestHeader_;
uint64_t lastContentLength_; off_t lastContentLength_;
std::stringstream lastBody_; std::stringstream lastBody_;
bool keepAlive_; bool keepAlive_;
bool gzip_; bool gzip_;
@ -118,7 +118,7 @@ public:
void disableGZip() { gzip_ = false; } void disableGZip() { gzip_ = false; }
uint64_t getContentLength() const { return lastContentLength_; } off_t getContentLength() const { return lastContentLength_; }
const SharedHandle<SocketRecvBuffer>& getSocketRecvBuffer() const const SharedHandle<SocketRecvBuffer>& getSocketRecvBuffer() const
{ {

View File

@ -133,8 +133,7 @@ bool HttpServerCommand::execute()
e_->setNoWait(true); e_->setNoWait(true);
return true; return true;
} }
if(static_cast<uint64_t> if(e_->getOption()->getAsInt(PREF_RPC_MAX_REQUEST_SIZE) <
(e_->getOption()->getAsInt(PREF_RPC_MAX_REQUEST_SIZE)) <
httpServer_->getContentLength()) { httpServer_->getContentLength()) {
A2_LOG_INFO A2_LOG_INFO
(fmt("Request too long. ContentLength=%lld." (fmt("Request too long. ContentLength=%lld."

View File

@ -127,7 +127,7 @@ bool HttpSkipResponseCommand::executeInternal()
if(totalLength_ > 0) { if(totalLength_ > 0) {
bufSize = std::min bufSize = std::min
(totalLength_-receivedBytes_, (totalLength_-receivedBytes_,
static_cast<uint64_t>(getSocketRecvBuffer()->getBufferLength())); static_cast<off_t>(getSocketRecvBuffer()->getBufferLength()));
} else { } else {
bufSize = getSocketRecvBuffer()->getBufferLength(); bufSize = getSocketRecvBuffer()->getBufferLength();
} }

View File

@ -53,9 +53,9 @@ private:
bool sinkFilterOnly_; bool sinkFilterOnly_;
uint64_t totalLength_; off_t totalLength_;
uint64_t receivedBytes_; off_t receivedBytes_;
bool processResponse(); bool processResponse();

View File

@ -84,14 +84,14 @@ void IteratableChecksumValidator::validateChunk()
bool IteratableChecksumValidator::finished() const bool IteratableChecksumValidator::finished() const
{ {
if((uint64_t)currentOffset_ >= dctx_->getTotalLength()) { if(currentOffset_ >= dctx_->getTotalLength()) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
uint64_t IteratableChecksumValidator::getTotalLength() const off_t IteratableChecksumValidator::getTotalLength() const
{ {
return dctx_->getTotalLength(); return dctx_->getTotalLength();
} }

View File

@ -70,7 +70,7 @@ public:
return currentOffset_; return currentOffset_;
} }
virtual uint64_t getTotalLength() const; virtual off_t getTotalLength() const;
}; };
typedef SharedHandle<IteratableChecksumValidator> IteratableChecksumValidatorHandle; typedef SharedHandle<IteratableChecksumValidator> IteratableChecksumValidatorHandle;

View File

@ -149,10 +149,10 @@ bool IteratableChunkChecksumValidator::finished() const
off_t IteratableChunkChecksumValidator::getCurrentOffset() const off_t IteratableChunkChecksumValidator::getCurrentOffset() const
{ {
return (off_t)currentIndex_*dctx_->getPieceLength(); return static_cast<off_t>(currentIndex_)*dctx_->getPieceLength();
} }
uint64_t IteratableChunkChecksumValidator::getTotalLength() const off_t IteratableChunkChecksumValidator::getTotalLength() const
{ {
return dctx_->getTotalLength(); return dctx_->getTotalLength();
} }

View File

@ -73,7 +73,7 @@ public:
virtual off_t getCurrentOffset() const; virtual off_t getCurrentOffset() const;
virtual uint64_t getTotalLength() const; virtual off_t getTotalLength() const;
}; };
typedef SharedHandle<IteratableChunkChecksumValidator> IteratableChunkChecksumValidatorHandle; typedef SharedHandle<IteratableChunkChecksumValidator> IteratableChunkChecksumValidatorHandle;

View File

@ -62,7 +62,7 @@ public:
virtual off_t getCurrentOffset() const = 0; virtual off_t getCurrentOffset() const = 0;
virtual uint64_t getTotalLength() const = 0; virtual off_t getTotalLength() const = 0;
}; };
typedef SharedHandle<IteratableValidator> IteratableValidatorHandle; typedef SharedHandle<IteratableValidator> IteratableValidatorHandle;

View File

@ -97,7 +97,7 @@ SharedHandle<LpdMessage> LpdMessageReceiver::receiveMessage()
static const std::string A2_INFOHASH = "infohash"; static const std::string A2_INFOHASH = "infohash";
static const std::string A2_PORT = "port"; static const std::string A2_PORT = "port";
const std::string& infoHashString = header->find(A2_INFOHASH); const std::string& infoHashString = header->find(A2_INFOHASH);
uint16_t port = header->findAsUInt(A2_PORT); uint16_t port = header->findAsInt(A2_PORT);
A2_LOG_INFO(fmt("LPD message received infohash=%s, port=%u from %s", A2_LOG_INFO(fmt("LPD message received infohash=%s, port=%u from %s",
infoHashString.c_str(), infoHashString.c_str(),
port, port,

View File

@ -101,7 +101,7 @@ const std::string& MetalinkEntry::getPath() const
return file->getPath(); return file->getPath();
} }
uint64_t MetalinkEntry::getLength() const off_t MetalinkEntry::getLength() const
{ {
return file->getLength(); return file->getLength();
} }

View File

@ -79,7 +79,7 @@ public:
const std::string& getPath() const; const std::string& getPath() const;
uint64_t getLength() const; off_t getLength() const;
const SharedHandle<FileEntry>& getFile() const const SharedHandle<FileEntry>& getFile() const
{ {

View File

@ -87,7 +87,7 @@ void MetalinkParserController::setFileNameOfEntry(const std::string& filename)
} }
} }
void MetalinkParserController::setFileLengthOfEntry(uint64_t length) void MetalinkParserController::setFileLengthOfEntry(off_t length)
{ {
if(!tEntry_) { if(!tEntry_) {
return; return;

View File

@ -96,7 +96,7 @@ public:
void setFileNameOfEntry(const std::string& filename); void setFileNameOfEntry(const std::string& filename);
void setFileLengthOfEntry(uint64_t length); void setFileLengthOfEntry(off_t length);
void setVersionOfEntry(const std::string& version); void setVersionOfEntry(const std::string& version);

View File

@ -262,7 +262,7 @@ void MetalinkParserStateMachine::setFileNameOfEntry(const std::string& filename)
ctrl_->setFileNameOfEntry(filename); ctrl_->setFileNameOfEntry(filename);
} }
void MetalinkParserStateMachine::setFileLengthOfEntry(uint64_t length) void MetalinkParserStateMachine::setFileLengthOfEntry(off_t length)
{ {
ctrl_->setFileLengthOfEntry(length); ctrl_->setFileLengthOfEntry(length);
} }

View File

@ -159,7 +159,7 @@ public:
void setFileNameOfEntry(const std::string& filename); void setFileNameOfEntry(const std::string& filename);
void setFileLengthOfEntry(uint64_t length); void setFileLengthOfEntry(off_t length);
void setVersionOfEntry(const std::string& version); void setVersionOfEntry(const std::string& version);

View File

@ -148,8 +148,8 @@ void SizeMetalinkParserState::endElement
const std::string& characters) const std::string& characters)
{ {
// current metalink specification doesn't require size element. // current metalink specification doesn't require size element.
uint64_t size; off_t size;
if(util::parseULLIntNoThrow(size, characters)) { if(util::parseLLIntNoThrow(size, characters) && size >= 0) {
psm->setFileLengthOfEntry(size); psm->setFileLengthOfEntry(size);
} }
} }

View File

@ -253,8 +253,8 @@ void SizeMetalinkParserStateV4::endElement
const char* nsUri, const char* nsUri,
const std::string& characters) const std::string& characters)
{ {
uint64_t size; off_t size;
if(util::parseULLIntNoThrow(size, characters)) { if(util::parseLLIntNoThrow(size, characters) && size >= 0) {
psm->setFileLengthOfEntry(size); psm->setFileLengthOfEntry(size);
} else { } else {
psm->cancelEntryTransaction(); psm->cancelEntryTransaction();

View File

@ -101,7 +101,7 @@ bool DiskWriterEntry::fileExists()
return fileEntry_->exists(); return fileEntry_->exists();
} }
uint64_t DiskWriterEntry::size() const off_t DiskWriterEntry::size() const
{ {
return File(getFilePath()).size(); return File(getFilePath()).size();
} }
@ -169,8 +169,7 @@ void MultiDiskAdaptor::resetDiskWriterEntries()
itr-1; true; --i) { itr-1; true; --i) {
const SharedHandle<FileEntry>& fileEntry = (*i)->getFileEntry(); const SharedHandle<FileEntry>& fileEntry = (*i)->getFileEntry();
if(pieceStartOffset <= fileEntry->getOffset() || if(pieceStartOffset <= fileEntry->getOffset() ||
(uint64_t)pieceStartOffset < pieceStartOffset < fileEntry->getLastOffset()) {
fileEntry->getOffset()+fileEntry->getLength()) {
(*i)->needsFileAllocation(true); (*i)->needsFileAllocation(true);
} else { } else {
break; break;
@ -306,22 +305,19 @@ namespace {
bool isInRange(const DiskWriterEntryHandle entry, off_t offset) bool isInRange(const DiskWriterEntryHandle entry, off_t offset)
{ {
return entry->getFileEntry()->getOffset() <= offset && return entry->getFileEntry()->getOffset() <= offset &&
(uint64_t)offset < offset < entry->getFileEntry()->getLastOffset();
entry->getFileEntry()->getOffset()+entry->getFileEntry()->getLength();
} }
} // namespace } // namespace
namespace { namespace {
size_t calculateLength(const DiskWriterEntryHandle entry, ssize_t calculateLength(const DiskWriterEntryHandle entry,
off_t fileOffset, size_t rem) off_t fileOffset, ssize_t rem)
{ {
size_t length; if(entry->getFileEntry()->getLength() < fileOffset+rem) {
if(entry->getFileEntry()->getLength() < (uint64_t)fileOffset+rem) { return entry->getFileEntry()->getLength()-fileOffset;
length = entry->getFileEntry()->getLength()-fileOffset;
} else { } else {
length = rem; return rem;
} }
return length;
} }
} // namespace } // namespace
@ -371,11 +367,11 @@ void MultiDiskAdaptor::writeData(const unsigned char* data, size_t len,
DiskWriterEntries::const_iterator first = DiskWriterEntries::const_iterator first =
findFirstDiskWriterEntry(diskWriterEntries_, offset); findFirstDiskWriterEntry(diskWriterEntries_, offset);
size_t rem = len; ssize_t rem = len;
off_t fileOffset = offset-(*first)->getFileEntry()->getOffset(); off_t fileOffset = offset-(*first)->getFileEntry()->getOffset();
for(DiskWriterEntries::const_iterator i = first, for(DiskWriterEntries::const_iterator i = first,
eoi = diskWriterEntries_.end(); i != eoi; ++i) { eoi = diskWriterEntries_.end(); i != eoi; ++i) {
size_t writeLength = calculateLength(*i, fileOffset, rem); ssize_t writeLength = calculateLength(*i, fileOffset, rem);
openIfNot(*i, &DiskWriterEntry::openFile); openIfNot(*i, &DiskWriterEntry::openFile);
@ -398,12 +394,12 @@ ssize_t MultiDiskAdaptor::readData
DiskWriterEntries::const_iterator first = DiskWriterEntries::const_iterator first =
findFirstDiskWriterEntry(diskWriterEntries_, offset); findFirstDiskWriterEntry(diskWriterEntries_, offset);
size_t rem = len; ssize_t rem = len;
size_t totalReadLength = 0; ssize_t totalReadLength = 0;
off_t fileOffset = offset-(*first)->getFileEntry()->getOffset(); off_t fileOffset = offset-(*first)->getFileEntry()->getOffset();
for(DiskWriterEntries::const_iterator i = first, for(DiskWriterEntries::const_iterator i = first,
eoi = diskWriterEntries_.end(); i != eoi; ++i) { eoi = diskWriterEntries_.end(); i != eoi; ++i) {
size_t readLength = calculateLength(*i, fileOffset, rem); ssize_t readLength = calculateLength(*i, fileOffset, rem);
openIfNot(*i, &DiskWriterEntry::openFile); openIfNot(*i, &DiskWriterEntry::openFile);
@ -429,9 +425,9 @@ bool MultiDiskAdaptor::fileExists()
getFileEntries().end(); getFileEntries().end();
} }
uint64_t MultiDiskAdaptor::size() off_t MultiDiskAdaptor::size()
{ {
uint64_t size = 0; off_t size = 0;
for(std::vector<SharedHandle<FileEntry> >::const_iterator i = for(std::vector<SharedHandle<FileEntry> >::const_iterator i =
getFileEntries().begin(), eoi = getFileEntries().end(); i != eoi; ++i) { getFileEntries().begin(), eoi = getFileEntries().end(); i != eoi; ++i) {
size += File((*i)->getPath()).size(); size += File((*i)->getPath()).size();
@ -460,9 +456,9 @@ void MultiDiskAdaptor::cutTrailingGarbage()
for(std::vector<SharedHandle<DiskWriterEntry> >::const_iterator i = for(std::vector<SharedHandle<DiskWriterEntry> >::const_iterator i =
diskWriterEntries_.begin(), eoi = diskWriterEntries_.end(); diskWriterEntries_.begin(), eoi = diskWriterEntries_.end();
i != eoi; ++i) { i != eoi; ++i) {
uint64_t length = (*i)->getFileEntry()->getLength(); off_t length = (*i)->getFileEntry()->getLength();
if(File((*i)->getFilePath()).size() > length) { if(File((*i)->getFilePath()).size() > length) {
// We need open file before calling DiskWriter::truncate(uint64_t) // We need open file before calling DiskWriter::truncate(off_t)
openIfNot(*i, &DiskWriterEntry::openFile); openIfNot(*i, &DiskWriterEntry::openFile);
(*i)->getDiskWriter()->truncate(length); (*i)->getDiskWriter()->truncate(length);
} }

View File

@ -69,7 +69,7 @@ public:
bool fileExists(); bool fileExists();
uint64_t size() const; off_t size() const;
const SharedHandle<FileEntry>& getFileEntry() const const SharedHandle<FileEntry>& getFileEntry() const
{ {
@ -139,7 +139,7 @@ public:
virtual bool fileExists(); virtual bool fileExists();
virtual uint64_t size(); virtual off_t size();
virtual SharedHandle<FileAllocationIterator> fileAllocationIterator(); virtual SharedHandle<FileAllocationIterator> fileAllocationIterator();

View File

@ -104,7 +104,7 @@ off_t MultiFileAllocationIterator::getCurrentLength()
} }
} }
uint64_t MultiFileAllocationIterator::getTotalLength() off_t MultiFileAllocationIterator::getTotalLength()
{ {
if(!fileAllocationIterator_) { if(!fileAllocationIterator_) {
return 0; return 0;

View File

@ -61,7 +61,7 @@ public:
virtual off_t getCurrentLength(); virtual off_t getCurrentLength();
virtual uint64_t getTotalLength(); virtual off_t getTotalLength();
const std::deque<SharedHandle<DiskWriterEntry> >& const std::deque<SharedHandle<DiskWriterEntry> >&
getDiskWriterEntries() const; getDiskWriterEntries() const;

View File

@ -73,7 +73,7 @@ void Peer::usedBy(cuid_t cuid)
cuid_ = cuid; cuid_ = cuid;
} }
void Peer::allocateSessionResource(size_t pieceLength, uint64_t totalLength) void Peer::allocateSessionResource(size_t pieceLength, off_t totalLength)
{ {
delete res_; delete res_;
res_ = new PeerSessionResource(pieceLength, totalLength); res_ = new PeerSessionResource(pieceLength, totalLength);
@ -81,7 +81,7 @@ void Peer::allocateSessionResource(size_t pieceLength, uint64_t totalLength)
updateSeeder(); updateSeeder();
} }
void Peer::reconfigureSessionResource(size_t pieceLength, uint64_t totalLength) void Peer::reconfigureSessionResource(size_t pieceLength, off_t totalLength)
{ {
assert(res_); assert(res_);
res_->reconfigure(pieceLength, totalLength); res_->reconfigure(pieceLength, totalLength);
@ -228,13 +228,13 @@ unsigned int Peer::calculateDownloadSpeed()
return res_->getPeerStat().calculateDownloadSpeed(); return res_->getPeerStat().calculateDownloadSpeed();
} }
uint64_t Peer::getSessionUploadLength() const off_t Peer::getSessionUploadLength() const
{ {
assert(res_); assert(res_);
return res_->uploadLength(); return res_->uploadLength();
} }
uint64_t Peer::getSessionDownloadLength() const off_t Peer::getSessionDownloadLength() const
{ {
assert(res_); assert(res_);
return res_->downloadLength(); return res_->downloadLength();
@ -388,7 +388,7 @@ const Timer& Peer::getLastAmUnchoking() const
return res_->getLastAmUnchoking(); return res_->getLastAmUnchoking();
} }
uint64_t Peer::getCompletedLength() const off_t Peer::getCompletedLength() const
{ {
assert(res_); assert(res_);
return res_->getCompletedLength(); return res_->getCompletedLength();

View File

@ -160,9 +160,9 @@ public:
bool isGood() const; bool isGood() const;
void allocateSessionResource(size_t pieceLength, uint64_t totalLength); void allocateSessionResource(size_t pieceLength, off_t totalLength);
void reconfigureSessionResource(size_t pieceLength, uint64_t totalLength); void reconfigureSessionResource(size_t pieceLength, off_t totalLength);
void releaseSessionResource(); void releaseSessionResource();
@ -234,12 +234,12 @@ public:
/** /**
* Returns the number of bytes uploaded to the remote host. * Returns the number of bytes uploaded to the remote host.
*/ */
uint64_t getSessionUploadLength() const; off_t getSessionUploadLength() const;
/** /**
* Returns the number of bytes downloaded from the remote host. * Returns the number of bytes downloaded from the remote host.
*/ */
uint64_t getSessionDownloadLength() const; off_t getSessionDownloadLength() const;
void setBitfield(const unsigned char* bitfield, size_t bitfieldLength); void setBitfield(const unsigned char* bitfield, size_t bitfieldLength);
@ -293,7 +293,7 @@ public:
const Timer& getLastAmUnchoking() const; const Timer& getLastAmUnchoking() const;
uint64_t getCompletedLength() const; off_t getCompletedLength() const;
bool isIncomingPeer() const bool isIncomingPeer() const
{ {

View File

@ -44,7 +44,7 @@
namespace aria2 { namespace aria2 {
PeerSessionResource::PeerSessionResource(size_t pieceLength, uint64_t totalLength): PeerSessionResource::PeerSessionResource(size_t pieceLength, off_t totalLength):
amChoking_(true), amChoking_(true),
amInterested_(false), amInterested_(false),
peerChoking_(true), peerChoking_(true),
@ -237,7 +237,7 @@ void PeerSessionResource::dhtEnabled(bool b)
dhtEnabled_ = b; dhtEnabled_ = b;
} }
uint64_t PeerSessionResource::uploadLength() const off_t PeerSessionResource::uploadLength() const
{ {
return peerStat_.getSessionUploadLength(); return peerStat_.getSessionUploadLength();
} }
@ -247,7 +247,7 @@ void PeerSessionResource::updateUploadLength(size_t bytes)
peerStat_.updateUploadLength(bytes); peerStat_.updateUploadLength(bytes);
} }
uint64_t PeerSessionResource::downloadLength() const off_t PeerSessionResource::downloadLength() const
{ {
return peerStat_.getSessionDownloadLength(); return peerStat_.getSessionDownloadLength();
} }
@ -259,7 +259,7 @@ void PeerSessionResource::updateDownloadLength(size_t bytes)
lastDownloadUpdate_ = global::wallclock(); lastDownloadUpdate_ = global::wallclock();
} }
uint64_t PeerSessionResource::getCompletedLength() const off_t PeerSessionResource::getCompletedLength() const
{ {
return bitfieldMan_->getCompletedLength(); return bitfieldMan_->getCompletedLength();
} }
@ -275,7 +275,7 @@ size_t PeerSessionResource::countOutstandingUpload() const
return dispatcher_->countOutstandingUpload(); return dispatcher_->countOutstandingUpload();
} }
void PeerSessionResource::reconfigure(size_t pieceLength, uint64_t totalLenth) void PeerSessionResource::reconfigure(size_t pieceLength, off_t totalLenth)
{ {
delete bitfieldMan_; delete bitfieldMan_;
bitfieldMan_ = new BitfieldMan(pieceLength, totalLenth); bitfieldMan_ = new BitfieldMan(pieceLength, totalLenth);

View File

@ -83,7 +83,7 @@ private:
BtMessageDispatcher* dispatcher_; BtMessageDispatcher* dispatcher_;
public: public:
PeerSessionResource(size_t pieceLength, uint64_t totalLength); PeerSessionResource(size_t pieceLength, off_t totalLength);
~PeerSessionResource(); ~PeerSessionResource();
@ -155,7 +155,7 @@ public:
size_t getBitfieldLength() const; size_t getBitfieldLength() const;
void reconfigure(size_t index, uint64_t totalLength); void reconfigure(size_t index, off_t totalLength);
bool hasPiece(size_t index) const; bool hasPiece(size_t index) const;
@ -210,11 +210,11 @@ public:
return peerStat_; return peerStat_;
} }
uint64_t uploadLength() const; off_t uploadLength() const;
void updateUploadLength(size_t bytes); void updateUploadLength(size_t bytes);
uint64_t downloadLength() const; off_t downloadLength() const;
void updateDownloadLength(size_t bytes); void updateDownloadLength(size_t bytes);
@ -228,7 +228,7 @@ public:
return lastAmUnchoking_; return lastAmUnchoking_;
} }
uint64_t getCompletedLength() const; off_t getCompletedLength() const;
void setBtMessageDispatcher(BtMessageDispatcher* dpt); void setBtMessageDispatcher(BtMessageDispatcher* dpt);

View File

@ -61,8 +61,8 @@ private:
PeerStat::STATUS status_; PeerStat::STATUS status_;
unsigned int avgDownloadSpeed_; unsigned int avgDownloadSpeed_;
unsigned int avgUploadSpeed_; unsigned int avgUploadSpeed_;
uint64_t sessionDownloadLength_; int64_t sessionDownloadLength_;
uint64_t sessionUploadLength_; int64_t sessionUploadLength_;
public: public:
PeerStat PeerStat
(cuid_t cuid, const std::string& hostname, const::std::string& protocol); (cuid_t cuid, const std::string& hostname, const::std::string& protocol);

View File

@ -179,13 +179,13 @@ public:
virtual bool isPieceUsed(size_t index) = 0; virtual bool isPieceUsed(size_t index) = 0;
virtual uint64_t getTotalLength() = 0; virtual off_t getTotalLength() = 0;
virtual uint64_t getFilteredTotalLength() = 0; virtual off_t getFilteredTotalLength() = 0;
virtual uint64_t getCompletedLength() = 0; virtual off_t getCompletedLength() = 0;
virtual uint64_t getFilteredCompletedLength() = 0; virtual off_t getFilteredCompletedLength() = 0;
virtual void setupFileFilter() = 0; virtual void setupFileFilter() = 0;
@ -258,7 +258,7 @@ public:
/** /**
* Sets all bits in bitfield(0 to length) to 1. * Sets all bits in bitfield(0 to length) to 1.
*/ */
virtual void markPiecesDone(uint64_t length) = 0; virtual void markPiecesDone(off_t length) = 0;
virtual void virtual void
addInFlightPiece(const std::vector<SharedHandle<Piece> >& pieces) = 0; addInFlightPiece(const std::vector<SharedHandle<Piece> >& pieces) = 0;

View File

@ -50,7 +50,7 @@ public:
virtual off_t getCurrentLength() = 0; virtual off_t getCurrentLength() = 0;
virtual uint64_t getTotalLength() = 0; virtual off_t getTotalLength() = 0;
virtual bool finished() = 0; virtual bool finished() = 0;
}; };

View File

@ -38,7 +38,7 @@ namespace aria2 {
Range::Range():startByte_(0), endByte_(0), entityLength_(0) {} Range::Range():startByte_(0), endByte_(0), entityLength_(0) {}
Range::Range(off_t startByte, off_t endByte, uint64_t entityLength) Range::Range(off_t startByte, off_t endByte, off_t entityLength)
: startByte_(startByte), endByte_(endByte), entityLength_(entityLength) : startByte_(startByte), endByte_(endByte), entityLength_(entityLength)
{} {}
@ -72,7 +72,7 @@ bool Range::operator!=(const Range& range) const
return !(*this == range); return !(*this == range);
} }
uint64_t Range::getContentLength() const off_t Range::getContentLength() const
{ {
if(endByte_ >= startByte_) { if(endByte_ >= startByte_) {
return endByte_-startByte_+1; return endByte_-startByte_+1;

View File

@ -47,11 +47,11 @@ class Range {
private: private:
off_t startByte_; off_t startByte_;
off_t endByte_; off_t endByte_;
uint64_t entityLength_; off_t entityLength_;
public: public:
Range(); Range();
Range(off_t startByte, off_t endByte, uint64_t entityLength); Range(off_t startByte, off_t endByte, off_t entityLength);
Range(const Range& c); Range(const Range& c);
@ -73,12 +73,12 @@ public:
return endByte_; return endByte_;
} }
uint64_t getEntityLength() const off_t getEntityLength() const
{ {
return entityLength_; return entityLength_;
} }
uint64_t getContentLength() const; off_t getContentLength() const;
}; };
typedef SharedHandle<Range> RangeHandle; typedef SharedHandle<Range> RangeHandle;

View File

@ -390,7 +390,7 @@ void RequestGroup::createInitialCommand
} }
removeDefunctControlFile(progressInfoFile); removeDefunctControlFile(progressInfoFile);
{ {
uint64_t actualFileSize = pieceStorage_->getDiskAdaptor()->size(); off_t actualFileSize = pieceStorage_->getDiskAdaptor()->size();
if(actualFileSize == downloadContext_->getTotalLength()) { if(actualFileSize == downloadContext_->getTotalLength()) {
// First, make DiskAdaptor read-only mode to allow the // First, make DiskAdaptor read-only mode to allow the
// program to seed file in read-only media. // program to seed file in read-only media.
@ -555,7 +555,7 @@ void RequestGroup::processCheckIntegrityEntry
const SharedHandle<CheckIntegrityEntry>& entry, const SharedHandle<CheckIntegrityEntry>& entry,
DownloadEngine* e) DownloadEngine* e)
{ {
uint64_t actualFileSize = pieceStorage_->getDiskAdaptor()->size(); off_t actualFileSize = pieceStorage_->getDiskAdaptor()->size();
if(actualFileSize > downloadContext_->getTotalLength()) { if(actualFileSize > downloadContext_->getTotalLength()) {
entry->cutTrailingGarbage(); entry->cutTrailingGarbage();
} }
@ -863,7 +863,7 @@ std::string RequestGroup::getFirstFilePath() const
} }
} }
uint64_t RequestGroup::getTotalLength() const off_t RequestGroup::getTotalLength() const
{ {
if(!pieceStorage_) { if(!pieceStorage_) {
return 0; return 0;
@ -876,7 +876,7 @@ uint64_t RequestGroup::getTotalLength() const
} }
} }
uint64_t RequestGroup::getCompletedLength() const off_t RequestGroup::getCompletedLength() const
{ {
if(!pieceStorage_) { if(!pieceStorage_) {
return 0; return 0;
@ -902,8 +902,8 @@ void RequestGroup::validateFilename(const std::string& expectedFilename,
} }
} }
void RequestGroup::validateTotalLength(uint64_t expectedTotalLength, void RequestGroup::validateTotalLength(off_t expectedTotalLength,
uint64_t actualTotalLength) const off_t actualTotalLength) const
{ {
if(expectedTotalLength <= 0) { if(expectedTotalLength <= 0) {
return; return;
@ -921,7 +921,7 @@ void RequestGroup::validateFilename(const std::string& actualFilename) const
validateFilename(downloadContext_->getFileEntries().front()->getBasename(), actualFilename); validateFilename(downloadContext_->getFileEntries().front()->getBasename(), actualFilename);
} }
void RequestGroup::validateTotalLength(uint64_t actualTotalLength) const void RequestGroup::validateTotalLength(off_t actualTotalLength) const
{ {
validateTotalLength(getTotalLength(), actualTotalLength); validateTotalLength(getTotalLength(), actualTotalLength);
} }
@ -1155,7 +1155,7 @@ void RequestGroup::setProgressInfoFile(const BtProgressInfoFileHandle& progressI
bool RequestGroup::needsFileAllocation() const bool RequestGroup::needsFileAllocation() const
{ {
return isFileAllocationEnabled() && return isFileAllocationEnabled() &&
(uint64_t)option_->getAsLLInt(PREF_NO_FILE_ALLOCATION_LIMIT) <= getTotalLength() && option_->getAsLLInt(PREF_NO_FILE_ALLOCATION_LIMIT) <= getTotalLength() &&
!pieceStorage_->getDiskAdaptor()->fileAllocationIterator()->finished(); !pieceStorage_->getDiskAdaptor()->fileAllocationIterator()->finished();
} }
@ -1204,7 +1204,7 @@ void RequestGroup::reportDownloadFinished()
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) { if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
TransferStat stat = calculateStat(); TransferStat stat = calculateStat();
uint64_t completedLength = getCompletedLength(); off_t completedLength = getCompletedLength();
double shareRatio = completedLength == 0 ? 0.0 : double shareRatio = completedLength == 0 ? 0.0 :
1.0*stat.getAllTimeUploadLength()/completedLength; 1.0*stat.getAllTimeUploadLength()/completedLength;
SharedHandle<TorrentAttribute> attrs = SharedHandle<TorrentAttribute> attrs =

View File

@ -230,9 +230,9 @@ public:
std::string getFirstFilePath() const; std::string getFirstFilePath() const;
uint64_t getTotalLength() const; off_t getTotalLength() const;
uint64_t getCompletedLength() const; off_t getCompletedLength() const;
/** /**
* Compares expected filename with specified actualFilename. * Compares expected filename with specified actualFilename.
@ -241,10 +241,10 @@ public:
*/ */
void validateFilename(const std::string& actualFilename) const; void validateFilename(const std::string& actualFilename) const;
void validateTotalLength(uint64_t expectedTotalLength, void validateTotalLength(off_t expectedTotalLength,
uint64_t actualTotalLength) const; off_t actualTotalLength) const;
void validateTotalLength(uint64_t actualTotalLength) const; void validateTotalLength(off_t actualTotalLength) const;
void setNumConcurrentCommand(unsigned int num) void setNumConcurrentCommand(unsigned int num)
{ {

View File

@ -711,7 +711,7 @@ void RequestGroupMan::formatDownloadResultFull
if((*i)->getLength() == 0 || downloadResult->bitfield.empty()) { if((*i)->getLength() == 0 || downloadResult->bitfield.empty()) {
o << " -|"; o << " -|";
} else { } else {
uint64_t completedLength = off_t completedLength =
bt.getOffsetCompletedLength((*i)->getOffset(), (*i)->getLength()); bt.getOffsetCompletedLength((*i)->getOffset(), (*i)->getLength());
o << std::setw(3) << 100*completedLength/(*i)->getLength() << "|"; o << std::setw(3) << 100*completedLength/(*i)->getLength() << "|";
} }

View File

@ -585,9 +585,9 @@ void createFileEntry
entry->put(KEY_PATH, (*first)->getPath()); entry->put(KEY_PATH, (*first)->getPath());
entry->put(KEY_SELECTED, (*first)->isRequested()?VLB_TRUE:VLB_FALSE); entry->put(KEY_SELECTED, (*first)->isRequested()?VLB_TRUE:VLB_FALSE);
entry->put(KEY_LENGTH, util::uitos((*first)->getLength())); entry->put(KEY_LENGTH, util::uitos((*first)->getLength()));
uint64_t completedLength = bf->getOffsetCompletedLength off_t completedLength = bf->getOffsetCompletedLength
((*first)->getOffset(), (*first)->getLength()); ((*first)->getOffset(), (*first)->getLength());
entry->put(KEY_COMPLETED_LENGTH, util::uitos(completedLength)); entry->put(KEY_COMPLETED_LENGTH, util::itos(completedLength));
SharedHandle<List> uriList = List::g(); SharedHandle<List> uriList = List::g();
createUriEntry(uriList, *first); createUriEntry(uriList, *first);
@ -602,7 +602,7 @@ template<typename InputIterator>
void createFileEntry void createFileEntry
(const SharedHandle<List>& files, (const SharedHandle<List>& files,
InputIterator first, InputIterator last, InputIterator first, InputIterator last,
uint64_t totalLength, off_t totalLength,
size_t pieceLength, size_t pieceLength,
const std::string& bitfield) const std::string& bitfield)
{ {
@ -618,7 +618,7 @@ template<typename InputIterator>
void createFileEntry void createFileEntry
(const SharedHandle<List>& files, (const SharedHandle<List>& files,
InputIterator first, InputIterator last, InputIterator first, InputIterator last,
uint64_t totalLength, off_t totalLength,
size_t pieceLength, size_t pieceLength,
const SharedHandle<PieceStorage>& ps) const SharedHandle<PieceStorage>& ps)
{ {

View File

@ -94,7 +94,7 @@ void SegmentMan::init()
// PieceStorage here? // PieceStorage here?
} }
uint64_t SegmentMan::getTotalLength() const off_t SegmentMan::getTotalLength() const
{ {
if(!pieceStorage_) { if(!pieceStorage_) {
return 0; return 0;
@ -342,7 +342,7 @@ bool SegmentMan::hasSegment(size_t index) const {
return pieceStorage_->hasPiece(index); return pieceStorage_->hasPiece(index);
} }
uint64_t SegmentMan::getDownloadLength() const { off_t SegmentMan::getDownloadLength() const {
if(!pieceStorage_) { if(!pieceStorage_) {
return 0; return 0;
} else { } else {
@ -444,14 +444,14 @@ void SegmentMan::updateDownloadSpeedFor(const SharedHandle<PeerStat>& pstat)
namespace { namespace {
class PeerStatDownloadLengthOperator { class PeerStatDownloadLengthOperator {
public: public:
uint64_t operator()(uint64_t total, const SharedHandle<PeerStat>& ps) off_t operator()(off_t total, const SharedHandle<PeerStat>& ps)
{ {
return ps->getSessionDownloadLength()+total; return ps->getSessionDownloadLength()+total;
} }
}; };
} // namespace } // namespace
uint64_t SegmentMan::calculateSessionDownloadLength() const off_t SegmentMan::calculateSessionDownloadLength() const
{ {
return std::accumulate(fastestPeerStats_.begin(), fastestPeerStats_.end(), return std::accumulate(fastestPeerStats_.begin(), fastestPeerStats_.end(),
0LL, PeerStatDownloadLengthOperator()); 0LL, PeerStatDownloadLengthOperator());

View File

@ -124,7 +124,7 @@ public:
* If Transfer-Encoding is Chunked or Content-Length header is not provided, * If Transfer-Encoding is Chunked or Content-Length header is not provided,
* then this value is set to be 0. * then this value is set to be 0.
*/ */
uint64_t getTotalLength() const; off_t getTotalLength() const;
/** /**
* Returs true when the download has finished. * Returs true when the download has finished.
@ -202,7 +202,7 @@ public:
/** /**
* Returns the length of bytes downloaded. * Returns the length of bytes downloaded.
*/ */
uint64_t getDownloadLength() const; off_t getDownloadLength() const;
// If there is inactive PeerStat in peerStats_, it is replaced with // If there is inactive PeerStat in peerStats_, it is replaced with
@ -238,7 +238,7 @@ public:
/** /**
* Returns the downloaded bytes in this session. * Returns the downloaded bytes in this session.
*/ */
uint64_t calculateSessionDownloadLength() const; off_t calculateSessionDownloadLength() const;
size_t countFreePieceFrom(size_t index) const; size_t countFreePieceFrom(size_t index) const;

View File

@ -51,7 +51,7 @@ void ShareRatioSeedCriteria::reset() {}
bool ShareRatioSeedCriteria::evaluate() bool ShareRatioSeedCriteria::evaluate()
{ {
uint64_t completedLength = pieceStorage_->getCompletedLength(); off_t completedLength = pieceStorage_->getCompletedLength();
if(completedLength == 0) { if(completedLength == 0) {
return true; return true;
} }

View File

@ -51,7 +51,7 @@ namespace aria2 {
SingleFileAllocationIterator::SingleFileAllocationIterator SingleFileAllocationIterator::SingleFileAllocationIterator
(BinaryStream* stream, (BinaryStream* stream,
off_t offset, off_t offset,
uint64_t totalLength) off_t totalLength)
: stream_(stream), : stream_(stream),
offset_(offset), offset_(offset),
totalLength_(totalLength), totalLength_(totalLength),
@ -90,7 +90,7 @@ void SingleFileAllocationIterator::allocateChunk()
stream_->writeData(buffer_, BUFSIZE, offset_); stream_->writeData(buffer_, BUFSIZE, offset_);
offset_ += BUFSIZE; offset_ += BUFSIZE;
if(totalLength_ < (uint64_t)offset_) { if(totalLength_ < offset_) {
stream_->truncate(totalLength_); stream_->truncate(totalLength_);
offset_ = totalLength_; offset_ = totalLength_;
} }
@ -98,7 +98,7 @@ void SingleFileAllocationIterator::allocateChunk()
bool SingleFileAllocationIterator::finished() bool SingleFileAllocationIterator::finished()
{ {
return (uint64_t)offset_ == totalLength_; return offset_ == totalLength_;
} }
} // namespace aria2 } // namespace aria2

View File

@ -48,11 +48,14 @@ private:
off_t offset_; off_t offset_;
uint64_t totalLength_; off_t totalLength_;
unsigned char* buffer_; unsigned char* buffer_;
public: public:
SingleFileAllocationIterator(BinaryStream* stream, off_t offset, uint64_t totalLength); SingleFileAllocationIterator
(BinaryStream* stream,
off_t offset,
off_t totalLength);
virtual ~SingleFileAllocationIterator(); virtual ~SingleFileAllocationIterator();
@ -65,7 +68,7 @@ public:
return offset_; return offset_;
} }
virtual uint64_t getTotalLength() virtual off_t getTotalLength()
{ {
return totalLength_; return totalLength_;
} }

View File

@ -79,7 +79,7 @@ unsigned int SpeedCalc::calculateSpeed() {
void SpeedCalc::update(size_t bytes) { void SpeedCalc::update(size_t bytes) {
accumulatedLength_ += bytes; accumulatedLength_ += bytes;
std::transform(&lengthArray_[0], &lengthArray_[2], &lengthArray_[0], std::transform(&lengthArray_[0], &lengthArray_[2], &lengthArray_[0],
std::bind1st(std::plus<uint64_t>(), (uint64_t)bytes)); std::bind1st(std::plus<int64_t>(), (int64_t)bytes));
if(isIntervalOver()) { if(isIntervalOver()) {
changeSw(); changeSw();
} }
@ -103,7 +103,7 @@ void SpeedCalc::changeSw() {
} }
unsigned int SpeedCalc::calculateAvgSpeed() const { unsigned int SpeedCalc::calculateAvgSpeed() const {
uint64_t milliElapsed = start_.differenceInMillis(global::wallclock()); int64_t milliElapsed = start_.differenceInMillis(global::wallclock());
// if milliElapsed is too small, the average speed is rubish, better return 0 // if milliElapsed is too small, the average speed is rubish, better return 0
if(milliElapsed > 4) { if(milliElapsed > 4) {

View File

@ -42,13 +42,13 @@ namespace aria2 {
class SpeedCalc { class SpeedCalc {
private: private:
uint64_t lengthArray_[2]; int64_t lengthArray_[2];
int sw_; int sw_;
Timer cpArray_[2]; Timer cpArray_[2];
unsigned int maxSpeed_; unsigned int maxSpeed_;
unsigned int prevSpeed_; unsigned int prevSpeed_;
Timer start_; Timer start_;
uint64_t accumulatedLength_; int64_t accumulatedLength_;
time_t nextInterval_; time_t nextInterval_;
bool isIntervalOver() const; bool isIntervalOver() const;

View File

@ -44,9 +44,9 @@ class TransferStat {
public: public:
unsigned int downloadSpeed; unsigned int downloadSpeed;
unsigned int uploadSpeed; unsigned int uploadSpeed;
uint64_t sessionDownloadLength; int64_t sessionDownloadLength;
uint64_t sessionUploadLength; int64_t sessionUploadLength;
uint64_t allTimeUploadLength; int64_t allTimeUploadLength;
void copy(const TransferStat& stat) void copy(const TransferStat& stat)
{ {
@ -98,28 +98,28 @@ public:
* Returns the number of bytes downloaded since the program started. * Returns the number of bytes downloaded since the program started.
* This is not the total number of bytes downloaded. * This is not the total number of bytes downloaded.
*/ */
uint64_t getSessionDownloadLength() const { int64_t getSessionDownloadLength() const {
return sessionDownloadLength; return sessionDownloadLength;
} }
void setSessionDownloadLength(uint64_t s) { sessionDownloadLength = s; } void setSessionDownloadLength(int64_t s) { sessionDownloadLength = s; }
/** /**
* Returns the number of bytes uploaded since the program started. * Returns the number of bytes uploaded since the program started.
* This is not the total number of bytes uploaded. * This is not the total number of bytes uploaded.
*/ */
uint64_t getSessionUploadLength() const { int64_t getSessionUploadLength() const {
return sessionUploadLength; return sessionUploadLength;
} }
void setSessionUploadLength(uint64_t s) { sessionUploadLength = s; } void setSessionUploadLength(int64_t s) { sessionUploadLength = s; }
void setAllTimeUploadLength(uint64_t s) void setAllTimeUploadLength(int64_t s)
{ {
allTimeUploadLength = s; allTimeUploadLength = s;
} }
uint64_t getAllTimeUploadLength() const int64_t getAllTimeUploadLength() const
{ {
return allTimeUploadLength; return allTimeUploadLength;
} }

View File

@ -238,7 +238,7 @@ void UnknownLengthPieceStorage::markAllPiecesDone()
downloadFinished_ = true; downloadFinished_ = true;
} }
void UnknownLengthPieceStorage::markPiecesDone(uint64_t length) void UnknownLengthPieceStorage::markPiecesDone(off_t length)
{ {
// TODO not implemented yet // TODO not implemented yet
abort(); abort();

View File

@ -54,7 +54,7 @@ private:
SharedHandle<DiskWriterFactory> diskWriterFactory_; SharedHandle<DiskWriterFactory> diskWriterFactory_;
uint64_t totalLength_; off_t totalLength_;
bool downloadFinished_; bool downloadFinished_;
@ -152,23 +152,23 @@ public:
virtual bool isPieceUsed(size_t index); virtual bool isPieceUsed(size_t index);
virtual uint64_t getTotalLength() virtual off_t getTotalLength()
{ {
return totalLength_; return totalLength_;
} }
virtual uint64_t getFilteredTotalLength() virtual off_t getFilteredTotalLength()
{ {
return totalLength_; return totalLength_;
} }
virtual uint64_t getCompletedLength() virtual off_t getCompletedLength()
{ {
// TODO we have to return actual completed length here? // TODO we have to return actual completed length here?
return totalLength_; return totalLength_;
} }
virtual uint64_t getFilteredCompletedLength() virtual off_t getFilteredCompletedLength()
{ {
return getCompletedLength(); return getCompletedLength();
} }
@ -259,7 +259,7 @@ public:
*/ */
virtual void markAllPiecesDone(); virtual void markAllPiecesDone();
virtual void markPiecesDone(uint64_t length); virtual void markPiecesDone(off_t length);
virtual void markPieceMissing(size_t index); virtual void markPieceMissing(size_t index);

View File

@ -232,7 +232,7 @@ void extractFileEntries
const List* filesList = downcast<List>(infoDict->get(C_FILES)); const List* filesList = downcast<List>(infoDict->get(C_FILES));
if(filesList) { if(filesList) {
fileEntries.reserve(filesList->size()); fileEntries.reserve(filesList->size());
uint64_t length = 0; off_t length = 0;
off_t offset = 0; off_t offset = 0;
// multi-file mode // multi-file mode
torrent->mode = MULTI; torrent->mode = MULTI;
@ -304,7 +304,7 @@ void extractFileEntries
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_LENGTH.c_str()), throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_LENGTH.c_str()),
error_code::BITTORRENT_PARSE_ERROR); error_code::BITTORRENT_PARSE_ERROR);
} }
uint64_t totalLength = lengthData->i(); off_t totalLength = lengthData->i();
// For each uri in urlList, if it ends with '/', then // For each uri in urlList, if it ends with '/', then
// concatenate name to it. Specification just says so. // concatenate name to it. Specification just says so.

Some files were not shown because too many files have changed in this diff Show More