#pragma once #include #include #include #include #include #include #include #include #include class Dependency { public: enum class Type { automatic, simple, mason }; Dependency( const std::string& path, Type type = Type::automatic, const std::optional& name = std::nullopt, const std::optional& version = std::nullopt ); Type getType() const; std::optional getName() const; std::optional getVersion() const; bool prepare(const std::filesystem::path& source, const std::filesystem::path& destination); const std::string path; private: static size_t writeFile(void* data, size_t size, size_t nmemb, void* file); static size_t writeString(void* data, size_t size, size_t nmemb, void* mem); static int trace(CURL *handle, curl_infotype type, char *data, size_t size, void *clientp); bool download(const std::string& url, const std::filesystem::path& destination); bool downloadRepo( const std::filesystem::path& destination, const std::string& protocol, const std::string& host, const std::string& owner, const std::string& repo, std::filesystem::path& out ); bool repoGiteaApi1( const std::string& protocol, const std::string& host, const std::string& owner, const std::string& repo, nlohmann::json& json ); CURLcode httpGet(const std::string& url, std::string& result, const std::list& headers = {}); bool extract(const std::filesystem::path& source, const std::filesystem::path& destination) const; int copy(struct archive *ar, struct archive *aw) const; private: Type type; std::optional name; std::optional version; };