mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-27 05:34:15 +01:00
-added more accurate progress bar for copy
gc game from usb to sd -made the gc disc installer progress bar more accurate too ;) -deleting a gamecube game will now delete all files found in the directory, more accurate lol
This commit is contained in:
parent
83b8c5dcf7
commit
b23d86b5bc
@ -32,6 +32,7 @@ static u32 blockIdx = 0;
|
||||
static u32 blockInfo[2] = {0,0};
|
||||
static u32 blockReady = 0;
|
||||
static u32 stopThread;
|
||||
static u64 folderSize = 0;
|
||||
|
||||
// return false if the file doesn't exist
|
||||
bool fsop_GetFileSizeBytes (char *path, size_t *filesize) // for me stats st_size report always 0 :(
|
||||
@ -198,12 +199,6 @@ bool fsop_CopyFile (char *source, char *target, progress_callback_t spinner, voi
|
||||
usleep (5);
|
||||
|
||||
bytes = 0;
|
||||
bool spinnerFlag = false;
|
||||
if (strstr (source, "game.iso")) {
|
||||
spinner(bytes, size, spinner_data);
|
||||
spinnerFlag = true;
|
||||
}
|
||||
|
||||
u32 bi;
|
||||
do
|
||||
{
|
||||
@ -223,7 +218,8 @@ bool fsop_CopyFile (char *source, char *target, progress_callback_t spinner, voi
|
||||
if (rb == 0) err = 1;
|
||||
bytes += rb;
|
||||
|
||||
if (spinnerFlag) spinner(bytes, size, spinner_data);
|
||||
if (spinner)
|
||||
spinner(bytes, folderSize, spinner_data);
|
||||
}
|
||||
while (bytes < size && err == 0);
|
||||
|
||||
@ -295,10 +291,43 @@ static bool doCopyFolder (char *source, char *target, progress_callback_t spinne
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool fsop_CopyFolder (char *source, char *target, progress_callback_t spinner, void *spinner_data)
|
||||
{
|
||||
gprintf("DML game USB->SD job started!\n");
|
||||
|
||||
folderSize = fsop_GetFolderBytes(source);
|
||||
return doCopyFolder(source, target, spinner, spinner_data);
|
||||
}
|
||||
|
||||
void fsop_deleteFolder(char *source)
|
||||
{
|
||||
DIR *pdir;
|
||||
struct dirent *pent;
|
||||
char newSource[300];
|
||||
|
||||
pdir = opendir(source);
|
||||
|
||||
while ((pent=readdir(pdir)) != NULL)
|
||||
{
|
||||
// Skip it
|
||||
if (strcmp (pent->d_name, ".") == 0 || strcmp (pent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
sprintf (newSource, "%s/%s", source, pent->d_name);
|
||||
|
||||
// If it is a folder... recurse...
|
||||
if (fsop_DirExist(newSource))
|
||||
{
|
||||
fsop_deleteFolder(newSource);
|
||||
}
|
||||
else // It is a file !
|
||||
{
|
||||
gprintf("Deleting file: %s\n",newSource);
|
||||
remove(newSource);
|
||||
}
|
||||
}
|
||||
closedir(pdir);
|
||||
gprintf("Deleting directory: %s\n",source);
|
||||
unlink(source);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ u32 fsop_GetFreeSpaceKb (char *path);
|
||||
bool fsop_DirExist (char *path);
|
||||
bool fsop_CopyFile (char *source, char *target, progress_callback_t spinner, void *spinner_data);
|
||||
bool fsop_CopyFolder (char *source, char *target, progress_callback_t spinner, void *spinner_data);
|
||||
void fsop_deleteFolder(char *source);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "gecko.h"
|
||||
#include "fileOps.h"
|
||||
#include "utils.h"
|
||||
#include "defines.h"
|
||||
|
||||
#define SRAM_ENGLISH 0
|
||||
#define SRAM_GERMAN 1
|
||||
@ -94,48 +95,20 @@ void set_language(u8 lang)
|
||||
while(!__SYS_SyncSram());
|
||||
}
|
||||
|
||||
void DML_RemoveGame(const char *discid, const char* partition)
|
||||
{
|
||||
int num = 6;
|
||||
const char *fl[6] = {"%s:/games/%s/game.iso","%s:/games/%s/sys/boot.bin","%s:/games/%s/sys/bi2.bin",
|
||||
"%s:/games/%s/sys/apploader.img","%s:/games/%s/sys","%s:/games/%s"};
|
||||
char fname[MAX_FAT_PATH];
|
||||
FILE *f;
|
||||
DIR *dir;
|
||||
int i;
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
sprintf(fname, fl[i], partition, 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, const char* partition)
|
||||
{
|
||||
char filepath[MAX_FAT_PATH];
|
||||
sprintf(filepath, "%s:/games/%s/game.iso", partition, discid);
|
||||
char folder[12];
|
||||
char source[300];
|
||||
snprintf(folder, sizeof(folder), DML_DIR, partition);
|
||||
snprintf(source, sizeof(source), "%s/%s", folder, discid);
|
||||
|
||||
gprintf("Filepath on SD: %s\n", filepath);
|
||||
|
||||
FILE *f = fopen(filepath, "r");
|
||||
FILE *f = fopen(source, "r");
|
||||
if (f)
|
||||
{
|
||||
gprintf("Found on %s: %s\n", partition, source);
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
gprintf("Not found\n");
|
||||
gprintf("Not found on %s: %s\n", partition, source);
|
||||
return false;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ extern "C"
|
||||
#define GC_H_
|
||||
void set_video_mode(int i);
|
||||
void set_language(u8 lang);
|
||||
void DML_RemoveGame(const char *discid, const char* partition);
|
||||
bool DML_GameIsInstalled(char *discid, const char* partition);
|
||||
#endif //GC_H_
|
||||
|
||||
|
@ -273,6 +273,8 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo
|
||||
memset(ReadBuffer,0,toread);
|
||||
fwrite(ReadBuffer,1,toread,f);
|
||||
correction -= toread;
|
||||
if(spinner)
|
||||
spinner(wrote+toread, DiscSizeCalculated, spinner_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -370,7 +370,11 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
||||
}
|
||||
else
|
||||
{
|
||||
DML_RemoveGame(m_cf.getHdr()->path, DeviceName[currentPartition]);
|
||||
char folder[12];
|
||||
char source[300];
|
||||
snprintf(folder, sizeof(folder), DML_DIR, DeviceName[currentPartition]);
|
||||
snprintf(source, sizeof(source), "%s/%s", folder, m_cf.getHdr()->path);
|
||||
fsop_deleteFolder(source);
|
||||
upd_dml = true;
|
||||
}
|
||||
if(m_cfg.getBool("GENERAL", "delete_cover_and_game", true))
|
||||
|
Loading…
Reference in New Issue
Block a user