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>
|
2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Removed unused contants
|
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
|
} // namespace aria2
|
||||||
|
|
|
@ -113,14 +113,7 @@ public:
|
||||||
_pieceHashes.assign(first, last);
|
_pieceHashes.assign(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getTotalLength() const
|
uint64_t getTotalLength() const;
|
||||||
{
|
|
||||||
if(_fileEntries.empty()) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return _fileEntries.back()->getLastOffset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool knowsTotalLength() const { return _knowsTotalLength; }
|
bool knowsTotalLength() const { return _knowsTotalLength; }
|
||||||
|
|
||||||
|
@ -149,15 +142,7 @@ public:
|
||||||
|
|
||||||
void setPieceLength(size_t length) { _pieceLength = length; }
|
void setPieceLength(size_t length) { _pieceLength = length; }
|
||||||
|
|
||||||
size_t getNumPieces() const
|
size_t getNumPieces() const;
|
||||||
{
|
|
||||||
if(_pieceLength == 0) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
assert(!_fileEntries.empty());
|
|
||||||
return (_fileEntries.back()->getLastOffset()+_pieceLength-1)/_pieceLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& getPieceHashAlgo() const { return _pieceHashAlgo; }
|
const std::string& getPieceHashAlgo() const { return _pieceHashAlgo; }
|
||||||
|
|
||||||
|
@ -184,15 +169,7 @@ public:
|
||||||
// part of .aria2 control file. If _basePath is set, returns
|
// part of .aria2 control file. If _basePath is set, returns
|
||||||
// _basePath. Otherwise, the first FileEntry's getFilePath() is
|
// _basePath. Otherwise, the first FileEntry's getFilePath() is
|
||||||
// returned.
|
// returned.
|
||||||
const std::string& getBasePath() const
|
const std::string& getBasePath() const;
|
||||||
{
|
|
||||||
if(_basePath.empty()) {
|
|
||||||
assert(!_fileEntries.empty());
|
|
||||||
return getFirstFileEntry()->getPath();
|
|
||||||
} else {
|
|
||||||
return _basePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBasePath(const std::string& basePath) { _basePath = basePath; }
|
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
|
} // namespace aria2
|
||||||
|
|
|
@ -84,15 +84,9 @@ public:
|
||||||
|
|
||||||
FileEntry& operator=(const FileEntry& entry);
|
FileEntry& operator=(const FileEntry& entry);
|
||||||
|
|
||||||
std::string getBasename() const
|
std::string getBasename() const;
|
||||||
{
|
|
||||||
return File(_path).getBasename();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getDirname() const
|
std::string getDirname() const;
|
||||||
{
|
|
||||||
return File(_path).getDirname();
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& getPath() const { return _path; }
|
const std::string& getPath() const { return _path; }
|
||||||
|
|
||||||
|
@ -129,11 +123,7 @@ public:
|
||||||
return _spentUris;
|
return _spentUris;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t setUris(const std::vector<std::string>& uris)
|
size_t setUris(const std::vector<std::string>& uris);
|
||||||
{
|
|
||||||
_uris.clear();
|
|
||||||
return addUris(uris.begin(), uris.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename InputIterator>
|
template<typename InputIterator>
|
||||||
size_t addUris(InputIterator first, InputIterator last)
|
size_t addUris(InputIterator first, InputIterator last)
|
||||||
|
@ -147,26 +137,9 @@ public:
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addUri(const std::string& uri)
|
bool addUri(const std::string& uri);
|
||||||
{
|
|
||||||
if(Request().setUri(uri)) {
|
|
||||||
_uris.push_back(uri);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool insertUri(const std::string& uri, size_t pos)
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inserts _uris and _spentUris into uris.
|
// Inserts _uris and _spentUris into uris.
|
||||||
void getUris(std::vector<std::string>& uris) const;
|
void getUris(std::vector<std::string>& uris) const;
|
||||||
|
|
Loading…
Reference in New Issue