update system for standalone versions in place - not yet tested

This commit is contained in:
Christopher Roy Bratusek 2013-01-01 12:25:59 +01:00
parent 88a4b17e8e
commit adcecb89f5
2 changed files with 69 additions and 14 deletions

View File

@ -13,12 +13,15 @@ string CheckNewVersions()
{
string revs = "error";
char buffer[100];
#ifdef VWII
sprintf(buffer, "http://www.nanolx.org/hbf/DOL.vwii/revisions.vwii");
#ifdef STBOOTVWII
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL.st.vwii/revisions.st.vwii");
#elif VWII
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL.vwii/revisions.vwii");
#elif STBOOT
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL.st/revisions.st");
#else
sprintf(buffer, "http://www.nanolx.org/hbf/DOL/revisions");
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL/revisions");
#endif
struct block file = downloadfile(buffer);
if (file.data != NULL)
{
@ -31,10 +34,14 @@ string CheckNewVersions()
string NewVersionsText()
{
string text = "error";
#ifdef VWII
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL.vwii/updates.vwii");
#ifdef STBOOTVWII
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL.st.vwii/updates.st.vwii");
#elif VWII
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL.vwii/updates.vwii");
#elif STBOOT
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL.st/updates.st");
#else
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL/updates");
struct block file = downloadfile("http://www.nanolx.org/hbf/DOL/updates");
#endif
if (file.data != NULL)
{
@ -48,11 +55,22 @@ struct block file;
string new_update(string rev, string filename)
{
char url[100];
#ifdef VWII
#ifdef STBOOTVWII
if(rev == "Beta")
sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/Beta/%s", filename.c_str());
else
sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/rev%s/%s", rev.c_str(), filename.c_str());
#elif VWII
if(rev == "Beta")
sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/Beta/%s", filename.c_str());
else
sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/rev%s/%s", rev.c_str(), filename.c_str());
#elif STBOOT
if(rev == "Beta")
sprintf(url, "http://www.nanolx.org/hbf/DOL.st/Beta/%s", filename.c_str());
else
sprintf(url, "http://www.nanolx.org/hbf/DOL.st/rev%s/%s", rev.c_str(), filename.c_str());
#else
if(rev == "Beta")
sprintf(url, "http://www.nanolx.org/hbf/DOL/Beta/%s", filename.c_str());

View File

@ -102,22 +102,40 @@ updatePrompt(string rev)
ResumeGui();
char url[100];
#ifdef VWII
#ifdef STBOOTVWII
if(rev == "Beta")
sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/Beta/boot.dol");
else
sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/rev%s/boot.dol", rev.c_str());
// copy boot.dol to prev.dol
std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/boot.dol").c_str(), std::ios_base::binary);
std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/prev.dol").c_str(), std::ios_base::binary);
#elif VWII
if(rev == "Beta")
sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/Beta/boot.dol");
else
sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/rev%s/boot.dol", rev.c_str());
// copy boot.dol to prev.dol
// copy boot.dol to prev.dol
std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.vWii/boot.dol").c_str(), std::ios_base::binary);
std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.vWii/prev.dol").c_str(), std::ios_base::binary);
#elif STDBOOT
if(rev == "Beta")
sprintf(url, "http://www.nanolx.org/hbf/DOL.st/Beta/boot.dol");
else
sprintf(url, "http://www.nanolx.org/hbf/DOL.st/rev%s/boot.dol", rev.c_str());
// copy boot.dol to prev.dol
std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/boot.dol").c_str(), std::ios_base::binary);
std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/prev.dol").c_str(), std::ios_base::binary);
#else
if(rev == "Beta")
sprintf(url, "http://www.nanolx.org/hbf/DOL/Beta/boot.dol");
else
sprintf(url, "http://www.nanolx.org/hbf/DOL/rev%s/boot.dol", rev.c_str());
// copy boot.dol to prev.dol
// copy boot.dol to prev.dol
std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), std::ios_base::binary);
std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter/prev.dol").c_str(), std::ios_base::binary);
#endif
@ -127,8 +145,18 @@ updatePrompt(string rev)
struct block file = downloadfile(url);
if (file.data && file.size > 0)
{
#ifdef VWII
// write file
// write file
#ifdef STBOOTVWII
if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone").c_str()) == NULL)
mkdir((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone").c_str(), 0777);
FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/boot.dol").c_str(), "wb");
if(data)
{
fwrite(file.data, 1, file.size, data);
fclose(data);
}
#elif VWII
if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.vWii").c_str()) == NULL)
mkdir((Settings.device_dat + ":/apps/HomebrewFilter.vWii").c_str(), 0777);
@ -138,8 +166,17 @@ updatePrompt(string rev)
fwrite(file.data, 1, file.size, data);
fclose(data);
}
#elif STDBOOT
if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.Standalone").c_str()) == NULL)
mkdir((Settings.device_dat + ":/apps/HomebrewFilter.Standalone").c_str(), 0777);
FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/boot.dol").c_str(), "wb");
if(data)
{
fwrite(file.data, 1, file.size, data);
fclose(data);
}
#else
// write file
if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter").c_str()) == NULL)
mkdir((Settings.device_dat + ":/apps/HomebrewFilter").c_str(), 0777);