Skip to content

Commit

Permalink
Trying to fix by renaming utils to download
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmmaTech committed Mar 8, 2021
1 parent 10c0d82 commit a88175b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/include/constants.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions core/include/utils.hpp → core/include/download.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <json.hpp>
#include <sys/select.h>
#include <curl/curl.h>
Expand All @@ -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);
9 changes: 7 additions & 2 deletions core/source/utils.cpp → core/source/download.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion gui/source/gui_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <filesystem>
#include <fstream>
#include "constants.hpp"
#include "utils.hpp"
#include "download.hpp"
//#include "app.hpp"

using namespace brls::literals;
Expand Down
2 changes: 1 addition & 1 deletion gui/source/updaterTab.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "updaterTab.hpp"

#include "utils.hpp"
#include "download.hpp"
#include "constants.hpp"
#include <string>
#include <filesystem>
Expand Down

0 comments on commit a88175b

Please sign in to comment.