mirror of https://github.com/aria2/aria2
2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Moved non-trivial functions to *.cc file * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.hpull/1/head
parent
b352b97bc6
commit
237f15b491
|
@ -1,3 +1,11 @@
|
|||
2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Moved non-trivial functions to *.cc file
|
||||
* src/DownloadContext.cc
|
||||
* src/DownloadContext.h
|
||||
* src/FileEntry.cc
|
||||
* src/FileEntry.h
|
||||
|
||||
2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Removed unused contants
|
||||
|
|
|
@ -176,4 +176,33 @@ void DownloadContext::releaseRuntimeResource()
|
|||
}
|
||||
}
|
||||
|
||||
size_t DownloadContext::getNumPieces() const
|
||||
{
|
||||
if(_pieceLength == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
assert(!_fileEntries.empty());
|
||||
return (_fileEntries.back()->getLastOffset()+_pieceLength-1)/_pieceLength;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t DownloadContext::getTotalLength() const
|
||||
{
|
||||
if(_fileEntries.empty()) {
|
||||
return 0;
|
||||
} else {
|
||||
return _fileEntries.back()->getLastOffset();
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& DownloadContext::getBasePath() const
|
||||
{
|
||||
if(_basePath.empty()) {
|
||||
assert(!_fileEntries.empty());
|
||||
return getFirstFileEntry()->getPath();
|
||||
} else {
|
||||
return _basePath;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -113,14 +113,7 @@ public:
|
|||
_pieceHashes.assign(first, last);
|
||||
}
|
||||
|
||||
uint64_t getTotalLength() const
|
||||
{
|
||||
if(_fileEntries.empty()) {
|
||||
return 0;
|
||||
} else {
|
||||
return _fileEntries.back()->getLastOffset();
|
||||
}
|
||||
}
|
||||
uint64_t getTotalLength() const;
|
||||
|
||||
bool knowsTotalLength() const { return _knowsTotalLength; }
|
||||
|
||||
|
@ -149,15 +142,7 @@ public:
|
|||
|
||||
void setPieceLength(size_t length) { _pieceLength = length; }
|
||||
|
||||
size_t getNumPieces() const
|
||||
{
|
||||
if(_pieceLength == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
assert(!_fileEntries.empty());
|
||||
return (_fileEntries.back()->getLastOffset()+_pieceLength-1)/_pieceLength;
|
||||
}
|
||||
}
|
||||
size_t getNumPieces() const;
|
||||
|
||||
const std::string& getPieceHashAlgo() const { return _pieceHashAlgo; }
|
||||
|
||||
|
@ -184,15 +169,7 @@ public:
|
|||
// part of .aria2 control file. If _basePath is set, returns
|
||||
// _basePath. Otherwise, the first FileEntry's getFilePath() is
|
||||
// returned.
|
||||
const std::string& getBasePath() const
|
||||
{
|
||||
if(_basePath.empty()) {
|
||||
assert(!_fileEntries.empty());
|
||||
return getFirstFileEntry()->getPath();
|
||||
} else {
|
||||
return _basePath;
|
||||
}
|
||||
}
|
||||
const std::string& getBasePath() const;
|
||||
|
||||
void setBasePath(const std::string& basePath) { _basePath = basePath; }
|
||||
|
||||
|
|
|
@ -378,4 +378,41 @@ bool FileEntry::removeUri(const std::string& uri)
|
|||
}
|
||||
}
|
||||
|
||||
std::string FileEntry::getBasename() const
|
||||
{
|
||||
return File(_path).getBasename();
|
||||
}
|
||||
|
||||
std::string FileEntry::getDirname() const
|
||||
{
|
||||
return File(_path).getDirname();
|
||||
}
|
||||
|
||||
size_t FileEntry::setUris(const std::vector<std::string>& uris)
|
||||
{
|
||||
_uris.clear();
|
||||
return addUris(uris.begin(), uris.end());
|
||||
}
|
||||
|
||||
bool FileEntry::addUri(const std::string& uri)
|
||||
{
|
||||
if(Request().setUri(uri)) {
|
||||
_uris.push_back(uri);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool FileEntry::insertUri(const std::string& uri, size_t pos)
|
||||
{
|
||||
if(Request().setUri(uri)) {
|
||||
pos = std::min(pos, _uris.size());
|
||||
_uris.insert(_uris.begin()+pos, uri);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -84,15 +84,9 @@ public:
|
|||
|
||||
FileEntry& operator=(const FileEntry& entry);
|
||||
|
||||
std::string getBasename() const
|
||||
{
|
||||
return File(_path).getBasename();
|
||||
}
|
||||
std::string getBasename() const;
|
||||
|
||||
std::string getDirname() const
|
||||
{
|
||||
return File(_path).getDirname();
|
||||
}
|
||||
std::string getDirname() const;
|
||||
|
||||
const std::string& getPath() const { return _path; }
|
||||
|
||||
|
@ -129,11 +123,7 @@ public:
|
|||
return _spentUris;
|
||||
}
|
||||
|
||||
size_t setUris(const std::vector<std::string>& uris)
|
||||
{
|
||||
_uris.clear();
|
||||
return addUris(uris.begin(), uris.end());
|
||||
}
|
||||
size_t setUris(const std::vector<std::string>& uris);
|
||||
|
||||
template<typename InputIterator>
|
||||
size_t addUris(InputIterator first, InputIterator last)
|
||||
|
@ -147,26 +137,9 @@ public:
|
|||
return count;
|
||||
}
|
||||
|
||||
bool addUri(const std::string& uri)
|
||||
{
|
||||
if(Request().setUri(uri)) {
|
||||
_uris.push_back(uri);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool addUri(const std::string& uri);
|
||||
|
||||
bool insertUri(const std::string& uri, size_t pos)
|
||||
{
|
||||
if(Request().setUri(uri)) {
|
||||
pos = std::min(pos, _uris.size());
|
||||
_uris.insert(_uris.begin()+pos, uri);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool insertUri(const std::string& uri, size_t pos);
|
||||
|
||||
// Inserts _uris and _spentUris into uris.
|
||||
void getUris(std::vector<std::string>& uris) const;
|
||||
|
|
Loading…
Reference in New Issue