From a88175b15d8b14857fe8e6ade6a66b62b72733fd Mon Sep 17 00:00:00 2001 From: EmreTech Date: Mon, 8 Mar 2021 11:41:56 -0800 Subject: [PATCH] Trying to fix by renaming utils to download --- core/include/constants.hpp | 1 + core/include/{utils.hpp => download.hpp} | 3 +++ core/source/{utils.cpp => download.cpp} | 9 +++++++-- gui/source/gui_app.cpp | 2 +- gui/source/updaterTab.cpp | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) rename core/include/{utils.hpp => download.hpp} (82%) rename core/source/{utils.cpp => download.cpp} (84%) diff --git a/core/include/constants.hpp b/core/include/constants.hpp index 158c66c..b8d7dff 100644 --- a/core/include/constants.hpp +++ b/core/include/constants.hpp @@ -1,3 +1,4 @@ +#pragma once #define ROOT_PATH "/" #define NRO_PATH_1 "/switch/Calculator_NX.nro" // This is for if the user manually got this app from my GitHub diff --git a/core/include/utils.hpp b/core/include/download.hpp similarity index 82% rename from core/include/utils.hpp rename to core/include/download.hpp index ea855d2..5d7d164 100644 --- a/core/include/utils.hpp +++ b/core/include/download.hpp @@ -1,3 +1,5 @@ +#pragma once + #include #include #include @@ -13,6 +15,7 @@ #define API_AGENT "EmreTech" using json = nlohmann::json; +size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream); void downloadFile(const char *url, const char *filename); std::string getLatestTag(std::string url); std::string getLatestDownload(std::string url); \ No newline at end of file diff --git a/core/source/utils.cpp b/core/source/download.cpp similarity index 84% rename from core/source/utils.cpp rename to core/source/download.cpp index ce9ab8d..afb76a3 100644 --- a/core/source/utils.cpp +++ b/core/source/download.cpp @@ -1,4 +1,9 @@ -#include "utils.hpp" +#include "download.hpp" + +size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { + size_t written = fwrite(ptr, size, nmemb, stream); + return written; +} void downloadFile(const char *url, const char *filename) { CURL *curl; @@ -16,7 +21,7 @@ void downloadFile(const char *url, const char *filename) { curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); res = curl_easy_perform(curl); diff --git a/gui/source/gui_app.cpp b/gui/source/gui_app.cpp index a344f0b..5042dcf 100644 --- a/gui/source/gui_app.cpp +++ b/gui/source/gui_app.cpp @@ -3,7 +3,7 @@ #include #include #include "constants.hpp" -#include "utils.hpp" +#include "download.hpp" //#include "app.hpp" using namespace brls::literals; diff --git a/gui/source/updaterTab.cpp b/gui/source/updaterTab.cpp index 2640d0f..8da1f01 100644 --- a/gui/source/updaterTab.cpp +++ b/gui/source/updaterTab.cpp @@ -1,6 +1,6 @@ #include "updaterTab.hpp" -#include "utils.hpp" +#include "download.hpp" #include "constants.hpp" #include #include