Refactored downloading of Kickstart RTB files into function
This commit is contained in:
parent
0b76ecc9e7
commit
25a4daabdd
3 changed files with 20 additions and 30 deletions
14
src/main.cpp
14
src/main.cpp
|
@ -931,6 +931,20 @@ bool download_file(const std::string& source, std::string destination)
|
|||
return false;
|
||||
}
|
||||
|
||||
void download_rtb(std::string filename)
|
||||
{
|
||||
char destination[MAX_DPATH];
|
||||
char url[MAX_DPATH];
|
||||
|
||||
snprintf(destination, MAX_DPATH, "%s/whdboot/save-data/Kickstarts/%s", start_path_data, filename);
|
||||
if (get_file_size(destination) <= 0)
|
||||
{
|
||||
write_log("Downloading %s ...\n", destination);
|
||||
snprintf(url, MAX_DPATH, "https://github.com/midwan/amiberry/blob/master/whdboot/save-data/Kickstarts/%s?raw=true", filename);
|
||||
download_file(url, destination);
|
||||
}
|
||||
}
|
||||
|
||||
// In case of error, print the error code and close the application
|
||||
void check_error_sdl(const bool check, const char* message)
|
||||
{
|
||||
|
|
|
@ -189,36 +189,11 @@ public:
|
|||
download_file("https://github.com/midwan/amiberry/blob/master/whdboot/boot-data.zip?raw=true", destination);
|
||||
|
||||
// download kickstart RTB files for maximum compatibility
|
||||
snprintf(destination, MAX_DPATH, "%s/whdboot/save-data/Kickstarts/kick33180.A500.RTB", start_path_data);
|
||||
if (get_file_size(destination) <= 0)
|
||||
{
|
||||
write_log("Downloading %s ...\n", destination);
|
||||
download_file("https://github.com/midwan/amiberry/blob/master/whdboot/save-data/Kickstarts/kick33180.A500.RTB?raw=true", destination);
|
||||
}
|
||||
snprintf(destination, MAX_DPATH, "%s/whdboot/save-data/Kickstarts/kick34005.A500.RTB", start_path_data);
|
||||
if (get_file_size(destination) <= 0)
|
||||
{
|
||||
write_log("Downloading %s ...\n", destination);
|
||||
download_file("https://github.com/midwan/amiberry/blob/master/whdboot/save-data/Kickstarts/kick34005.A500.RTB?raw=true", destination);
|
||||
}
|
||||
snprintf(destination, MAX_DPATH, "%s/whdboot/save-data/Kickstarts/kick40063.A600.RTB", start_path_data);
|
||||
if (get_file_size(destination) <= 0)
|
||||
{
|
||||
write_log("Downloading %s ...\n", destination);
|
||||
download_file("https://github.com/midwan/amiberry/blob/master/whdboot/save-data/Kickstarts/kick40063.A600.RTB?raw=true", destination);
|
||||
}
|
||||
snprintf(destination, MAX_DPATH, "%s/whdboot/save-data/Kickstarts/kick40068.A1200.RTB", start_path_data);
|
||||
if (get_file_size(destination) <= 0)
|
||||
{
|
||||
write_log("Downloading %s ...\n", destination);
|
||||
download_file("https://github.com/midwan/amiberry/blob/master/whdboot/save-data/Kickstarts/kick40068.A1200.RTB?raw=true", destination);
|
||||
}
|
||||
snprintf(destination, MAX_DPATH, "%s/whdboot/save-data/Kickstarts/kick40068.A4000.RTB", start_path_data);
|
||||
if (get_file_size(destination) <= 0)
|
||||
{
|
||||
write_log("Downloading %s ...\n", destination);
|
||||
download_file("https://github.com/midwan/amiberry/blob/master/whdboot/save-data/Kickstarts/kick40068.A4000.RTB?raw=true", destination);
|
||||
}
|
||||
download_rtb("kick33180.A500.RTB");
|
||||
download_rtb("kick34005.A500.RTB");
|
||||
download_rtb("kick40063.A600.RTB");
|
||||
download_rtb("kick40068.A1200.RTB");
|
||||
download_rtb("kick40068.A4000.RTB");
|
||||
|
||||
snprintf(destination, MAX_DPATH, "%s/whdboot/game-data/whdload_db.xml", start_path_data);
|
||||
write_log("Downloading %s ...\n", destination);
|
||||
|
|
|
@ -189,5 +189,6 @@ extern void UpdateGuiScreen();
|
|||
extern void cap_fps(Uint64 start, int fps);
|
||||
extern long get_file_size(const std::string& filename);
|
||||
extern bool download_file(const std::string& source, std::string destination);
|
||||
extern void download_rtb(std::string filename);
|
||||
|
||||
#endif // GUI_HANDLING_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue