-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed headers and sources for consistency switched from namespaces to classes sllightly improved the tar header parsing (using 64-bit fseek function) moved the zip extraction logic into a separate class to make it compatible with the tar class moved the tools download logic into a separate class
- Loading branch information
1 parent
440be2d
commit f9aaa78
Showing
35 changed files
with
1,349 additions
and
801 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,7 @@ | |
CMakeSettings.json | ||
/testing | ||
/LIBS | ||
/debug.log | ||
/debug.log | ||
/test.tar | ||
/test.zip | ||
/testtar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef ARCHIVEUTILS_H | ||
#define ARCHIVEUTILS_H | ||
|
||
#include "filesystem.hpp" | ||
#ifdef __linux__ | ||
#include <cstring> | ||
#endif | ||
|
||
#include "ziparchive.h" | ||
#include "tar.h" | ||
#include "debug.h" | ||
#include <errno.h> | ||
|
||
class Archive | ||
{ | ||
public: | ||
static bool extractZip(fs::path from, std::string filename, fs::path to); | ||
static bool extractTar(fs::path from, std::string filename, fs::path to); | ||
static void Archive::extractionProgress(float progress); | ||
}; | ||
|
||
#endif // ARCHIVEUTILS_H |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef NETUTILS_H | ||
#define NETUTILS_H | ||
|
||
#include <curl/curl.h> | ||
#include <fstream> | ||
#include <sstream> | ||
#include <string> | ||
#include <iostream> | ||
#include <iomanip> | ||
#include <algorithm> | ||
#include <chrono> | ||
#include <functional> | ||
|
||
#define CURL_DEBUG false | ||
|
||
class NetworkException : public std::runtime_error | ||
{ | ||
public: | ||
NetworkException(const char* message, CURLcode code) : std::runtime_error(message), code(code) {} | ||
NetworkException(const std::string& message, CURLcode code) : std::runtime_error(message), code(code) {} | ||
CURLcode getCode() const { return code; } | ||
private: | ||
CURLcode code; | ||
}; | ||
|
||
struct NetworkProgress { | ||
double mBytesDownloadedLastTime = 0.0; | ||
long long lastProgressUpdateTime = 0; | ||
}; | ||
|
||
class Network | ||
{ | ||
public: | ||
Network(); | ||
~Network(); | ||
void curlDownload(const std::string& url, const std::string& fileName); | ||
std::string curlGet(const std::string& url); | ||
private: | ||
static constexpr double mBytesProgressUpdateDelta = 0.1; // 0.1 MB | ||
static constexpr long long updatePeriodMs = 200; // update every 100ms | ||
|
||
NetworkProgress networkProgress = {}; | ||
static size_t write_data_file(char* ptr, size_t size, size_t nmemb, void* stream); | ||
static int progress_callback(void* clientp, double dltotal, double dlnow, double ultotal, double ulnow); | ||
}; | ||
|
||
#endif // NETUTILS_H |
Oops, something went wrong.