feat: add updater

This commit is contained in:
2021-11-13 16:06:48 +01:00
parent 67a4ec511e
commit fc0cab54d2
7 changed files with 289 additions and 0 deletions

37
include/misc/Updater.h Normal file
View File

@@ -0,0 +1,37 @@
#pragma once
#include "misc/DataBuffer.h"
namespace td {
namespace utils {
class Updater {
private:
float m_Progress;
bool m_DownloadComplete;
bool m_FileWrited;
bool m_CancelDownload;
DataBuffer m_FileBuffer;
public:
Updater() : m_Progress(0), m_DownloadComplete(false), m_FileWrited(false), m_CancelDownload(false) {}
bool checkUpdate();
void downloadUpdate();
void cancelDownload() { m_CancelDownload = true; m_Progress = 0.0f; m_DownloadComplete = false; }
bool writeFile();
void clearCache() { m_FileBuffer.Clear(); }
float getDownloadProgress() { return m_Progress; }
bool isDownloadComplete() { return m_DownloadComplete; }
bool isFileWrited() { return m_FileWrited; }
static std::string getLocalFilePath();
static void removeOldFile();
private:
std::string getDownloadFileURL();
std::uint32_t getLocalFileSize();
};
} // namespace utils
} // namespace td