From 1b874268a067b4aba0e329768b82df635d7cae17 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 25 Jun 2012 23:35:24 +0900 Subject: [PATCH] Use int64_t instead of off_t Some classes such as DiskAdaptor, DiskWriter, FileAllocationIterator and ChecksumValidator are left unchanged. --- src/BitfieldMan.cc | 40 +++++++++--------- src/BitfieldMan.h | 38 ++++++++--------- src/BtRuntime.h | 6 +-- src/ChunkChecksum.cc | 4 +- src/ChunkChecksum.h | 2 +- src/DefaultPieceStorage.cc | 14 +++--- src/DefaultPieceStorage.h | 10 ++--- src/DownloadCommand.cc | 4 +- src/DownloadCommand.h | 2 +- src/DownloadContext.cc | 6 +-- src/DownloadContext.h | 6 +-- src/DownloadResult.h | 6 +-- src/File.cc | 2 +- src/File.h | 2 +- src/FileEntry.cc | 6 +-- src/FileEntry.h | 18 ++++---- src/FtpDownloadCommand.cc | 2 +- src/FtpDownloadCommand.h | 2 +- src/FtpNegotiationCommand.cc | 2 +- src/FtpNegotiationCommand.h | 2 +- src/GrowSegment.h | 4 +- src/HttpDownloadCommand.cc | 9 ++-- src/HttpDownloadCommand.h | 2 +- src/HttpRequest.cc | 10 ++--- src/HttpRequest.h | 10 ++--- src/HttpRequestCommand.cc | 13 +++--- src/HttpResponse.cc | 4 +- src/HttpResponse.h | 4 +- src/HttpResponseCommand.cc | 4 +- src/HttpServer.h | 4 +- src/HttpSkipResponseCommand.cc | 2 +- src/HttpSkipResponseCommand.h | 4 +- src/Metalink2RequestGroup.cc | 2 +- src/MetalinkEntry.cc | 2 +- src/MetalinkEntry.h | 2 +- src/MetalinkParserController.cc | 2 +- src/MetalinkParserController.h | 2 +- src/MetalinkParserStateMachine.cc | 2 +- src/MetalinkParserStateMachine.h | 2 +- src/Peer.cc | 10 ++--- src/Peer.h | 10 ++--- src/PeerSessionResource.cc | 10 ++--- src/PeerSessionResource.h | 10 ++--- src/PieceStorage.h | 10 ++--- src/PiecedSegment.cc | 6 +-- src/PiecedSegment.h | 4 +- src/Range.cc | 4 +- src/Range.h | 16 +++---- src/RequestGroup.cc | 16 +++---- src/RequestGroup.h | 10 ++--- src/RequestGroupMan.cc | 2 +- src/RpcMethodImpl.cc | 6 +-- src/Segment.h | 4 +- src/SegmentMan.cc | 8 ++-- src/SegmentMan.h | 6 +-- src/UnknownLengthPieceStorage.cc | 2 +- src/UnknownLengthPieceStorage.h | 12 +++--- src/bittorrent_helper.cc | 2 +- src/util.cc | 8 ++-- src/util.h | 2 +- test/BitfieldManTest.cc | 54 ++++++++++++------------ test/BittorrentHelperTest.cc | 4 +- test/DefaultBtProgressInfoFileTest.cc | 14 +++--- test/DefaultPieceStorageTest.cc | 24 +++++------ test/DirectDiskAdaptorTest.cc | 2 +- test/FallocFileAllocationIteratorTest.cc | 4 +- test/FtpConnectionTest.cc | 4 +- test/GZipDecodingStreamFilterTest.cc | 4 +- test/GrowSegmentTest.cc | 2 +- test/HandshakeExtensionMessageTest.cc | 2 +- test/HttpHeaderTest.cc | 42 +++++++++--------- test/HttpRequestTest.cc | 14 +++--- test/HttpResponseTest.cc | 8 ++-- test/Metalink2RequestGroupTest.cc | 2 +- test/MetalinkParserControllerTest.cc | 4 +- test/MetalinkProcessorTest.cc | 14 +++--- test/MockPieceStorage.h | 26 ++++++------ test/MockSegment.h | 4 +- test/MultiDiskAdaptorTest.cc | 4 +- test/MultiFileAllocationIteratorTest.cc | 8 ++-- test/PeerSessionResourceTest.cc | 8 ++-- test/RequestGroupTest.cc | 2 +- test/SingleFileAllocationIteratorTest.cc | 4 +- 83 files changed, 334 insertions(+), 336 deletions(-) diff --git a/src/BitfieldMan.cc b/src/BitfieldMan.cc index bfbc6937..feb387c1 100644 --- a/src/BitfieldMan.cc +++ b/src/BitfieldMan.cc @@ -44,7 +44,7 @@ using namespace aria2::expr; namespace aria2 { -BitfieldMan::BitfieldMan(int32_t blockLength, off_t totalLength) +BitfieldMan::BitfieldMan(int32_t blockLength, int64_t totalLength) :blockLength_(blockLength), totalLength_(totalLength), bitfieldLength_(0), @@ -663,7 +663,7 @@ void BitfieldMan::ensureFilterBitfield() } } -void BitfieldMan::addFilter(off_t offset, off_t length) { +void BitfieldMan::addFilter(int64_t offset, int64_t length) { ensureFilterBitfield(); if(length > 0) { size_t startBlock = offset/blockLength_; @@ -675,7 +675,7 @@ void BitfieldMan::addFilter(off_t offset, off_t length) { updateCache(); } -void BitfieldMan::removeFilter(off_t offset, off_t length) { +void BitfieldMan::removeFilter(int64_t offset, int64_t length) { ensureFilterBitfield(); if(length > 0) { size_t startBlock = offset/blockLength_; @@ -687,7 +687,7 @@ void BitfieldMan::removeFilter(off_t offset, off_t length) { updateCache(); } -void BitfieldMan::addNotFilter(off_t offset, off_t length) +void BitfieldMan::addNotFilter(int64_t offset, int64_t length) { ensureFilterBitfield(); if(length > 0 && blocks_ > 0) { @@ -726,7 +726,7 @@ void BitfieldMan::clearFilter() { updateCache(); } -off_t BitfieldMan::getFilteredTotalLengthNow() const { +int64_t BitfieldMan::getFilteredTotalLengthNow() const { if(!filterBitfield_) { return 0; } @@ -735,13 +735,13 @@ off_t BitfieldMan::getFilteredTotalLengthNow() const { return 0; } if(bitfield::test(filterBitfield_, blocks_, blocks_-1)) { - return ((off_t)filteredBlocks-1)*blockLength_+getLastBlockLength(); + return ((int64_t)filteredBlocks-1)*blockLength_+getLastBlockLength(); } else { - return ((off_t)filteredBlocks)*blockLength_; + return ((int64_t)filteredBlocks)*blockLength_; } } -off_t BitfieldMan::getCompletedLength(bool useFilter) const { +int64_t BitfieldMan::getCompletedLength(bool useFilter) const { unsigned char* temp; if(useFilter) { temp = new unsigned char[bitfieldLength_]; @@ -755,15 +755,15 @@ off_t BitfieldMan::getCompletedLength(bool useFilter) const { temp = bitfield_; } size_t completedBlocks = bitfield::countSetBit(temp, blocks_); - off_t completedLength = 0; + int64_t completedLength = 0; if(completedBlocks == 0) { completedLength = 0; } else { if(bitfield::test(temp, blocks_, blocks_-1)) { completedLength = - ((off_t)completedBlocks-1)*blockLength_+getLastBlockLength(); + ((int64_t)completedBlocks-1)*blockLength_+getLastBlockLength(); } else { - completedLength = ((off_t)completedBlocks)*blockLength_; + completedLength = ((int64_t)completedBlocks)*blockLength_; } } if(useFilter) { @@ -772,11 +772,11 @@ off_t BitfieldMan::getCompletedLength(bool useFilter) const { return completedLength; } -off_t BitfieldMan::getCompletedLengthNow() const { +int64_t BitfieldMan::getCompletedLengthNow() const { return getCompletedLength(false); } -off_t BitfieldMan::getFilteredCompletedLengthNow() const { +int64_t BitfieldMan::getFilteredCompletedLengthNow() const { return getCompletedLength(true); } @@ -815,7 +815,7 @@ void BitfieldMan::setBitRange(size_t startIndex, size_t endIndex) updateCache(); } -bool BitfieldMan::isBitSetOffsetRange(off_t offset, off_t length) const +bool BitfieldMan::isBitSetOffsetRange(int64_t offset, int64_t length) const { if(length <= 0) { return false; @@ -836,11 +836,11 @@ bool BitfieldMan::isBitSetOffsetRange(off_t offset, off_t length) const return true; } -off_t BitfieldMan::getOffsetCompletedLength -(off_t offset, - off_t length) const +int64_t BitfieldMan::getOffsetCompletedLength +(int64_t offset, + int64_t length) const { - off_t res = 0; + int64_t res = 0; if(length == 0 || totalLength_ <= offset) { return 0; } @@ -869,12 +869,12 @@ off_t BitfieldMan::getOffsetCompletedLength return res; } -off_t BitfieldMan::getMissingUnusedLength(size_t startingIndex) const +int64_t BitfieldMan::getMissingUnusedLength(size_t startingIndex) const { if(blocks_ <= startingIndex) { return 0; } - off_t length = 0; + int64_t length = 0; for(size_t i = startingIndex; i < blocks_; ++i) { if(isBitSet(i) || isUseBitSet(i)) { break; diff --git a/src/BitfieldMan.h b/src/BitfieldMan.h index 9a2114eb..818e6957 100644 --- a/src/BitfieldMan.h +++ b/src/BitfieldMan.h @@ -46,7 +46,7 @@ namespace aria2 { class BitfieldMan { private: int32_t blockLength_; - off_t totalLength_; + int64_t totalLength_; size_t bitfieldLength_; size_t blocks_; bool filterEnabled_; @@ -57,9 +57,9 @@ private: // for caching size_t cachedNumMissingBlock_; size_t cachedNumFilteredBlock_; - off_t cachedCompletedLength_; - off_t cachedFilteredCompletedLength_; - off_t cachedFilteredTotalLength_; + int64_t cachedCompletedLength_; + int64_t cachedFilteredCompletedLength_; + int64_t cachedFilteredTotalLength_; bool setBitInternal(unsigned char* bitfield, size_t index, bool on); bool setFilterBit(size_t index); @@ -67,7 +67,7 @@ private: size_t getStartIndex(size_t index) const; size_t getEndIndex(size_t index) const; - off_t getCompletedLength(bool useFilter) const; + int64_t getCompletedLength(bool useFilter) const; // If filterBitfield_ is 0, allocate bitfieldLength_ bytes to it and // set 0 to all bytes. @@ -84,7 +84,7 @@ public: bool operator==(const Range& range) const; }; public: - BitfieldMan(int32_t blockLength, off_t totalLength); + BitfieldMan(int32_t blockLength, int64_t totalLength); BitfieldMan(const BitfieldMan& bitfieldMan); ~BitfieldMan(); @@ -99,7 +99,7 @@ public: int32_t getBlockLength(size_t index) const; - off_t getTotalLength() const { return totalLength_; } + int64_t getTotalLength() const { return totalLength_; } // Returns true iff there is a bit index which is set in bitfield_, // but not set in this object. @@ -238,10 +238,10 @@ public: void clearAllUseBit(); void setAllUseBit(); - void addFilter(off_t offset, off_t length); - void removeFilter(off_t offset, off_t length); + void addFilter(int64_t offset, int64_t length); + void removeFilter(int64_t offset, int64_t length); // Add filter not in the range of [offset, offset+length) bytes - void addNotFilter(off_t offset, off_t length); + void addNotFilter(int64_t offset, int64_t length); // Clears filter and disables filter void clearFilter(); @@ -254,29 +254,29 @@ public: } // affected by filter - off_t getFilteredTotalLength() const + int64_t getFilteredTotalLength() const { return cachedFilteredTotalLength_; } // affected by filter - off_t getFilteredTotalLengthNow() const; + int64_t getFilteredTotalLengthNow() const; - off_t getCompletedLength() const + int64_t getCompletedLength() const { return cachedCompletedLength_; } - off_t getCompletedLengthNow() const; + int64_t getCompletedLengthNow() const; // affected by filter - off_t getFilteredCompletedLength() const + int64_t getFilteredCompletedLength() const { return cachedFilteredCompletedLength_; } // affected by filter - off_t getFilteredCompletedLengthNow() const; + int64_t getFilteredCompletedLengthNow() const; void updateCache(); @@ -286,13 +286,13 @@ public: void setBitRange(size_t startIndex, size_t endIndex); - bool isBitSetOffsetRange(off_t offset, off_t length) const; + bool isBitSetOffsetRange(int64_t offset, int64_t length) const; // Returns completed length in bytes in range [offset, // offset+length). This function will not affected by filter. - off_t getOffsetCompletedLength(off_t offset, off_t length) const; + int64_t getOffsetCompletedLength(int64_t offset, int64_t length) const; - off_t getMissingUnusedLength(size_t startingIndex) const; + int64_t getMissingUnusedLength(size_t startingIndex) const; const unsigned char* getFilterBitfield() const { diff --git a/src/BtRuntime.h b/src/BtRuntime.h index c2ef7454..5a500d39 100644 --- a/src/BtRuntime.h +++ b/src/BtRuntime.h @@ -42,7 +42,7 @@ namespace aria2 { class BtRuntime { private: - off_t uploadLengthAtStartup_; + int64_t uploadLengthAtStartup_; bool halt_; int connections_; bool ready_; @@ -57,11 +57,11 @@ public: ~BtRuntime(); - off_t getUploadLengthAtStartup() const { + int64_t getUploadLengthAtStartup() const { return uploadLengthAtStartup_; } - void setUploadLengthAtStartup(off_t length) { + void setUploadLengthAtStartup(int64_t length) { uploadLengthAtStartup_ = length; } diff --git a/src/ChunkChecksum.cc b/src/ChunkChecksum.cc index 72b5cd0b..44748c87 100644 --- a/src/ChunkChecksum.cc +++ b/src/ChunkChecksum.cc @@ -56,9 +56,9 @@ bool ChunkChecksum::validateChunk return !digest.empty() && actualDigest == digest; } -off_t ChunkChecksum::getEstimatedDataLength() const +int64_t ChunkChecksum::getEstimatedDataLength() const { - return static_cast(pieceLength_)*pieceHashes_.size(); + return static_cast(pieceLength_)*pieceHashes_.size(); } size_t ChunkChecksum::countPieceHash() const diff --git a/src/ChunkChecksum.h b/src/ChunkChecksum.h index 0baa570b..3e1e3109 100644 --- a/src/ChunkChecksum.h +++ b/src/ChunkChecksum.h @@ -60,7 +60,7 @@ public: bool validateChunk(const std::string& actualDigest, size_t index) const; - off_t getEstimatedDataLength() const; + int64_t getEstimatedDataLength() const; size_t countPieceHash() const; diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index 4af142e1..f1f13f2f 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -513,28 +513,28 @@ bool DefaultPieceStorage::isPieceUsed(size_t index) return bitfieldMan_->isUseBitSet(index); } -off_t DefaultPieceStorage::getTotalLength() +int64_t DefaultPieceStorage::getTotalLength() { return bitfieldMan_->getTotalLength(); } -off_t DefaultPieceStorage::getFilteredTotalLength() +int64_t DefaultPieceStorage::getFilteredTotalLength() { return bitfieldMan_->getFilteredTotalLength(); } -off_t DefaultPieceStorage::getCompletedLength() +int64_t DefaultPieceStorage::getCompletedLength() { - off_t completedLength = + int64_t completedLength = bitfieldMan_->getCompletedLength()+getInFlightPieceCompletedLength(); - off_t totalLength = getTotalLength(); + int64_t totalLength = getTotalLength(); if(completedLength > totalLength) { completedLength = totalLength; } return completedLength; } -off_t DefaultPieceStorage::getFilteredCompletedLength() +int64_t DefaultPieceStorage::getFilteredCompletedLength() { return bitfieldMan_->getFilteredCompletedLength()+ getInFlightPieceCompletedLength(); @@ -707,7 +707,7 @@ void DefaultPieceStorage::markAllPiecesDone() bitfieldMan_->setAllBit(); } -void DefaultPieceStorage::markPiecesDone(off_t length) +void DefaultPieceStorage::markPiecesDone(int64_t length) { if(length == bitfieldMan_->getTotalLength()) { bitfieldMan_->setAllBit(); diff --git a/src/DefaultPieceStorage.h b/src/DefaultPieceStorage.h index 4c845d8e..7851f171 100644 --- a/src/DefaultPieceStorage.h +++ b/src/DefaultPieceStorage.h @@ -192,13 +192,13 @@ public: virtual bool isPieceUsed(size_t index); - virtual off_t getTotalLength(); + virtual int64_t getTotalLength(); - virtual off_t getFilteredTotalLength(); + virtual int64_t getFilteredTotalLength(); - virtual off_t getCompletedLength(); + virtual int64_t getCompletedLength(); - virtual off_t getFilteredCompletedLength(); + virtual int64_t getFilteredCompletedLength(); virtual void initStorage(); @@ -251,7 +251,7 @@ public: virtual void markAllPiecesDone(); - virtual void markPiecesDone(off_t length); + virtual void markPiecesDone(int64_t length); virtual void markPieceMissing(size_t index); diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index 8f3c8289..c57b768e 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -146,7 +146,7 @@ bool DownloadCommand::executeInternal() { size_t bufSize; if(sinkFilterOnly_) { if(segment->getLength() > 0) { - if(static_cast(segment->getPosition()+segment->getLength()) <= + if(segment->getPosition()+segment->getLength() <= getFileEntry()->getLastOffset()) { bufSize = std::min(static_cast(segment->getLength() @@ -188,7 +188,7 @@ bool DownloadCommand::executeInternal() { segmentPartComplete = true; } } else { - off_t loff = getFileEntry()->gtoloff(segment->getPositionToWrite()); + int64_t loff = getFileEntry()->gtoloff(segment->getPositionToWrite()); if(getFileEntry()->getLength() > 0 && !sinkFilterOnly_ && ((loff == getRequestEndOffset() && streamFilter_->finished()) || loff < getRequestEndOffset()) && diff --git a/src/DownloadCommand.h b/src/DownloadCommand.h index 8d33639f..e2bc374f 100644 --- a/src/DownloadCommand.h +++ b/src/DownloadCommand.h @@ -76,7 +76,7 @@ protected: virtual bool prepareForNextSegment(); // This is file local offset - virtual off_t getRequestEndOffset() const = 0; + virtual int64_t getRequestEndOffset() const = 0; public: DownloadCommand(cuid_t cuid, const SharedHandle& req, diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc index a3b459c9..10c03ca6 100644 --- a/src/DownloadContext.cc +++ b/src/DownloadContext.cc @@ -57,7 +57,7 @@ DownloadContext::DownloadContext(): metalinkServerContacted_(false) {} DownloadContext::DownloadContext(int32_t pieceLength, - off_t totalLength, + int64_t totalLength, const std::string& path): pieceLength_(pieceLength), checksumVerified_(false), @@ -95,7 +95,7 @@ int64_t DownloadContext::calculateSessionTime() const } SharedHandle -DownloadContext::findFileEntryByOffset(off_t offset) const +DownloadContext::findFileEntryByOffset(int64_t offset) const { if(fileEntries_.empty() || (offset > 0 && fileEntries_.back()->getLastOffset() <= offset)) { @@ -198,7 +198,7 @@ size_t DownloadContext::getNumPieces() const } } -off_t DownloadContext::getTotalLength() const +int64_t DownloadContext::getTotalLength() const { if(fileEntries_.empty()) { return 0; diff --git a/src/DownloadContext.h b/src/DownloadContext.h index 5bee68a3..810671bd 100644 --- a/src/DownloadContext.h +++ b/src/DownloadContext.h @@ -93,7 +93,7 @@ public: // Convenient constructor that creates single file download. path // should be escaped with util::escapePath(...). DownloadContext(int32_t pieceLength, - off_t totalLength, + int64_t totalLength, const std::string& path = A2STR::NIL); ~DownloadContext(); @@ -114,7 +114,7 @@ public: pieceHashes_.assign(first, last); } - off_t getTotalLength() const; + int64_t getTotalLength() const; bool knowsTotalLength() const { return knowsTotalLength_; } @@ -222,7 +222,7 @@ public: // Returns FileEntry at given offset. SharedHandle() is // returned if no such FileEntry is found. - SharedHandle findFileEntryByOffset(off_t offset) const; + SharedHandle findFileEntryByOffset(int64_t offset) const; void releaseRuntimeResource(); diff --git a/src/DownloadResult.h b/src/DownloadResult.h index c0efc1b4..312d67d5 100644 --- a/src/DownloadResult.h +++ b/src/DownloadResult.h @@ -79,11 +79,11 @@ struct DownloadResult SharedHandle metadataInfo; - off_t totalLength; + int64_t totalLength; - off_t completedLength; + int64_t completedLength; - off_t uploadLength; + int64_t uploadLength; std::string bitfield; diff --git a/src/File.cc b/src/File.cc index 7a73f503..dab20cbb 100644 --- a/src/File.cc +++ b/src/File.cc @@ -103,7 +103,7 @@ bool File::remove() { } } -off_t File::size() { +int64_t File::size() { a2_struct_stat fstat; if(fillStat(fstat) < 0) { return 0; diff --git a/src/File.h b/src/File.h index 8290cd4e..3a6ab846 100644 --- a/src/File.h +++ b/src/File.h @@ -94,7 +94,7 @@ public: */ bool mkdirs(); - off_t size(); + int64_t size(); mode_t mode(); diff --git a/src/FileEntry.cc b/src/FileEntry.cc index fc7add1d..27641c24 100644 --- a/src/FileEntry.cc +++ b/src/FileEntry.cc @@ -68,8 +68,8 @@ bool FileEntry::RequestFaster::operator() FileEntry::FileEntry (const std::string& path, - off_t length, - off_t offset, + int64_t length, + int64_t offset, const std::vector& uris) : path_(path), uris_(uris.begin(), uris.end()), @@ -112,7 +112,7 @@ bool FileEntry::exists() const return File(getPath()).exists(); } -off_t FileEntry::gtoloff(off_t goff) const +int64_t FileEntry::gtoloff(int64_t goff) const { assert(offset_ <= goff); return goff-offset_; diff --git a/src/FileEntry.h b/src/FileEntry.h index 13d51272..a1ed29de 100644 --- a/src/FileEntry.h +++ b/src/FileEntry.h @@ -66,8 +66,8 @@ private: std::string path_; std::deque uris_; std::deque spentUris_; - off_t length_; - off_t offset_; + int64_t length_; + int64_t offset_; bool requested_; class RequestFaster { @@ -92,7 +92,7 @@ private: public: FileEntry(); - FileEntry(const std::string& path, off_t length, off_t offset, + FileEntry(const std::string& path, int64_t length, int64_t offset, const std::vector& uris = std::vector()); ~FileEntry(); @@ -107,15 +107,15 @@ public: void setPath(const std::string& path); - off_t getLength() const { return length_; } + int64_t getLength() const { return length_; } - void setLength(off_t length) { length_ = length; } + void setLength(int64_t length) { length_ = length; } - off_t getOffset() const { return offset_; } + int64_t getOffset() const { return offset_; } - void setOffset(off_t offset) { offset_ = offset; } + void setOffset(int64_t offset) { offset_ = offset; } - off_t getLastOffset() { return offset_+length_; } + int64_t getLastOffset() { return offset_+length_; } bool isRequested() const { return requested_; } @@ -209,7 +209,7 @@ public: bool exists() const; // Translate global offset goff to file local offset. - off_t gtoloff(off_t goff) const; + int64_t gtoloff(int64_t goff) const; void removeURIWhoseHostnameIs(const std::string& hostname); diff --git a/src/FtpDownloadCommand.cc b/src/FtpDownloadCommand.cc index a13c601e..4b175d7b 100644 --- a/src/FtpDownloadCommand.cc +++ b/src/FtpDownloadCommand.cc @@ -85,7 +85,7 @@ bool FtpDownloadCommand::prepareForNextSegment() } } -off_t FtpDownloadCommand::getRequestEndOffset() const +int64_t FtpDownloadCommand::getRequestEndOffset() const { return getFileEntry()->getLength(); } diff --git a/src/FtpDownloadCommand.h b/src/FtpDownloadCommand.h index 4d381f0e..24eeabe8 100644 --- a/src/FtpDownloadCommand.h +++ b/src/FtpDownloadCommand.h @@ -48,7 +48,7 @@ private: SharedHandle ctrlSocket_; protected: virtual bool prepareForNextSegment(); - virtual off_t getRequestEndOffset() const; + virtual int64_t getRequestEndOffset() const; public: FtpDownloadCommand(cuid_t cuid, const SharedHandle& req, diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index 49907e9a..662a4746 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -367,7 +367,7 @@ bool FtpNegotiationCommand::sendSize() { return false; } -bool FtpNegotiationCommand::onFileSizeDetermined(off_t totalLength) +bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength) { getFileEntry()->setLength(totalLength); if(getFileEntry()->getPath().empty()) { diff --git a/src/FtpNegotiationCommand.h b/src/FtpNegotiationCommand.h index a22e6853..07e4c228 100644 --- a/src/FtpNegotiationCommand.h +++ b/src/FtpNegotiationCommand.h @@ -137,7 +137,7 @@ private: void poolConnection() const; - bool onFileSizeDetermined(off_t totalLength); + bool onFileSizeDetermined(int64_t totalLength); void onDryRunFileFound(); diff --git a/src/GrowSegment.h b/src/GrowSegment.h index cc67ba2f..c211e8f7 100644 --- a/src/GrowSegment.h +++ b/src/GrowSegment.h @@ -58,12 +58,12 @@ public: return 0; } - virtual off_t getPosition() const + virtual int64_t getPosition() const { return 0; } - virtual off_t getPositionToWrite() const + virtual int64_t getPositionToWrite() const { return writtenLength_; } diff --git a/src/HttpDownloadCommand.cc b/src/HttpDownloadCommand.cc index f919dbfd..0963665a 100644 --- a/src/HttpDownloadCommand.cc +++ b/src/HttpDownloadCommand.cc @@ -117,9 +117,8 @@ bool HttpDownloadCommand::prepareForNextSegment() { !downloadFinished) { const SharedHandle& segment = getSegments().front(); - off_t lastOffset =getFileEntry()->gtoloff - (std::min(static_cast - (segment->getPosition()+segment->getLength()), + int64_t lastOffset =getFileEntry()->gtoloff + (std::min(segment->getPosition()+segment->getLength(), getFileEntry()->getLastOffset())); if(lastOffset == @@ -131,9 +130,9 @@ bool HttpDownloadCommand::prepareForNextSegment() { } } -off_t HttpDownloadCommand::getRequestEndOffset() const +int64_t HttpDownloadCommand::getRequestEndOffset() const { - off_t endByte = httpResponse_->getHttpHeader()->getRange()->getEndByte(); + int64_t endByte = httpResponse_->getHttpHeader()->getRange()->getEndByte(); if(endByte > 0) { return endByte+1; } else { diff --git a/src/HttpDownloadCommand.h b/src/HttpDownloadCommand.h index eae1dc87..491933aa 100644 --- a/src/HttpDownloadCommand.h +++ b/src/HttpDownloadCommand.h @@ -48,7 +48,7 @@ private: SharedHandle httpConnection_; protected: virtual bool prepareForNextSegment(); - virtual off_t getRequestEndOffset() const; + virtual int64_t getRequestEndOffset() const; public: HttpDownloadCommand(cuid_t cuid, const SharedHandle& req, diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index beba1b67..104a02a9 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -75,7 +75,7 @@ void HttpRequest::setRequest(const SharedHandle& request) request_ = request; } -off_t HttpRequest::getStartByte() const +int64_t HttpRequest::getStartByte() const { if(!segment_) { return 0; @@ -84,15 +84,15 @@ off_t HttpRequest::getStartByte() const } } -off_t HttpRequest::getEndByte() const +int64_t HttpRequest::getEndByte() const { if(!segment_ || !request_) { return 0; } else { if(request_->isPipeliningEnabled()) { - off_t endByte = + int64_t endByte = fileEntry_->gtoloff(segment_->getPosition()+segment_->getLength()-1); - return std::min(endByte, static_cast(fileEntry_->getLength()-1)); + return std::min(endByte, fileEntry_->getLength()-1); } else { return 0; } @@ -367,7 +367,7 @@ const SharedHandle& HttpRequest::getAuthConfig() const return authConfig_; } -off_t HttpRequest::getEntityLength() const +int64_t HttpRequest::getEntityLength() const { assert(fileEntry_); return fileEntry_->getLength(); diff --git a/src/HttpRequest.h b/src/HttpRequest.h index 1e72f754..6b5e948b 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -87,7 +87,7 @@ private: bool acceptGzip_; - off_t endOffsetOverride_; + int64_t endOffsetOverride_; std::string ifModSinceHeader_; @@ -105,7 +105,7 @@ public: void setRequest(const SharedHandle& request); - off_t getEntityLength() const; + int64_t getEntityLength() const; const std::string& getHost() const; @@ -140,9 +140,9 @@ public: return request_; } - off_t getStartByte() const; + int64_t getStartByte() const; - off_t getEndByte() const; + int64_t getEndByte() const; /** * Returns string representation of http request. It usually starts @@ -240,7 +240,7 @@ public: return acceptGzip_; } - void setEndOffsetOverride(off_t offset) + void setEndOffsetOverride(int64_t offset) { endOffsetOverride_ = offset; } diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc index a52ce99e..3d0ba593 100644 --- a/src/HttpRequestCommand.cc +++ b/src/HttpRequestCommand.cc @@ -86,13 +86,13 @@ SharedHandle createHttpRequest(const SharedHandle& req, const SharedHandle& fileEntry, const SharedHandle& segment, - off_t totalLength, + int64_t totalLength, const SharedHandle