本文整理汇总了C++中Download::addPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Download::addPos方法的具体用法?C++ Download::addPos怎么用?C++ Download::addPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Download
的用法示例。
在下文中一共展示了Download::addPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on
void DownloadManager::on(UserConnectionListener::Data, UserConnection* aSource, const uint8_t* aData, size_t aLen) noexcept {
Download* d = aSource->getDownload();
dcassert(d != NULL);
try {
d->addPos(d->getFile()->write(aData, aLen), aLen);
d->tick();
if(d->getFile()->eof()) {
endData(aSource);
aSource->setLineMode(0);
}
} catch(const Exception& e) {
failDownload(aSource, e.getError());
}
}
示例2: on
void DownloadManager::on(UserConnectionListener::Data, UserConnection* aSource, const u_int8_t* aData, size_t aLen) throw() {
Download* d = aSource->getDownload();
dcassert(d != NULL);
try {
d->addPos(d->getFile()->write(aData, aLen), aLen);
if(d->getPos() > d->getSize()) {
throw Exception(STRING(TOO_MUCH_DATA));
} else if(d->getPos() == d->getSize()) {
handleEndData(aSource);
aSource->setLineMode();
}
} catch(const RollbackException& e) {
string target = d->getTarget();
QueueManager::getInstance()->removeSource(target, aSource->getUser(), QueueItem::Source::FLAG_ROLLBACK_INCONSISTENCY);
fire(DownloadManagerListener::Failed(), d, e.getError());
d->resetPos();
aSource->setDownload(NULL);
removeDownload(d, true);
removeConnection(aSource);
return;
} catch(const FileException& e) {
fire(DownloadManagerListener::Failed(), d, e.getError());
d->resetPos();
aSource->setDownload(NULL);
removeDownload(d, true);
removeConnection(aSource);
return;
} catch(const Exception& e) {
fire(DownloadManagerListener::Failed(), d, e.getError());
// Nuke the bytes we have written, this is probably a compression error
d->resetPos();
aSource->setDownload(NULL);
removeDownload(d, true);
removeConnection(aSource);
return;
}
}