-added better check if DML game is already

installed
-added possibility to delete DML game
This commit is contained in:
fix94.1 2012-02-25 22:34:52 +00:00
parent cb478c4dd3
commit 714047d220
4 changed files with 66 additions and 8 deletions

View File

@ -1,5 +1,11 @@
#include <gccore.h>
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include "gc.h"
#include "gecko.h"
#define MAX_FAT_PATH 1024
#define SRAM_ENGLISH 0
#define SRAM_GERMAN 1
@ -86,4 +92,50 @@ void set_language(u8 lang)
__SYS_UnlockSram(1); // 1 -> write changes
while(!__SYS_SyncSram());
}
}
void DML_RemoveGame(const char *discid)
{
int num = 6;
const char *fl[6] = {"sd:/games/%s/game.iso","sd:/games/%s/sys/boot.bin","sd:/games/%s/sys/bi2.bin",
"sd:/games/%s/sys/apploader.img","sd:/games/%s/sys","sd:/games/%s"};
char fname[MAX_FAT_PATH];
FILE *f;
DIR *dir;
int i;
for(i = 0; i < num; i++)
{
sprintf(fname, fl[i], discid);
f = fopen((char*)fname, "r");
if(f)
{
gprintf("Deleting %s...\n",fname);
fclose(f);
remove(fname);
}
dir = opendir((char*)fname);
if(dir)
{
gprintf("Deleting %s...\n",fname);
closedir(dir);
unlink((char*)fname);
}
}
}
bool DML_GameIsInstalled(char *discid)
{
char filepath[64];
sprintf(filepath, "sd:/games/%s/game.iso", discid);
gprintf("Filepath on SD: %s\n", filepath);
FILE *f = fopen(filepath, "r");
if (f)
{
fclose(f);
return true;
}
gprintf("Not found\n");
return false;
}

View File

@ -7,6 +7,8 @@ extern "C"
#define GC_H_
void set_video_mode(int i);
void set_language(u8 lang);
void DML_RemoveGame(const char *discid);
bool DML_GameIsInstalled(char *discid);
#endif //GC_H_
#ifdef __cplusplus

View File

@ -512,7 +512,7 @@ void CMenu::_game(bool launch)
m_btnMgr.show(m_gameBtnSettings);
}
if (m_current_view == COVERFLOW_USB && !m_locked)
if ((m_current_view == COVERFLOW_USB || m_current_view == COVERFLOW_DML) && !m_locked)
m_btnMgr.show(m_gameBtnDelete);
}
else

View File

@ -3,6 +3,7 @@
#include "loader/wbfs.h"
#include "lockMutex.hpp"
#include "loader/gc_disc.hpp"
#include "gc.h"
using namespace std;
@ -178,7 +179,6 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
bool upd_usb = false;
bool upd_dml = false;
bool out = false;
bool del_cover = true;
struct AutoLight { AutoLight(void) { } ~AutoLight(void) { slotLight(false); } } aw;
string cfPos = m_cf.getNextId();
@ -258,7 +258,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
{
Disc_ReadGCHeader(&gcheader);
if (_searchGamesByID((const char *) gcheader.id).size() != 0)
char gcfolder[64];
sprintf(gcfolder, "%s [%s]", gcheader.title, (char *)gcheader.id);
if (_searchGamesByID((const char *) gcheader.id).size() != 0 || DML_GameIsInstalled((char *)gcheader.id) || DML_GameIsInstalled(gcfolder))
{
error(_t("wbfsoperr4", L"Game already installed"));
out = true;
@ -278,12 +280,14 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
error(_t("wbfsoperr3", L"This is not a Wii or GC disc!"));
out = true;
break;
}
}
break;
case CMenu::WO_REMOVE_GAME:
WBFS_RemoveGame((u8 *)m_cf.getId().c_str(), (char *) m_cf.getHdr()->path);
del_cover = m_cfg.getBool("GENERAL", "delete_cover_and_game", true);
if(del_cover)
if(m_current_view == COVERFLOW_USB)
WBFS_RemoveGame((u8 *)m_cf.getId().c_str(), (char *) m_cf.getHdr()->path);
else
DML_RemoveGame(m_cf.getHdr()->path);
if(m_cfg.getBool("GENERAL", "delete_cover_and_game", true))
RemoveCover((char *)m_cf.getId().c_str());
m_btnMgr.show(m_wbfsPBar);
m_btnMgr.setProgress(m_wbfsPBar, 0.f, true);