38 lines
723 B
C
38 lines
723 B
C
|
#ifndef MULTI_DOWNLOAD_H
|
||
|
#define MULTI_DOWNLOAD_H
|
||
|
|
||
|
#include <curl/curl.h>
|
||
|
#include <iostream>
|
||
|
#include <fstream>
|
||
|
#include <chrono>
|
||
|
|
||
|
class CTimer
|
||
|
{
|
||
|
using time_point_t = std::chrono::high_resolution_clock::time_point;
|
||
|
public:
|
||
|
CTimer() = default;
|
||
|
~CTimer() = default;
|
||
|
public:
|
||
|
void start();
|
||
|
// 秒种
|
||
|
size_t getTime();
|
||
|
private:
|
||
|
time_point_t m_start;
|
||
|
time_point_t m_end;
|
||
|
};
|
||
|
|
||
|
class CThreadDownload
|
||
|
{
|
||
|
public:
|
||
|
CThreadDownload();
|
||
|
~CThreadDownload();
|
||
|
public:
|
||
|
double getFileLength(const char* url);
|
||
|
int download(const char* url, const char* filename);
|
||
|
static size_t writeFunCall(void* ptr, size_t size, size_t mmb, void* userdata);
|
||
|
|
||
|
private:
|
||
|
std::ofstream m_fstream;
|
||
|
};
|
||
|
|
||
|
#endif
|