2020#include " ini.hpp"
2121
2222#define NEWLINE std::cout << std::endl;
23+ #define DEFAULT_CONFIG " [Config]\n download_server=https://www.nlog.us/downloads/\n download_file=full_archive.zip"
2324
2425// Needed
26+ std::string download_server;
27+ std::string download_file;
2528bool download_complete = false ;
2629
2730// Termination
@@ -88,7 +91,7 @@ std::size_t write_data(void* ptr, std::size_t size, std::size_t nmemb, FILE* str
8891void get_bonzo ()
8992{
9093 // Folder/file
91- std::string site (" https://nlog.us/downloads/full_archive.zip " );
94+ std::string site (download_server + download_file );
9295
9396 // File variable
9497 FILE* fp;
@@ -102,7 +105,7 @@ void get_bonzo()
102105 curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data);
103106
104107 // Open
105- fp = fopen (" full_archive.zip " , " wb" );
108+ fp = fopen (download_file. c_str () , " wb" );
106109 if (fp)
107110 {
108111 // Write
@@ -180,6 +183,34 @@ int main()
180183 // Do a cleaning before downloading anything
181184 deep_clean (false );
182185
186+ // We don't have a config?
187+ if (!std::filesystem::exists (" config.ini" ))
188+ {
189+ // Create
190+ std::ofstream file (" config.ini" );
191+ file << DEFAULT_CONFIG << std::endl;
192+
193+ // Close
194+ file.close ();
195+ }
196+
197+ // Read download information
198+ {
199+ mINI ::INIFile file (" config.ini" );
200+ mINI ::INIStructure ini;
201+
202+ // Read
203+ file.read (ini);
204+
205+ // Server information
206+ download_server = ini[" Config" ][" download_server" ];
207+ download_file = ini[" Config" ][" download_file" ];
208+
209+ // Validation
210+ if (download_server.empty ()) throw_error (" Missing download_server in config.ini, please make a proper configuration." );
211+ if (download_file.empty ()) throw_error (" Missing download_file in config.ini, please make a proper configuration." );
212+ }
213+
183214 // Download
184215 get_bonzo ();
185216
@@ -283,15 +314,15 @@ int main()
283314 NEWLINE
284315
285316 // Ask about the platform
286- std::cout << " Steam or Epic Games ? (steam / epic ): " ;
317+ std::cout << " Steam or Other platform ? (steam / other ): " ;
287318 std::string input_platform;
288319
289320 std::getline (std::cin, input_platform);
290321
291322 // Choice
292- bool steam = true ;
323+ bool steam = false ;
293324
294- if (input_platform.find (" epic " ) != std::string::npos) steam = false ;
325+ if (input_platform.find (" steam " ) != std::string::npos) steam = true ;
295326
296327 // Variable, will be used later
297328 std::string game_path;
0 commit comments