Commit ebf1c535 by xzl

http文件下载器改成默认不断点续传

parent 1b78f7ae
......@@ -65,9 +65,20 @@ void HttpDownloader::onResponseBody(const char* buf, size_t size, size_t recvedS
fwrite(buf,size,1,_saveFile);
}
}
//string getMd5Sum(const string &filePath){
// auto fp = File::createfile_file(filePath.data(),"rb");
// fseek(fp,0,SEEK_END);
// auto sz = ftell(fp);
// char tmp[sz];
// fseek(fp,0,SEEK_SET);
// auto rd = fread(tmp,1,sz,fp);
// InfoL << sz << " " << rd;
// fclose(fp);
// return MD5(string(tmp,sz)).hexdigest();
//}
void HttpDownloader::onResponseCompleted() {
closeFile();
//InfoL << "md5Sum:" << getMd5Sum(_filePath);
_bDownloadSuccess = true;
if(_onResult){
_onResult(Err_success,"success",_filePath.data());
......@@ -88,6 +99,7 @@ void HttpDownloader::onDisconnect(const SockException &ex) {
void HttpDownloader::closeFile() {
if(_saveFile){
fflush(_saveFile);
fclose(_saveFile);
_saveFile = nullptr;
}
......
......@@ -20,7 +20,7 @@ public:
HttpDownloader();
virtual ~HttpDownloader();
//开始下载文件,默认断点续传方式下载
void startDownload(const string &url,const string &filePath = "",bool bAppend = true);
void startDownload(const string &url,const string &filePath = "",bool bAppend = false);
void startDownload(const string &url,const onDownloadResult &cb){
setOnResult(cb);
startDownload(url);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论