add WiiSD directory parsing

This commit is contained in:
dsbomb 2008-04-29 17:23:13 +00:00
parent e27b48d517
commit ed39cf2655
3 changed files with 84 additions and 32 deletions

View File

@ -67,7 +67,7 @@ extern int ChosenSlot;
extern bool isWii; extern bool isWii;
int UseSDCARD = 0; int UseSDCARD = 0;
int UseFrontSDCARD = 0; int UseWiiSDCARD = 0;
sd_file * filehandle = NULL; sd_file * filehandle = NULL;
char rootSDdir[SDCARD_MAX_PATH_LEN]; char rootSDdir[SDCARD_MAX_PATH_LEN];
char rootWiiSDdir[SDCARD_MAX_PATH_LEN]; char rootWiiSDdir[SDCARD_MAX_PATH_LEN];
@ -426,23 +426,21 @@ int parsedir() {
/*************************************************************************** /***************************************************************************
* Update SDCARD curent directory name * Update SDCARD curent directory name
***************************************************************************/ ***************************************************************************/
int updateSDdirname() int updateSDdirname() {
{
int size=0; int size=0;
char *test; char *test;
char temp[1024]; char temp[1024];
/* current directory doesn't change */ /* current directory doesn't change */
if (strcmp(filelist[selection].filename,".") == 0) return 0; if (strcmp(filelist[selection].filename,".") == 0)
return 0;
/* go up to parent directory */ /* go up to parent directory */
else if (strcmp(filelist[selection].filename,"..") == 0) if (strcmp(filelist[selection].filename,"..") == 0) {
{
/* determine last subdirectory namelength */ /* determine last subdirectory namelength */
sprintf(temp,"%s",rootSDdir); sprintf(temp,"%s",rootSDdir);
test= strtok(temp,"\\"); test = strtok(temp,"\\");
while (test != NULL) while (test != NULL) {
{
size = strlen(test); size = strlen(test);
test = strtok(NULL,"\\"); test = strtok(NULL,"\\");
} }
@ -453,32 +451,70 @@ int updateSDdirname()
/* handles root name */ /* handles root name */
//sprintf(tmpCompare, "dev%d:",ChosenSlot); //sprintf(tmpCompare, "dev%d:",ChosenSlot);
if (strcmp(rootSDdir, sdslot ? "dev1:":"dev0:") == 0)sprintf(rootSDdir,"dev%d:\\fceu\\..", sdslot); if (strcmp(rootSDdir, sdslot ? "dev1:":"dev0:") == 0)
sprintf(rootSDdir,"dev%d:\\%s\\..", sdslot, FCEUDIR);
return 1; return 1;
} } else {
else
{
/* test new directory namelength */ /* test new directory namelength */
if ((strlen(rootSDdir)+1+strlen(filelist[selection].filename)) < SDCARD_MAX_PATH_LEN) if ((strlen(rootSDdir)+1+strlen(filelist[selection].filename)) < SDCARD_MAX_PATH_LEN) {
{
/* handles root name */ /* handles root name */
//sprintf(tmpCompare, "dev%d:\\fceu\\..",ChosenSlot); sprintf(temp, "dev%d:\\%s\\..", sdslot, FCEUDIR);
//if (strcmp(rootSDdir, tmpCompare) == 0) sprintf(rootSDdir,"dev%d:",ChosenSlot); if (strcmp(rootSDdir, temp) == 0)
if (strcmp(rootSDdir, sdslot ? "dev1:\\fceu\\.." : "dev0:\\fceu\\..") == 0) sprintf(rootSDdir,"dev%d:",sdslot); sprintf(rootSDdir,"dev%d:",sdslot);
/* update current directory name */ /* update current directory name */
sprintf(rootSDdir, "%s\\%s",rootSDdir, filelist[selection].filename); sprintf(rootSDdir, "%s\\%s",rootSDdir, filelist[selection].filename);
return 1; return 1;
} } else {
else
{
WaitPrompt ("Dirname is too long !"); WaitPrompt ("Dirname is too long !");
return -1; return -1;
} }
} }
} }
#ifdef HW_RVL
/***************************************************************************
* * Update WiiSDCARD curent directory name
* ***************************************************************************/
int updateWiiSDdirname() {
int size=0;
char *test;
char temp[1024];
/* current directory doesn't change */
if (strcmp(filelist[selection].filename,".") == 0)
return 0;
/* go up to parent directory */
else if (strcmp(filelist[selection].filename,"..") == 0) {
/* determine last subdirectory namelength */
sprintf(temp,"%s",rootWiiSDdir);
test = strtok(temp,"/");
while (test != NULL) {
size = strlen(test);
test = strtok(NULL,"/");
}
/* remove last subdirectory name */
size = strlen(rootWiiSDdir) - size - 1;
rootWiiSDdir[size] = 0;
return 1;
} else {
/* test new directory namelength */
if ((strlen(rootWiiSDdir)+1+strlen(filelist[selection].filename)) < SDCARD_MAX_PATH_LEN) {
/* update current directory name */
sprintf(rootWiiSDdir, "%s/%s",rootWiiSDdir, filelist[selection].filename);
return 1;
} else {
WaitPrompt ((char*)"Dirname is too long !");
return -1;
}
}
}
#endif
/*************************************************************************** /***************************************************************************
* Browse SDCARD subdirectories * Browse SDCARD subdirectories
***************************************************************************/ ***************************************************************************/
@ -602,7 +638,7 @@ void ShowFiles( int offset, int selection ) {
char dir[1024]; char dir[1024];
if (UseSDCARD) if (UseSDCARD)
strcpy(dir, rootSDdir); strcpy(dir, rootSDdir);
else if (UseFrontSDCARD) else if (UseWiiSDCARD)
strcpy(dir, rootWiiSDdir); strcpy(dir, rootWiiSDdir);
else else
dir[0] = 0; dir[0] = 0;
@ -698,6 +734,22 @@ void FileSelector() {
haverom = 1; // quit SD menu haverom = 1; // quit SD menu
haveSDdir = 0; // reset everything at next access haveSDdir = 0; // reset everything at next access
} }
#ifdef HW_RVL
} else if (UseWiiSDCARD) {
/* update current directory and set new entry list if directory has changed */
int status = updateWiiSDdirname();
if (status == 1) {
maxfiles = parseWiiSDdirectory();
if (!maxfiles) {
WaitPrompt ((char*)"Error reading directory !");
haverom = 1; // quit SD menu
haveWiiSDdir = 0; // reset everything at next access
}
} else if (status == -1) {
haverom = 1; // quit SD menu
haveWiiSDdir = 0; // reset everything at next access
}
#endif
} else { } else {
rootdir = filelist[selection].offset; rootdir = filelist[selection].offset;
rootdirlength = filelist[selection].length; rootdirlength = filelist[selection].length;
@ -735,7 +787,7 @@ void FileSelector() {
} }
} else { } else {
#ifdef HW_RVL #ifdef HW_RVL
if (UseFrontSDCARD) { if (UseWiiSDCARD) {
strncpy(finfo.fname, filelist[selection].filename, 12); strncpy(finfo.fname, filelist[selection].filename, 12);
int l = strlen(finfo.fname); int l = strlen(finfo.fname);
if (l > 12) l = 12; if (l > 12) l = 12;
@ -768,7 +820,7 @@ int LoadDVDFile( unsigned char *buffer ) {
FIL fp; FIL fp;
u32 bytes_read = 0, bytes_read_total = 0; u32 bytes_read = 0, bytes_read_total = 0;
if(UseFrontSDCARD) { if(UseWiiSDCARD) {
ShowAction((char*)"Loading ... Wait"); ShowAction((char*)"Loading ... Wait");
char filename[1024]; char filename[1024];
sprintf(filename, "%s/%s", rootWiiSDdir, finfo.fname); sprintf(filename, "%s/%s", rootWiiSDdir, finfo.fname);
@ -907,8 +959,8 @@ int OpenDVD() {
} }
#ifdef HW_RVL #ifdef HW_RVL
int OpenFrontSD () { int OpenWiiSD () {
UseFrontSDCARD = 1; UseWiiSDCARD = 1;
UseSDCARD = 0; UseSDCARD = 0;
haveSDdir = 0; haveSDdir = 0;
char msg[128]; char msg[128];
@ -954,7 +1006,7 @@ int OpenFrontSD () {
int OpenSD () { int OpenSD () {
UseSDCARD = 1; UseSDCARD = 1;
UseFrontSDCARD = 0; UseWiiSDCARD = 0;
haveWiiSDdir = 0; haveWiiSDdir = 0;
char msg[128]; char msg[128];
@ -965,7 +1017,7 @@ int OpenSD () {
havedir = 0; havedir = 0;
/* Reset SDCARD root directory */ /* Reset SDCARD root directory */
sprintf(rootSDdir,"dev%d:\\fceu\\roms",ChosenSlot); sprintf(rootSDdir,"dev%d:\\%s\\%s", FCEUDIR, SAVEDIR, ChosenSlot);
sdslot = ChosenSlot; sdslot = ChosenSlot;
/* Parse initial root directory and get entries list */ /* Parse initial root directory and get entries list */
@ -980,7 +1032,7 @@ int OpenSD () {
haveSDdir = 1; haveSDdir = 1;
} else { } else {
/* no entries found */ /* no entries found */
sprintf (msg, "Error reading dev%d:\\fceu\\roms", ChosenSlot); sprintf (msg, "Error reading %s", rootSDdir);
WaitPrompt (msg); WaitPrompt (msg);
return 0; return 0;
} }

View File

@ -913,7 +913,7 @@ int MediaSelect() {
case MEDIA_SDCARD: case MEDIA_SDCARD:
#ifdef HW_RVL #ifdef HW_RVL
if (ChosenSlot == SLOT_WIISD) { if (ChosenSlot == SLOT_WIISD) {
OpenFrontSD(); OpenWiiSD();
} else } else
#endif #endif
OpenSD(); OpenSD();

View File

@ -10,7 +10,7 @@
#include "sz.h" #include "sz.h"
extern int UseSDCARD; extern int UseSDCARD;
extern int UseFrontSDCARD; extern int UseWiiSDCARD;
extern sd_file *filehandle; extern sd_file *filehandle;
// 7zip error list // 7zip error list
@ -70,7 +70,7 @@ int dvd_buffered_read(void *dst, u32 len, u64 offset) {
GetSDInfo(); GetSDInfo();
SDCARD_SeekFile(filehandle, offset, SDCARD_SEEK_SET); SDCARD_SeekFile(filehandle, offset, SDCARD_SEEK_SET);
SDCARD_ReadFile(filehandle, &dvdsf_buffer, len); SDCARD_ReadFile(filehandle, &dvdsf_buffer, len);
} else if (!UseFrontSDCARD) } else if (!UseWiiSDCARD)
ret = dvd_read(&dvdsf_buffer, len, offset); ret = dvd_read(&dvdsf_buffer, len, offset);
dvdsf_last_offset = offset; dvdsf_last_offset = offset;
dvdsf_last_length = len; dvdsf_last_length = len;