*Prepare source code for devkitPPC r23 - replaced removed directory functions

*Added additional sort mode - "Sort by number of players"
*Added support for multiple game partitions.

Note: You can activate multiple game partitions support in the Loader Settings. When it is active, all games from all partitions will be listed in the game list. Partitions can be mixed up as you wish wbfs/fat/ntfs/ext. When the multiple partitions feature is activated than the partition in "Game/Install Partition" setting is taken for new game installation. Also the free space amount will be shown from that game installation partition. This will be clickable in the future listing all partitions with their sizes.
This commit is contained in:
dimok321 2011-02-02 18:30:15 +00:00
parent 1d2854c777
commit 6f63f9cf05
42 changed files with 421 additions and 768 deletions

View File

@ -2,8 +2,8 @@
<app version="1"> <app version="1">
<name> USB Loader GX</name> <name> USB Loader GX</name>
<coder>USB Loader GX Team</coder> <coder>USB Loader GX Team</coder>
<version>2.0 r1059</version> <version>2.0 r1060</version>
<release_date>201101282120</release_date> <release_date>201101301622</release_date>
<no_ios_reload/> <no_ios_reload/>
<short_description>Loads games from USB-devices</short_description> <short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. <long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.

File diff suppressed because one or more lines are too long

View File

@ -169,8 +169,8 @@ void BoxCover::Draw()
GX_LoadPosMtxImm(modelView, GX_PNMTX0); GX_LoadPosMtxImm(modelView, GX_PNMTX0);
GX_InvalidateTexAll();
GX_LoadTexObj(&boxBorderTex, GX_TEXMAP0); GX_LoadTexObj(&boxBorderTex, GX_TEXMAP0);
GX_InvalidateTexAll();
//! Border quads //! Border quads
GX_SetArray(GX_VA_POS, (void *) &g_boxMeshQ[0].pos, sizeof(g_boxMeshQ[0])); GX_SetArray(GX_VA_POS, (void *) &g_boxMeshQ[0].pos, sizeof(g_boxMeshQ[0]));
@ -199,6 +199,7 @@ void BoxCover::Draw()
GX_End(); GX_End();
GX_LoadTexObj(flatCover ? &defaultBoxTex : &coverTex, GX_TEXMAP0); GX_LoadTexObj(flatCover ? &defaultBoxTex : &coverTex, GX_TEXMAP0);
GX_InvalidateTexAll();
//! Back Cover //! Back Cover
GX_SetArray(GX_VA_POS, (void *) &g_boxBackCoverMesh[0].pos, sizeof(g_boxBackCoverMesh[0])); GX_SetArray(GX_VA_POS, (void *) &g_boxBackCoverMesh[0].pos, sizeof(g_boxBackCoverMesh[0]));
@ -220,6 +221,7 @@ void BoxCover::Draw()
{ {
//! Front Flat Cover //! Front Flat Cover
GX_LoadTexObj(&coverTex, GX_TEXMAP0); GX_LoadTexObj(&coverTex, GX_TEXMAP0);
GX_InvalidateTexAll();
GX_SetArray(GX_VA_POS, (void *) &g_flatCoverMesh[0].pos, sizeof(g_flatCoverMesh[0])); GX_SetArray(GX_VA_POS, (void *) &g_flatCoverMesh[0].pos, sizeof(g_flatCoverMesh[0]));
GX_SetArray(GX_VA_TEX0, (void *) &g_flatCoverMesh[0].texCoord, sizeof(g_flatCoverMesh[0])); GX_SetArray(GX_VA_TEX0, (void *) &g_flatCoverMesh[0].texCoord, sizeof(g_flatCoverMesh[0]));

View File

@ -258,6 +258,7 @@ int DeviceHandler::GetUSBFilesystemType(int partition)
PartitionHandle * usbHandle = instance->GetUSBHandle(); PartitionHandle * usbHandle = instance->GetUSBHandle();
const char * FSName = usbHandle->GetFSName(partition); const char * FSName = usbHandle->GetFSName(partition);
if(!FSName) return -1;
if(strncmp(FSName, "WBFS", 4) == 0) if(strncmp(FSName, "WBFS", 4) == 0)
return PART_FS_WBFS; return PART_FS_WBFS;

View File

@ -43,94 +43,6 @@
static bool actioncanceled = false; static bool actioncanceled = false;
/****************************************************************************
* FindFile
*
* Check if file is available in the given directory
***************************************************************************/
extern "C" bool FindFile(const char * filename, const char * path)
{
if(!filename || ! path)
return false;
DIR_ITER *dir = NULL;
struct stat st;
char currfilename[MAXPATHLEN];
dir = diropen(path);
if(!dir)
{
dirclose(dir);
return false;
}
while (dirnext(dir,currfilename,&st) == 0)
{
if (strcasecmp(currfilename, filename) == 0)
{
dirclose(dir);
return true;
}
}
dirclose(dir);
return false;
}
/****************************************************************************
* SearchFile
*
* Search for a file recursive through all subdirectories
***************************************************************************/
extern "C" bool SearchFile(const char * searchpath, const char * searched_filename, char * outfilepath)
{
struct stat st;
DIR_ITER *dir = NULL;
bool result = false;
char filename[MAXPATHLEN];
char pathptr[strlen(searchpath)+2];
snprintf(pathptr, sizeof(pathptr), "%s", searchpath);
if(pathptr[strlen(pathptr)-1] == '/')
{
pathptr[strlen(pathptr)-1] = '\0';
}
char * notRoot = strrchr(pathptr, '/');
if(!notRoot)
{
strcat(pathptr, "/");
}
dir = diropen(pathptr);
if(!dir)
return false;
while (dirnext(dir,filename,&st) == 0 && result == false)
{
if(strcasecmp(filename, searched_filename) == 0)
{
if(outfilepath)
{
sprintf(outfilepath, "%s/%s", pathptr, filename);
}
result = true;
}
else if((st.st_mode & S_IFDIR) != 0)
{
if(strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0)
{
char newpath[1024];
snprintf(newpath, sizeof(newpath), "%s/%s", pathptr, filename);
result = SearchFile(newpath, searched_filename, outfilepath);
}
}
}
dirclose(dir);
return result;
}
/**************************************************************************** /****************************************************************************
* CheckFile * CheckFile
* *
@ -465,239 +377,6 @@ static inline void ClearList(std::vector<char *> &List)
std::vector<char *>().swap(List); std::vector<char *>().swap(List);
} }
/****************************************************************************
* CopyDirectory
*
* Copy recursive a complete source path to destination path
***************************************************************************/
extern "C" int CopyDirectory(const char * src, const char * dest)
{
struct stat st;
DIR_ITER *dir = NULL;
dir = diropen(src);
if(dir == NULL)
return -1;
char *filename = (char *) malloc(MAXPATHLEN);
if(!filename)
{
dirclose(dir);
return -2;
}
std::vector<char *> DirList;
std::vector<char *> FileList;
while (dirnext(dir,filename,&st) == 0)
{
if(actioncanceled)
{
free(filename);
ClearList(DirList);
ClearList(FileList);
dirclose(dir);
return -10;
}
if(st.st_mode & S_IFDIR)
{
if(strcmp(filename,".") != 0 && strcmp(filename,"..") != 0)
{
VectorResize(DirList);
DirList.push_back(strdup(filename));
}
}
else
{
VectorResize(FileList);
FileList.push_back(strdup(filename));
}
}
dirclose(dir);
free(filename);
filename = NULL;
//! Ensure that empty directories are created
CreateSubfolder(dest);
for(u32 i = 0; i < FileList.size(); ++i)
{
if(actioncanceled)
{
ClearList(DirList);
ClearList(FileList);
return -10;
}
if(FileList[i])
{
u32 strsize = strlen(src)+strlen(FileList[i])+1;
char currentname[strsize];
char destname[strsize];
sprintf(currentname, "%s%s", src, FileList[i]);
sprintf(destname, "%s%s", dest, FileList[i]);
free(FileList[i]);
FileList[i] = NULL;
CopyFile(currentname, destname);
}
}
FileList.clear();
ClearList(FileList);
for(u32 i = 0; i < DirList.size(); ++i)
{
if(actioncanceled)
{
ClearList(DirList);
ClearList(FileList);
return -10;
}
if(DirList[i])
{
u32 strsize = strlen(src)+strlen(DirList[i])+2;
char currentname[strsize];
char destname[strsize];
sprintf(currentname, "%s%s/", src, DirList[i]);
sprintf(destname, "%s%s/", dest, DirList[i]);
free(DirList[i]);
DirList[i] = NULL;
CopyDirectory(currentname, destname);
}
}
DirList.clear();
ClearList(DirList);
if(actioncanceled)
return -10;
return 1;
}
/****************************************************************************
* MoveDirectory
*
* Move recursive a complete source path to destination path
***************************************************************************/
extern "C" int MoveDirectory(char * src, const char * dest)
{
struct stat st;
DIR_ITER *dir = NULL;
dir = diropen(src);
if(dir == NULL)
return -1;
char *filename = (char *) malloc(MAXPATHLEN);
if(!filename)
{
dirclose(dir);
return -2;
}
std::vector<char *> DirList;
std::vector<char *> FileList;
while (dirnext(dir,filename,&st) == 0)
{
if(actioncanceled)
{
free(filename);
ClearList(DirList);
ClearList(FileList);
dirclose(dir);
return -10;
}
if(st.st_mode & S_IFDIR)
{
if(strcmp(filename,".") != 0 && strcmp(filename,"..") != 0)
{
VectorResize(DirList);
DirList.push_back(strdup(filename));
}
}
else
{
VectorResize(FileList);
FileList.push_back(strdup(filename));
}
}
dirclose(dir);
free(filename);
filename = NULL;
//! Ensure that empty directories are created
CreateSubfolder(dest);
for(u32 i = 0; i < FileList.size(); ++i)
{
if(actioncanceled)
{
ClearList(DirList);
ClearList(FileList);
return -10;
}
if(FileList[i])
{
u32 strsize = strlen(src)+strlen(FileList[i])+2;
char currentname[strsize];
char destname[strsize];
sprintf(currentname, "%s%s", src, FileList[i]);
sprintf(destname, "%s%s", dest, FileList[i]);
MoveFile(currentname, destname);
free(FileList[i]);
FileList[i] = NULL;
}
}
FileList.clear();
ClearList(FileList);
for(u32 i = 0; i < DirList.size(); ++i)
{
if(actioncanceled)
{
ClearList(DirList);
ClearList(FileList);
return -10;
}
if(DirList[i])
{
u32 strsize = strlen(src)+strlen(DirList[i])+2;
char currentname[strsize];
char destname[strsize];
sprintf(currentname, "%s%s/", src, DirList[i]);
sprintf(destname, "%s%s/", dest, DirList[i]);
free(DirList[i]);
DirList[i] = NULL;
MoveDirectory(currentname, destname);
}
}
DirList.clear();
ClearList(DirList);
src[strlen(src)-1] = '\0';
if(actioncanceled)
return -10;
if(remove(src) != 0)
return -1;
return 1;
}
/**************************************************************************** /****************************************************************************
* MoveFile * MoveFile
* *
@ -723,116 +402,6 @@ extern "C" int MoveFile(const char *srcpath, char *destdir)
return -1; return -1;
} }
/****************************************************************************
* RemoveDirectory
*
* Remove a directory and its content recursively
***************************************************************************/
extern "C" int RemoveDirectory(char * dirpath)
{
struct stat st;
DIR_ITER *dir = NULL;
dir = diropen(dirpath);
if(dir == NULL)
return -1;
char * filename = (char *) malloc(MAXPATHLEN);
if(!filename)
{
dirclose(dir);
return -2;
}
std::vector<char *> DirList;
std::vector<char *> FileList;
while (dirnext(dir,filename,&st) == 0)
{
if(actioncanceled)
{
free(filename);
ClearList(DirList);
ClearList(FileList);
dirclose(dir);
return -10;
}
if(st.st_mode & S_IFDIR)
{
if(strcmp(filename,".") != 0 && strcmp(filename,"..") != 0)
{
VectorResize(DirList);
DirList.push_back(strdup(filename));
}
}
else
{
VectorResize(FileList);
FileList.push_back(strdup(filename));
}
}
dirclose(dir);
free(filename);
filename = NULL;
for(u32 i = 0; i < FileList.size(); ++i)
{
if(actioncanceled)
{
ClearList(DirList);
ClearList(FileList);
return -10;
}
if(FileList[i])
{
u32 strsize = strlen(dirpath)+strlen(FileList[i])+2;
char fullpath[strsize];
sprintf(fullpath, "%s%s", dirpath, FileList[i]);
RemoveFile(fullpath);
//!Display Throbber rotating
free(FileList[i]);
FileList[i] = NULL;
}
}
FileList.clear();
ClearList(FileList);
for(u32 i = 0; i < DirList.size(); ++i)
{
if(actioncanceled)
{
ClearList(DirList);
ClearList(FileList);
return -10;
}
if(DirList[i])
{
char fullpath[strlen(dirpath)+strlen(DirList[i])+2];
sprintf(fullpath, "%s%s/", dirpath, DirList[i]);
free(DirList[i]);
DirList[i] = NULL;
RemoveDirectory(fullpath);
}
}
DirList.clear();
ClearList(DirList);
dirpath[strlen(dirpath)-1] = '\0';
if(actioncanceled)
return -10;
if(remove(dirpath) != 0)
return -1;
return 1;
}
/**************************************************************************** /****************************************************************************
* RemoveFile * RemoveFile
* *
@ -852,62 +421,3 @@ extern "C" bool RenameFile(const char * srcpath, const char * destpath)
{ {
return (rename(srcpath, destpath) == 0); return (rename(srcpath, destpath) == 0);
} }
/****************************************************************************
* GetFolderSize
*
* Get recursivly complete foldersize
***************************************************************************/
extern "C" void GetFolderSize(const char * folderpath, u64 * foldersize, u32 * filecount)
{
struct stat st;
DIR_ITER *dir = diropen(folderpath);
if(dir == NULL)
return;
char *filename = (char *) malloc(MAXPATHLEN);
if(!filename)
{
dirclose(dir);
return;
}
std::vector<char *> DirList;
while (dirnext(dir,filename,&st) == 0)
{
if(st.st_mode & S_IFDIR)
{
if(strcmp(filename,".") != 0 && strcmp(filename,"..") != 0)
{
VectorResize(DirList);
DirList.push_back(strdup(filename));
}
}
else
{
if(filecount) *filecount += 1;
if(foldersize) *foldersize += st.st_size;
}
}
dirclose(dir);
free(filename);
filename = NULL;
for(u32 i = 0; i < DirList.size(); ++i)
{
if(DirList[i])
{
char currentname[strlen(folderpath)+strlen(DirList[i])+2];
sprintf(currentname, "%s%s/", folderpath, DirList[i]);
free(DirList[i]);
DirList[i] = NULL;
GetFolderSize(currentname, foldersize, filecount);
}
}
DirList.clear();
ClearList(DirList);
}

View File

@ -35,20 +35,14 @@ extern "C" {
#endif #endif
bool CreateSubfolder(const char * fullpath); bool CreateSubfolder(const char * fullpath);
bool FindFile(const char * filename, const char * path);
bool SearchFile(const char * searchpath, const char * searched_filename, char * outfilepath);
bool CheckFile(const char * filepath); bool CheckFile(const char * filepath);
u64 FileSize(const char * filepath); u64 FileSize(const char * filepath);
int LoadFileToMem(const char * filepath, u8 **buffer, u64 *size); int LoadFileToMem(const char * filepath, u8 **buffer, u64 *size);
int LoadFileToMemWithProgress(const char *progressText, const char *filePath, u8 **buffer, u64 *size); int LoadFileToMemWithProgress(const char *progressText, const char *filePath, u8 **buffer, u64 *size);
int CopyFile(const char * src, const char * dest); int CopyFile(const char * src, const char * dest);
int CopyDirectory(const char * src, const char * dest);
int MoveDirectory(char * src, const char * dest);
int MoveFile(const char *srcpath, char *destdir); int MoveFile(const char *srcpath, char *destdir);
int RemoveDirectory(char * dirpath);
bool RenameFile(const char * srcpath, const char * destpath); bool RenameFile(const char * srcpath, const char * destpath);
bool RemoveFile(const char * filepath); bool RemoveFile(const char * filepath);
void GetFolderSize(const char * folderpath, u64 * foldersize, u32 * filenumber);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -4,7 +4,7 @@
* *
* Backgroundmusic * Backgroundmusic
***************************************************************************/ ***************************************************************************/
#include <sys/dir.h> #include <sys/dirent.h>
#include "themes/CTheme.h" #include "themes/CTheme.h"
#include "gui_bgm.h" #include "gui_bgm.h"
#include "menu.h" #include "menu.h"
@ -87,9 +87,9 @@ bool GuiBGM::ParsePath(const char * folderpath)
char * LoadedFilename = strrchr(folderpath, '/') + 1; char * LoadedFilename = strrchr(folderpath, '/') + 1;
char filename[1024]; char filename[1024];
struct stat st; struct dirent * dirent = NULL;
DIR_ITER * dir = diropen(currentPath); DIR * dir = opendir(currentPath);
if (dir == NULL) if (dir == NULL)
{ {
LoadStandard(); LoadStandard();
@ -97,24 +97,27 @@ bool GuiBGM::ParsePath(const char * folderpath)
} }
u32 counter = 0; u32 counter = 0;
while (dirnext(dir, filename, &st) == 0) while ((dirent = readdir(dir)) != 0)
{ {
snprintf(filename, sizeof(filename), dirent->d_name);
char * fileext = strrchr(filename, '.'); char * fileext = strrchr(filename, '.');
if (fileext) if (!fileext)
continue;
if (strcasecmp(fileext, ".mp3") == 0 || strcasecmp(fileext, ".ogg") == 0 ||
strcasecmp(fileext, ".wav") == 0 || strcasecmp(fileext, ".aif") == 0)
{ {
if (strcasecmp(fileext, ".mp3") == 0 || strcasecmp(fileext, ".ogg") == 0 || strcasecmp(fileext, ".wav") AddEntrie(filename);
== 0)
{
AddEntrie(filename);
if (strcmp(LoadedFilename, filename) == 0) currentPlaying = counter; if (strcmp(LoadedFilename, filename) == 0) currentPlaying = counter;
counter++; counter++;
}
} }
} }
dirclose(dir); closedir(dir);
snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s", folderpath); snprintf(Settings.ogg_path, sizeof(Settings.ogg_path), "%s", folderpath);

View File

@ -529,6 +529,9 @@ extern const u32 boxBorder_png_size;
extern const u8 nocoverFull_png[]; extern const u8 nocoverFull_png[];
extern const u32 nocoverFull_png_size; extern const u32 nocoverFull_png_size;
extern const u8 playersSort_png[];
extern const u32 playersSort_png_size;
extern const u8 stub_bin[]; extern const u8 stub_bin[];
extern const u32 stub_bin_size; extern const u32 stub_bin_size;

View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/dir.h> #include <sys/dirent.h>
#include "HomebrewFiles.h" #include "HomebrewFiles.h"
@ -37,17 +37,25 @@ HomebrewFiles::~HomebrewFiles()
bool HomebrewFiles::LoadPath(const char * folderpath) bool HomebrewFiles::LoadPath(const char * folderpath)
{ {
struct stat st; struct stat st;
DIR_ITER *dir = NULL; DIR *dir = NULL;
struct dirent *dirent = NULL;
char filename[1024]; char filename[1024];
dir = diropen(folderpath); dir = opendir(folderpath);
if (dir == NULL) if (dir == NULL)
{ {
return false; return false;
} }
while (dirnext(dir, filename, &st) == 0) while ((dirent = readdir(dir)) != 0)
{ {
snprintf(filename, 1024, "%s/%s", folderpath, dirent->d_name);
if(stat(filename, &st) != 0)
continue;
snprintf(filename, 1024, dirent->d_name);
if ((st.st_mode & S_IFDIR) != 0) if ((st.st_mode & S_IFDIR) != 0)
{ {
if (strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0) if (strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0)
@ -76,7 +84,7 @@ bool HomebrewFiles::LoadPath(const char * folderpath)
free(FileInfo); free(FileInfo);
FileInfo = NULL; FileInfo = NULL;
filecount = 0; filecount = 0;
dirclose(dir); closedir(dir);
return false; return false;
} }
@ -89,7 +97,7 @@ bool HomebrewFiles::LoadPath(const char * folderpath)
} }
} }
} }
dirclose(dir); closedir(dir);
return true; return true;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -82,6 +82,7 @@ GameBrowseMenu::GameBrowseMenu()
imgabcIcon = Resources::GetImageData("abcIcon.png"); imgabcIcon = Resources::GetImageData("abcIcon.png");
imgrankIcon = Resources::GetImageData("rankIcon.png"); imgrankIcon = Resources::GetImageData("rankIcon.png");
imgplayCountIcon = Resources::GetImageData("playCountIcon.png"); imgplayCountIcon = Resources::GetImageData("playCountIcon.png");
imgplayersSortIcon = Resources::GetImageData("playersSort.png");
imgarrangeGrid = Resources::GetImageData("arrangeGrid.png"); imgarrangeGrid = Resources::GetImageData("arrangeGrid.png");
imgarrangeGrid_gray = Resources::GetImageData("arrangeGrid_gray.png"); imgarrangeGrid_gray = Resources::GetImageData("arrangeGrid_gray.png");
imgarrangeList = Resources::GetImageData("arrangeList.png"); imgarrangeList = Resources::GetImageData("arrangeList.png");
@ -352,6 +353,7 @@ GameBrowseMenu::~GameBrowseMenu()
delete imgabcIcon; delete imgabcIcon;
delete imgrankIcon; delete imgrankIcon;
delete imgplayCountIcon; delete imgplayCountIcon;
delete imgplayersSortIcon;
delete imgarrangeGrid; delete imgarrangeGrid;
delete imgarrangeGrid_gray; delete imgarrangeGrid_gray;
delete imgarrangeCarousel; delete imgarrangeCarousel;
@ -514,6 +516,11 @@ void GameBrowseMenu::ReloadBrowser()
sortTTText = tr( "Sort order by most played"); sortTTText = tr( "Sort order by most played");
sortImgData = imgplayCountIcon; sortImgData = imgplayCountIcon;
} }
else if(Settings.GameSort & SORT_PLAYERS)
{
sortTTText = tr( "Sort by number of players");
sortImgData = imgplayersSortIcon;
}
else else
{ {
sortTTText = tr("Sort alphabetically"); sortTTText = tr("Sort alphabetically");
@ -913,6 +920,11 @@ int GameBrowseMenu::MainLoop()
else if(Settings.GameSort & SORT_PLAYCOUNT) else if(Settings.GameSort & SORT_PLAYCOUNT)
{ {
Settings.GameSort &= ~SORT_PLAYCOUNT; Settings.GameSort &= ~SORT_PLAYCOUNT;
Settings.GameSort |= SORT_PLAYERS;
}
else if(Settings.GameSort & SORT_PLAYERS)
{
Settings.GameSort &= ~SORT_PLAYERS;
Settings.GameSort |= SORT_ABC; Settings.GameSort |= SORT_ABC;
} }

View File

@ -62,6 +62,7 @@ class GameBrowseMenu : public GuiWindow
GuiImageData * imgabcIcon; GuiImageData * imgabcIcon;
GuiImageData * imgrankIcon; GuiImageData * imgrankIcon;
GuiImageData * imgplayCountIcon; GuiImageData * imgplayCountIcon;
GuiImageData * imgplayersSortIcon;
GuiImageData * imgarrangeGrid; GuiImageData * imgarrangeGrid;
GuiImageData * imgarrangeGrid_gray; GuiImageData * imgarrangeGrid_gray;
GuiImageData * imgarrangeCarousel; GuiImageData * imgarrangeCarousel;

View File

@ -14,7 +14,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <sys/dir.h> #include <sys/dirent.h>
#include <sys/iosupport.h> #include <sys/iosupport.h>
#include <malloc.h> #include <malloc.h>
#include <algorithm> #include <algorithm>
@ -80,9 +80,9 @@ int InitBrowsers()
if (strcmp(devoptab_list[i]->name, "stdnull") && devoptab_list[i]->write_r != NULL) if (strcmp(devoptab_list[i]->name, "stdnull") && devoptab_list[i]->write_r != NULL)
{ {
snprintf(rootdir, sizeof(rootdir), "%s:/", devoptab_list[i]->name); snprintf(rootdir, sizeof(rootdir), "%s:/", devoptab_list[i]->name);
if ( DIR_ITER *dir = diropen( rootdir ) ) if ( DIR *dir = opendir( rootdir ) )
{ {
dirclose(dir); closedir(dir);
BROWSERINFO browser; BROWSERINFO browser;
browser.dir[0] = '\0'; browser.dir[0] = '\0';
strcpy(browser.rootdir, rootdir); strcpy(browser.rootdir, rootdir);
@ -171,7 +171,7 @@ int ParseFilter(FILTERCASCADE *Filter, BROWSERENTRY* Entry)
**************************************************************************/ **************************************************************************/
int ParseDirectory(const char* Path, int Flags, FILTERCASCADE *Filter) int ParseDirectory(const char* Path, int Flags, FILTERCASCADE *Filter)
{ {
DIR_ITER *dir = NULL; DIR *dir = NULL;
char fulldir[MAXPATHLEN]; char fulldir[MAXPATHLEN];
char filename[MAXPATHLEN]; char filename[MAXPATHLEN];
struct stat filestat; struct stat filestat;
@ -233,18 +233,27 @@ int ParseDirectory(const char* Path, int Flags, FILTERCASCADE *Filter)
ResetBrowser(browser); ResetBrowser(browser);
// open the directory // open the directory
if ((dir = diropen(fulldir)) == NULL) if ((dir = opendir(fulldir)) == NULL)
{ {
if (Flags & FB_TRYROOTDIR) if (Flags & FB_TRYROOTDIR)
{ {
snprintf(fulldir, sizeof(fulldir), browser->rootdir);
browser->dir[0] = 0; browser->dir[0] = 0;
if ((dir = diropen(browser->rootdir)) == NULL) return -1; if ((dir = opendir(browser->rootdir)) == NULL) return -1;
} }
else return -1; else return -1;
} }
while (dirnext(dir, filename, &filestat) == 0) struct dirent *dirent = NULL;
while ((dirent = readdir(dir)) != 0)
{ {
snprintf(filename, sizeof(filename), "%s/%s", fulldir, dirent->d_name);
if(stat(filename, &filestat) != 0)
continue;
snprintf(filename, sizeof(filename), dirent->d_name);
if (strcmp(filename, ".") != 0) if (strcmp(filename, ".") != 0)
{ {
BROWSERENTRY newEntry; BROWSERENTRY newEntry;
@ -258,7 +267,7 @@ int ParseDirectory(const char* Path, int Flags, FILTERCASCADE *Filter)
} }
// close directory // close directory
dirclose(dir); closedir(dir);
// Sort the file list // Sort the file list
std::sort(browser->browserList.begin(), browser->browserList.end()); std::sort(browser->browserList.begin(), browser->browserList.end());

View File

@ -114,6 +114,7 @@ void CSettings::SetDefault()
InstallPartitions = ONLY_GAME_PARTITION; InstallPartitions = ONLY_GAME_PARTITION;
widescreen = (CONF_GetAspectRatio() == CONF_ASPECT_16_9); widescreen = (CONF_GetAspectRatio() == CONF_ASPECT_16_9);
HomeMenu = HOME_MENU_DEFAULT; HomeMenu = HOME_MENU_DEFAULT;
MultiplePartitions = OFF;
} }
bool CSettings::Load() bool CSettings::Load()
@ -255,6 +256,7 @@ bool CSettings::Save()
fprintf(file, "ParentalBlocks = %08X\n ", ParentalBlocks); fprintf(file, "ParentalBlocks = %08X\n ", ParentalBlocks);
fprintf(file, "returnTo = %s\n ", returnTo); fprintf(file, "returnTo = %s\n ", returnTo);
fprintf(file, "HomeMenu = %d\n ", HomeMenu); fprintf(file, "HomeMenu = %d\n ", HomeMenu);
fprintf(file, "MultiplePartitions = %d\n ", MultiplePartitions);
fclose(file); fclose(file);
return true; return true;
@ -457,6 +459,11 @@ bool CSettings::SetSetting(char *name, char *value)
if (sscanf(value, "%d", &i) == 1) HomeMenu = i; if (sscanf(value, "%d", &i) == 1) HomeMenu = i;
return true; return true;
} }
else if (strcmp(name, "MultiplePartitions") == 0)
{
if (sscanf(value, "%d", &i) == 1) MultiplePartitions = i;
return true;
}
else if (strcmp(name, "patchcountrystrings") == 0) else if (strcmp(name, "patchcountrystrings") == 0)
{ {
if (sscanf(value, "%d", &i) == 1) patchcountrystrings = i; if (sscanf(value, "%d", &i) == 1) patchcountrystrings = i;

View File

@ -111,6 +111,7 @@ class CSettings
short ShowFreeSpace; short ShowFreeSpace;
short UseIOS58; short UseIOS58;
short HomeMenu; short HomeMenu;
short MultiplePartitions;
u32 InstallPartitions; u32 InstallPartitions;
u32 ParentalBlocks; u32 ParentalBlocks;
protected: protected:

View File

@ -76,6 +76,21 @@ int CGameTitles::GetParentalRating(const char * id) const
return -1; return -1;
} }
int CGameTitles::GetPlayersCount(const char * id) const
{
if(!id)
return 1;
for(u32 i = 0; i < TitleList.size(); ++i)
{
if(strncasecmp(id, TitleList[i].GameID, 6) == 0)
return TitleList[i].PlayersCount;
}
return 1;
}
void CGameTitles::SetDefault() void CGameTitles::SetDefault()
{ {
TitleList.clear(); TitleList.clear();
@ -111,6 +126,7 @@ void CGameTitles::LoadTitlesFromWiiTDB(const char * path)
this->SetGameTitle(gameList[i]->id, Title.c_str()); this->SetGameTitle(gameList[i]->id, Title.c_str());
TitleList[TitleList.size()-1].ParentalRating = -1; TitleList[TitleList.size()-1].ParentalRating = -1;
TitleList[TitleList.size()-1].PlayersCount = 1;
Rating = XML_DB.GetRating((const char *) gameList[i]->id); Rating = XML_DB.GetRating((const char *) gameList[i]->id);
if(Rating < 0) if(Rating < 0)
@ -120,5 +136,8 @@ void CGameTitles::LoadTitlesFromWiiTDB(const char * path)
continue; continue;
TitleList[TitleList.size()-1].ParentalRating = ConvertRating(RatValTxt.c_str(), WiiTDB::RatingToString(Rating), "PEGI"); TitleList[TitleList.size()-1].ParentalRating = ConvertRating(RatValTxt.c_str(), WiiTDB::RatingToString(Rating), "PEGI");
int ret = XML_DB.GetPlayers((const char *) gameList[i]->id);
if(ret > 0)
TitleList[TitleList.size()-1].PlayersCount = ret;
} }
} }

View File

@ -11,6 +11,7 @@ typedef struct _GameTitle
char GameID[7]; char GameID[7];
std::string Title; std::string Title;
int ParentalRating; int ParentalRating;
int PlayersCount;
} GameTitle; } GameTitle;
@ -31,7 +32,8 @@ class CGameTitles
//! Get game parental rating //! Get game parental rating
int GetParentalRating(const char * id) const; int GetParentalRating(const char * id) const;
//! Get possible number of players for this game
int GetPlayersCount(const char * id) const;
//! Load Game Titles from WiiTDB //! Load Game Titles from WiiTDB
void LoadTitlesFromWiiTDB(const char * path); void LoadTitlesFromWiiTDB(const char * path);
//! Set default game titles //! Set default game titles

View File

@ -91,6 +91,7 @@ enum
SORT_PLAYCOUNT = 0x02, SORT_PLAYCOUNT = 0x02,
SORT_RANKING = 0x04, SORT_RANKING = 0x04,
SORT_FAVORITE = 0x08, SORT_FAVORITE = 0x08,
SORT_PLAYERS = 0x10,
}; };
enum enum
{ {

View File

@ -115,7 +115,8 @@ LoaderSettings::LoaderSettings()
Options->SetName(Idx++, "%s", tr( "Ocarina" )); Options->SetName(Idx++, "%s", tr( "Ocarina" ));
Options->SetName(Idx++, "%s", tr( "Use IOS58" )); Options->SetName(Idx++, "%s", tr( "Use IOS58" ));
Options->SetName(Idx++, "%s", tr( "Boot/Standard" )); Options->SetName(Idx++, "%s", tr( "Boot/Standard" ));
Options->SetName(Idx++, "%s", tr( "Partition" )); Options->SetName(Idx++, "%s", tr( "Game/Install Partition" ));
Options->SetName(Idx++, "%s", tr( "Multiple Partitions" ));
Options->SetName(Idx++, "%s", tr( "Install directories" )); Options->SetName(Idx++, "%s", tr( "Install directories" ));
Options->SetName(Idx++, "%s", tr( "Game Split Size" )); Options->SetName(Idx++, "%s", tr( "Game Split Size" ));
Options->SetName(Idx++, "%s", tr( "Quick Boot" )); Options->SetName(Idx++, "%s", tr( "Quick Boot" ));
@ -128,14 +129,20 @@ LoaderSettings::LoaderSettings()
SetOptionValues(); SetOptionValues();
OldSettingsPartition = Settings.partition; OldSettingsPartition = Settings.partition;
OldSettingsMultiplePartitions = Settings.MultiplePartitions;
} }
LoaderSettings::~LoaderSettings() LoaderSettings::~LoaderSettings()
{ {
//! if partition has changed, Reinitialize it //! if partition has changed, Reinitialize it
if (Settings.partition != OldSettingsPartition) if (Settings.partition != OldSettingsPartition ||
Settings.MultiplePartitions != OldSettingsMultiplePartitions)
{ {
WBFS_OpenPart(Settings.partition); WBFS_CloseAll();
if(Settings.MultiplePartitions)
WBFS_OpenAll();
else
WBFS_OpenPart(Settings.partition);
//! Reload the new game titles //! Reload the new game titles
gameList.ReadGameList(); gameList.ReadGameList();
@ -174,11 +181,14 @@ void LoaderSettings::SetOptionValues()
else else
Options->SetValue(Idx++, "********"); Options->SetValue(Idx++, "********");
//! Settings: Partition //! Settings: Game/Install Partition
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle(); PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
// Get the partition name and it's size in GB's // Get the partition name and it's size in GB's
Options->SetValue(Idx++, "%s (%.2fGB)", usbHandle->GetFSName(Settings.partition), usbHandle->GetSize(Settings.partition)/GB_SIZE); Options->SetValue(Idx++, "%s (%.2fGB)", usbHandle->GetFSName(Settings.partition), usbHandle->GetSize(Settings.partition)/GB_SIZE);
//! Settings: Multiple Partitions
Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.MultiplePartitions] ));
//! Settings: Install directories //! Settings: Install directories
Options->SetValue(Idx++, "%s", tr( InstallToText[Settings.InstallToDir] )); Options->SetValue(Idx++, "%s", tr( InstallToText[Settings.InstallToDir] ));
@ -287,7 +297,7 @@ int LoaderSettings::GetMenuInternal()
} }
} }
//! Settings: Partition //! Settings: Game/Install Partition
else if (ret == ++Idx) else if (ret == ++Idx)
{ {
if(DeviceHandler::Instance()->GetUSBHandle()->GetPartitionCount() < 2) if(DeviceHandler::Instance()->GetUSBHandle()->GetPartitionCount() < 2)
@ -308,6 +318,12 @@ int LoaderSettings::GetMenuInternal()
Settings.GameSplit = GAMESPLIT_4GB; Settings.GameSplit = GAMESPLIT_4GB;
} }
//! Settings: Multiple Partitions
else if (ret == ++Idx)
{
if (++Settings.MultiplePartitions >= MAX_ON_OFF) Settings.MultiplePartitions = 0;
}
//! Settings: Install directories //! Settings: Install directories
else if (ret == ++Idx) else if (ret == ++Idx)
{ {

View File

@ -37,6 +37,7 @@ class LoaderSettings : public SettingsMenu
int GetMenuInternal(); int GetMenuInternal();
int OldSettingsPartition; int OldSettingsPartition;
int OldSettingsMultiplePartitions;
OptionList GuiOptions; OptionList GuiOptions;
}; };

View File

@ -112,7 +112,7 @@ void AppCleanUp(void)
void ExitApp(void) void ExitApp(void)
{ {
AppCleanUp(); AppCleanUp();
WBFS_Close(); WBFS_CloseAll();
DeviceHandler::DestroyInstance(); DeviceHandler::DestroyInstance();
USB_Deinitialize(); USB_Deinitialize();
if(Settings.PlaylogUpdate) if(Settings.PlaylogUpdate)

View File

@ -89,7 +89,7 @@ s32 IosLoader::LoadGameCios(s32 ios)
s32 ret = -1; s32 ret = -1;
// Unmount fat before reloading IOS. // Unmount fat before reloading IOS.
WBFS_Close(); WBFS_CloseAll();
WDVD_Close(); WDVD_Close();
DeviceHandler::DestroyInstance(); DeviceHandler::DestroyInstance();

View File

@ -96,6 +96,7 @@ RecourceFile Resources::RecourceFiles[] =
{"abcIcon.png", abcIcon_png, abcIcon_png_size, NULL, 0}, {"abcIcon.png", abcIcon_png, abcIcon_png_size, NULL, 0},
{"rankIcon.png", rankIcon_png, rankIcon_png_size, NULL, 0}, {"rankIcon.png", rankIcon_png, rankIcon_png_size, NULL, 0},
{"playCountIcon.png", playCountIcon_png, playCountIcon_png_size, NULL, 0}, {"playCountIcon.png", playCountIcon_png, playCountIcon_png_size, NULL, 0},
{"playersSort.png", playersSort_png, playersSort_png_size, NULL, 0},
{"arrangeList.png", arrangeList_png, arrangeList_png_size, NULL, 0}, {"arrangeList.png", arrangeList_png, arrangeList_png_size, NULL, 0},
{"arrangeList_gray.png", arrangeList_gray_png, arrangeList_gray_png_size, NULL, 0}, {"arrangeList_gray.png", arrangeList_gray_png, arrangeList_gray_png_size, NULL, 0},
{"arrangeGrid.png", arrangeGrid_png, arrangeGrid_png_size, NULL, 0}, {"arrangeGrid.png", arrangeGrid_png, arrangeGrid_png_size, NULL, 0},

View File

@ -45,8 +45,6 @@ int defaultAltDol(const char *gameid)
if(defaultDolSelected) if(defaultDolSelected)
return defaultDolSelected; return defaultDolSelected;
gprintf("\nautoSelectDol() started");
char id[7]; char id[7];
snprintf(id, sizeof(id), gameid); snprintf(id, sizeof(id), gameid);

View File

@ -31,7 +31,6 @@
u32 AppEntrypoint = 0; u32 AppEntrypoint = 0;
struct discHdr *dvdheader = NULL; struct discHdr *dvdheader = NULL;
extern int wbfs_part_fs;
extern u32 hdd_sector_size; extern u32 hdd_sector_size;
extern int mountMethod; extern int mountMethod;
@ -103,8 +102,6 @@ int GameBooter::FindDiscHeader(const char * gameID, struct discHdr &gameHeader)
delete dvdheader; delete dvdheader;
dvdheader = NULL; dvdheader = NULL;
gameList.clear();
return 0; return 0;
} }
@ -136,7 +133,7 @@ int GameBooter::SetupDisc(u8 * gameID)
int ret = -1; int ret = -1;
if(((IosLoader::IsWaninkokoIOS() && IOS_GetRevision() < 18) || if(((IosLoader::IsWaninkokoIOS() && IOS_GetRevision() < 18) ||
hdd_sector_size != 512) && wbfs_part_fs == PART_FS_WBFS) hdd_sector_size != 512) && gameList.GetGameFS(gameID) == PART_FS_WBFS)
{ {
gprintf("Disc_SetUSB..."); gprintf("Disc_SetUSB...");
ret = Disc_SetUSB(gameID); ret = Disc_SetUSB(gameID);
@ -243,10 +240,13 @@ int GameBooter::BootGame(const char * gameID)
if (reloadblock == ON && IosLoader::IsHermesIOS()) if (reloadblock == ON && IosLoader::IsHermesIOS())
{ {
enable_ES_ioctlv_vector(); enable_ES_ioctlv_vector();
if (wbfs_part_fs == PART_FS_WBFS) if (gameList.GetGameFS(gameHeader.id) == PART_FS_WBFS)
mload_close(); mload_close();
} }
//! Now we can free up the memory used by the game list
gameList.clear();
//! Load main.dol or alternative dol into memory, start the game apploader and get game entrypoint //! Load main.dol or alternative dol into memory, start the game apploader and get game entrypoint
gprintf("\tDisc_wiiBoot\n"); gprintf("\tDisc_wiiBoot\n");
AppEntrypoint = BootPartition(Settings.dolpath, videoChoice, languageChoice, ocarinaChoice, viChoice, countrystrings, AppEntrypoint = BootPartition(Settings.dolpath, videoChoice, languageChoice, ocarinaChoice, viChoice, countrystrings,
@ -268,7 +268,7 @@ int GameBooter::BootGame(const char * gameID)
shadow_mload(); shadow_mload();
//! Flush all caches and close up all devices //! Flush all caches and close up all devices
WBFS_Close(); WBFS_CloseAll();
DeviceHandler::DestroyInstance(); DeviceHandler::DestroyInstance();
USB_Deinitialize(); USB_Deinitialize();

View File

@ -43,6 +43,7 @@ void GameList::clear()
GameFilter.clear(); GameFilter.clear();
AvailableSearchChars.clear(); AvailableSearchChars.clear();
FullGameList.clear(); FullGameList.clear();
GamePartitionList.clear();
FilteredList.clear(); FilteredList.clear();
//! Clear memory of the vector completely //! Clear memory of the vector completely
std::vector<struct discHdr *>().swap(FilteredList); std::vector<struct discHdr *>().swap(FilteredList);
@ -60,15 +61,41 @@ struct discHdr * GameList::GetDiscHeader(const char * gameID) const
return NULL; return NULL;
} }
int GameList::ReadGameList() int GameList::GetPartitionNumber(const u8 *gameID) const
{ {
// Clear list for (u32 i = 0; i < FullGameList.size(); ++i)
clear(); {
if(strncasecmp((const char *) gameID, (const char *) FullGameList[i].id, 6) == 0)
return GamePartitionList[i];
}
return -1;
}
void GameList::RemovePartition(int part)
{
wString filter(GameFilter);
for(u32 i = 0; i < GamePartitionList.size(); ++i)
{
if(GamePartitionList[i] == part)
{
FullGameList.erase(FullGameList.begin()+i);
GamePartitionList.erase(GamePartitionList.begin()+i);
--i;
}
}
if(FullGameList.size() > 0)
FilterList(filter.c_str());
}
int GameList::InternalReadList(int part)
{
// Retrieve all stuff from WBFS // Retrieve all stuff from WBFS
u32 cnt; u32 cnt = 0;
int ret = WBFS_GetCount(&cnt); int ret = WBFS_GetCount(part, &cnt);
if (ret < 0) return -1; if (ret < 0) return -1;
// We are done here if no games are there // We are done here if no games are there
@ -86,18 +113,52 @@ int GameList::ReadGameList()
memset(buffer, 0, len); memset(buffer, 0, len);
/* Get header list */ /* Get header list */
ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr)); ret = WBFS_GetHeaders(part, buffer, cnt, sizeof(struct discHdr));
if (ret < 0) if (ret < 0)
{ {
if (buffer) free(buffer); free(buffer);
return -1; return -1;
} }
FullGameList.resize(cnt); u32 oldSize = FullGameList.size();
memcpy(&FullGameList[0], buffer, len);
FullGameList.resize(oldSize+cnt);
memcpy(&FullGameList[oldSize], buffer, len);
free(buffer); free(buffer);
GamePartitionList.resize(oldSize+cnt);
for(u32 i = oldSize; i < GamePartitionList.size(); ++i)
GamePartitionList[i] = part;
return cnt;
}
int GameList::ReadGameList()
{
// Clear list
clear();
if(!Settings.MultiplePartitions)
{
int ret = InternalReadList(Settings.partition);
if(ret <= 0) return ret;
}
else
{
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
int cnt = 0;
for(int part = 0; part < usbHandle->GetPartitionCount(); ++part)
{
int ret = InternalReadList(part);
if(ret > 0) cnt += ret;
}
if(!cnt) return cnt;
}
return LoadUnfiltered(); return LoadUnfiltered();
} }
@ -253,6 +314,10 @@ void GameList::SortList()
{ {
std::sort(FilteredList.begin(), FilteredList.end(), RankingSortCallback); std::sort(FilteredList.begin(), FilteredList.end(), RankingSortCallback);
} }
else if(Settings.GameSort & SORT_PLAYERS)
{
std::sort(FilteredList.begin(), FilteredList.end(), PlayersSortCallback);
}
else else
{ {
std::sort(FilteredList.begin(), FilteredList.end(), NameSortCallback); std::sort(FilteredList.begin(), FilteredList.end(), NameSortCallback);
@ -287,3 +352,13 @@ bool GameList::RankingSortCallback(const struct discHdr *a, const struct discHdr
return (fav1 > fav2); return (fav1 > fav2);
} }
bool GameList::PlayersSortCallback(const struct discHdr *a, const struct discHdr *b)
{
int count1 = GameTitles.GetPlayersCount((const char *) a->id);
int count2 = GameTitles.GetPlayersCount((const char *) b->id);
if (count1 == count2) return NameSortCallback(a, b);
return (count1 > count2);
}

View File

@ -2,6 +2,7 @@
#define GAME_LIST_H_ #define GAME_LIST_H_
#include <vector> #include <vector>
#include "Controls/DeviceHandler.hpp"
#include "wstring.hpp" #include "wstring.hpp"
#include "usbloader/disc.h" #include "usbloader/disc.h"
@ -30,17 +31,22 @@ class GameList
int operator++(int i) { return operator++(); } int operator++(int i) { return operator++(); }
int operator--(int i) { return operator--(); } int operator--(int i) { return operator--(); }
struct discHdr * GetCurrentSelected() const { return operator[](selectedGame); } struct discHdr * GetCurrentSelected() const { return operator[](selectedGame); }
int GetPartitionNumber(const u8 *gameid) const;
int GetGameFS(const u8 *gameID) const { return DeviceHandler::Instance()->GetUSBFilesystemType(GetPartitionNumber(gameID)); }
void RemovePartition(int part_num);
protected: protected:
int InternalReadList(int part);
static bool NameSortCallback(const struct discHdr *a, const struct discHdr *b); static bool NameSortCallback(const struct discHdr *a, const struct discHdr *b);
static bool PlaycountSortCallback(const struct discHdr *a, const struct discHdr *b); static bool PlaycountSortCallback(const struct discHdr *a, const struct discHdr *b);
static bool RankingSortCallback(const struct discHdr *a, const struct discHdr *b); static bool RankingSortCallback(const struct discHdr *a, const struct discHdr *b);
static bool PlayersSortCallback(const struct discHdr *a, const struct discHdr *b);
wString AvailableSearchChars; wString AvailableSearchChars;
wString GameFilter; wString GameFilter;
int selectedGame; int selectedGame;
std::vector<struct discHdr *> FilteredList; std::vector<struct discHdr *> FilteredList;
std::vector<struct discHdr> FullGameList; std::vector<struct discHdr> FullGameList;
std::vector<int> GamePartitionList;
}; };
extern GameList gameList; extern GameList gameList;

View File

@ -47,7 +47,7 @@ static int FindGamePartition()
u32 count; u32 count;
// Get the game count... // Get the game count...
WBFS_GetCount(&count); WBFS_GetCount(i, &count);
if (count > 0) if (count > 0)
{ {
@ -55,7 +55,7 @@ static int FindGamePartition()
return 0; return 0;
} }
WBFS_Close(); WBFS_Close(i);
} }
return -1; return -1;
@ -119,7 +119,12 @@ int MountGamePartition(bool ShowGUI)
Sys_LoadMenu(); Sys_LoadMenu();
} }
s32 ret = WBFS_OpenPart(Settings.partition); s32 ret = -1;
if(Settings.MultiplePartitions)
ret = WBFS_OpenAll();
else
WBFS_OpenPart(Settings.partition);
if(ret < 0) if(ret < 0)
ret = FindGamePartition(); ret = FindGamePartition();
@ -138,7 +143,7 @@ int MountGamePartition(bool ShowGUI)
Sys_LoadMenu(); Sys_LoadMenu();
} }
gprintf("\tOpenXMLDatabase\n"); gprintf("LoadTitlesFromWiiTDB\n");
GameTitles.LoadTitlesFromWiiTDB(Settings.titlestxt_path); GameTitles.LoadTitlesFromWiiTDB(Settings.titlestxt_path);

View File

@ -18,9 +18,6 @@
#define SAFE_FREE(x) if(x) { free(x); x = NULL; } #define SAFE_FREE(x) if(x) { free(x); x = NULL; }
extern sec_t ntfs_wbfs_sec;
extern sec_t ext_wbfs_sec;
static FragList *frag_list = NULL; static FragList *frag_list = NULL;
void frag_init(FragList *ff, int maxnum) void frag_init(FragList *ff, int maxnum)
@ -167,7 +164,7 @@ int frag_remap(FragList *ff, FragList *log, FragList *phy)
return 0; return 0;
} }
int get_frag_list_for_file(char *fname, u8 *id) int get_frag_list_for_file(char *fname, u8 *id, u8 wbfs_part_fs, u32 lba_offset)
{ {
char fname1[1024]; char fname1[1024];
struct stat st; struct stat st;
@ -212,7 +209,7 @@ int get_frag_list_for_file(char *fname, u8 *id)
} }
// offset to start of partition // offset to start of partition
for (j=0; j<fs->num; j++) { for (j=0; j<fs->num; j++) {
fs->frag[j].sector += ntfs_wbfs_sec; fs->frag[j].sector += lba_offset;
} }
} else if (wbfs_part_fs == PART_FS_EXT) { } else if (wbfs_part_fs == PART_FS_EXT) {
ret = _EXT2_get_fragments(fname, &_frag_append, fs); ret = _EXT2_get_fragments(fname, &_frag_append, fs);
@ -222,7 +219,7 @@ int get_frag_list_for_file(char *fname, u8 *id)
} }
// offset to start of partition // offset to start of partition
for (j=0; j<fs->num; j++) { for (j=0; j<fs->num; j++) {
fs->frag[j].sector += ext_wbfs_sec; fs->frag[j].sector += lba_offset;
} }
} else if (wbfs_part_fs == PART_FS_WBFS) { } else if (wbfs_part_fs == PART_FS_WBFS) {
// if wbfs file format, remap. // if wbfs file format, remap.
@ -288,7 +285,7 @@ int set_frag_list(u8 *id)
frag_list = NULL; frag_list = NULL;
gprintf("Calling WDVD_SetFragList, frag list size %d\n", size); gprintf("Calling WDVD_SetFragList, frag list size %d\n", size);
int ret = WDVD_SetFragList(wbfsDev, FragListAligned, size); int ret = WDVD_SetFragList(WBFS_MIN_DEVICE, FragListAligned, size);
free(FragListAligned); free(FragListAligned);
if (ret) if (ret)

View File

@ -40,7 +40,7 @@ int frag_get(FragList *ff, u32 offset, u32 count, u32 *poffset, u32 *psector, u3
int frag_remap(FragList *ff, FragList *log, FragList *phy); int frag_remap(FragList *ff, FragList *log, FragList *phy);
int get_frag_list_for_file(char *fname, u8 *id); int get_frag_list_for_file(char *fname, u8 *id, u8 fstype, u32 sec_offset);
int get_frag_list(u8 *id); int get_frag_list(u8 *id);
int set_frag_list(u8 *id); int set_frag_list(u8 *id);

View File

@ -1,3 +1,4 @@
#include <vector>
#include <ogcsys.h> #include <ogcsys.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
@ -15,23 +16,31 @@
#include "menu/menus.h" #include "menu/menus.h"
#include "gecko.h" #include "gecko.h"
static Wbfs *current = NULL; #define VALID(x) (x >= 0 && x < (int) WbfsList.size() && WbfsList[x] != NULL)
/* WBFS device */
s32 wbfsDev = WBFS_MIN_DEVICE; static std::vector<Wbfs *> WbfsList;
wbfs_disc_t* WBFS_OpenDisc(u8 *discid) wbfs_disc_t* WBFS_OpenDisc(u8 *discid)
{ {
return current->OpenDisc(discid); int part = gameList.GetPartitionNumber(discid);
if(VALID(part))
return WbfsList[part]->OpenDisc(discid);
return NULL;
} }
void WBFS_CloseDisc(wbfs_disc_t *disc) void WBFS_CloseDisc(wbfs_disc_t *disc)
{ {
current->CloseDisc(disc); if(!disc) return;
}
wbfs_t *GetHddInfo(void) for(u32 i = 0; i < WbfsList.size(); ++i)
{ {
return current->GetHddInfo(); if(WbfsList[i]->GetHDDHandle() == disc->p)
{
WbfsList[i]->CloseDisc(disc);
break;
}
}
} }
s32 WBFS_Init(u32 device) s32 WBFS_Init(u32 device)
@ -39,6 +48,21 @@ s32 WBFS_Init(u32 device)
return Wbfs::Init(device); return Wbfs::Init(device);
} }
s32 WBFS_OpenAll()
{
int ret = -1;
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
for(int i = 0; i < usbHandle->GetPartitionCount(); ++i)
{
if(WBFS_OpenPart(i) == 0)
ret = 0;
}
return ret;
}
s32 WBFS_OpenPart(int part_num) s32 WBFS_OpenPart(int part_num)
{ {
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle(); PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
@ -46,137 +70,163 @@ s32 WBFS_OpenPart(int part_num)
return -1; return -1;
// close // close
WBFS_Close(); WBFS_Close(part_num);
if(part_num <= (int) WbfsList.size())
WbfsList.resize(part_num+1);
gprintf("\tWBFS_OpenPart: start sector %u, sector count: %u\n", usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num)); gprintf("\tWBFS_OpenPart: start sector %u, sector count: %u\n", usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
if (strncmp(usbHandle->GetFSName(part_num), "FAT", 3) == 0) if (strncmp(usbHandle->GetFSName(part_num), "FAT", 3) == 0)
{ {
current = new Wbfs_Fat(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num)); WbfsList[part_num] = new Wbfs_Fat(WBFS_MIN_DEVICE, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
} }
else if (strncmp(usbHandle->GetFSName(part_num), "NTFS", 4) == 0) else if (strncmp(usbHandle->GetFSName(part_num), "NTFS", 4) == 0)
{ {
current = new Wbfs_Ntfs(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num)); WbfsList[part_num] = new Wbfs_Ntfs(WBFS_MIN_DEVICE, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
} }
else if (strncmp(usbHandle->GetFSName(part_num), "LINUX", 5) == 0) else if (strncmp(usbHandle->GetFSName(part_num), "LINUX", 5) == 0)
{ {
current = new Wbfs_Ext(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num)); WbfsList[part_num] = new Wbfs_Ext(WBFS_MIN_DEVICE, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
} }
else if (strncmp(usbHandle->GetFSName(part_num), "WBFS", 4) == 0) else if (strncmp(usbHandle->GetFSName(part_num), "WBFS", 4) == 0)
{ {
current = new Wbfs_Wbfs(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num)); WbfsList[part_num] = new Wbfs_Wbfs(WBFS_MIN_DEVICE, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
} }
else else
{ {
return -1; return -1;
} }
if (current->Open()) if (WbfsList[part_num]->Open() != 0)
{ {
delete current; delete WbfsList[part_num];
current = NULL; WbfsList[part_num] = NULL;
return -1; return -1;
} }
return 0; return 0;
} }
bool WBFS_Close(void) bool WBFS_Close(int part_num)
{ {
if (current != NULL) if(!VALID(part_num))
{ return false;
current->Close();
delete current;
current = NULL;
}
gameList.clear(); WbfsList[part_num]->Close();
delete WbfsList[part_num];
WbfsList[part_num] = NULL;
return 0; gameList.RemovePartition(part_num);
return true;
} }
bool WBFS_Mounted() void WBFS_CloseAll()
{ {
return (current != NULL && current->IsMounted()); for(u32 i = 0; i < WbfsList.size(); ++i)
WBFS_Close(i);
} }
s32 WBFS_Format(u32 lba, u32 size) s32 WBFS_Format(u32 lba, u32 size)
{ {
Wbfs_Wbfs Part(wbfsDev, lba, size); Wbfs_Wbfs Part(WBFS_MIN_DEVICE, lba, size);
return Part.Format(); return Part.Format();
} }
s32 WBFS_GetCount(u32 *count) s32 WBFS_GetCount(int part_num, u32 *count)
{ {
return current->GetCount(count); if(!VALID(part_num))
return -1;
return WbfsList[part_num]->GetCount(count);
} }
s32 WBFS_GetHeaders(struct discHdr *outbuf, u32 cnt, u32 len) s32 WBFS_GetHeaders(int part_num, struct discHdr *outbuf, u32 cnt, u32 len)
{ {
return current->GetHeaders(outbuf, cnt, len); if(!VALID(part_num))
return -1;
return WbfsList[part_num]->GetHeaders(outbuf, cnt, len);
} }
s32 WBFS_CheckGame(u8 *discid) s32 WBFS_CheckGame(u8 *discid)
{ {
return current->CheckGame(discid); int part_num = gameList.GetPartitionNumber(discid);
if(!VALID(part_num))
return -1;
return WbfsList[part_num]->CheckGame(discid);
} }
s32 WBFS_AddGame(void) s32 WBFS_AddGame(void)
{ {
s32 retval = current->AddGame(); if(!VALID(Settings.partition))
if (retval == 0) gameList.clear(); return -1;
return retval; return WbfsList[Settings.partition]->AddGame();
} }
s32 WBFS_RemoveGame(u8 *discid) s32 WBFS_RemoveGame(u8 *discid)
{ {
s32 retval = current->RemoveGame(discid); int part_num = gameList.GetPartitionNumber(discid);
if (retval == 0) gameList.clear(); if(!VALID(part_num))
return -1;
return retval; return WbfsList[part_num]->RemoveGame(discid);
} }
s32 WBFS_GameSize(u8 *discid, f32 *size) s32 WBFS_GameSize(u8 *discid, f32 *size)
{ {
return current->GameSize(discid, size); int part_num = gameList.GetPartitionNumber(discid);
if(!VALID(part_num))
return -1;
return WbfsList[part_num]->GameSize(discid, size);
} }
s32 WBFS_DiskSpace(f32 *used, f32 *free) s32 WBFS_DiskSpace(f32 *used, f32 *free)
{ {
return current->DiskSpace(used, free); if(!VALID(Settings.partition))
return -1;
return WbfsList[Settings.partition]->DiskSpace(used, free);
} }
s32 WBFS_RenameGame(u8 *discid, const void *newname) s32 WBFS_RenameGame(u8 *discid, const void *newname)
{ {
s32 retval = current->RenameGame(discid, newname); int part_num = gameList.GetPartitionNumber(discid);
if (retval == 0) gameList.clear(); if(!VALID(part_num))
return -1;
return retval; return WbfsList[part_num]->RenameGame(discid, newname);
} }
s32 WBFS_ReIDGame(u8 *discid, const void *newID) s32 WBFS_ReIDGame(u8 *discid, const void *newID)
{ {
s32 retval = current->ReIDGame(discid, newID); int part_num = gameList.GetPartitionNumber(discid);
if (retval == 0) gameList.clear(); if(!VALID(part_num))
return -1;
return retval; return WbfsList[part_num]->ReIDGame(discid, newID);
} }
u64 WBFS_EstimeGameSize(void) u64 WBFS_EstimeGameSize(void)
{ {
return current->EstimateGameSize(); if(!VALID(Settings.partition))
return 0;
return WbfsList[Settings.partition]->EstimateGameSize();
} }
int WBFS_GetFragList(u8 *id) int WBFS_GetFragList(u8 *id)
{ {
return current->GetFragList(id); int part_num = gameList.GetPartitionNumber(id);
} if(!VALID(part_num))
return -1;
bool WBFS_ShowFreeSpace(void) return WbfsList[part_num]->GetFragList(id);
{
return current->ShowFreeSpace();
} }
int MountWBFS(bool ShowGUI) int MountWBFS(bool ShowGUI)

View File

@ -18,32 +18,28 @@ extern "C"
#define WBFS_MIN_DEVICE 1 #define WBFS_MIN_DEVICE 1
#define WBFS_MAX_DEVICE 2 #define WBFS_MAX_DEVICE 2
extern int wbfs_part_fs;
extern s32 wbfsDev;
/* Prototypes */ /* Prototypes */
s32 WBFS_Init(u32); s32 WBFS_Init(u32 device);
s32 WBFS_Format(u32, u32); s32 WBFS_Format(u32 lba, u32 size);
s32 WBFS_GetCount(u32 *); s32 WBFS_GetCount(int part, u32 *count);
s32 WBFS_GetHeaders(struct discHdr *, u32, u32); s32 WBFS_GetHeaders(int part, struct discHdr *, u32, u32);
wbfs_t *GetHddInfo(void); s32 WBFS_CheckGame(u8 *gameid);
s32 WBFS_CheckGame(u8 *);
s32 WBFS_AddGame(void); s32 WBFS_AddGame(void);
s32 WBFS_RemoveGame(u8 *); s32 WBFS_RemoveGame(u8 *gameid);
s32 WBFS_GameSize(u8 *, f32 *); s32 WBFS_GameSize(u8 *gameid, f32 *size);
bool WBFS_ShowFreeSpace(void); s32 WBFS_DiskSpace(f32 *used, f32 *free);
s32 WBFS_DiskSpace(f32 *, f32 *); s32 WBFS_RenameGame(u8 *gameid, const void *newname);
s32 WBFS_RenameGame(u8 *, const void *);
s32 WBFS_ReIDGame(u8 *discid, const void *newID); s32 WBFS_ReIDGame(u8 *discid, const void *newID);
u64 WBFS_EstimeGameSize(void); u64 WBFS_EstimeGameSize(void);
int WBFS_GetFragList(u8 *id); int WBFS_GetFragList(u8 *id);
s32 WBFS_OpenAll();
s32 WBFS_OpenPart(int part_num); s32 WBFS_OpenPart(int part_num);
wbfs_disc_t* WBFS_OpenDisc(u8 *discid); wbfs_disc_t* WBFS_OpenDisc(u8 *discid);
void WBFS_CloseDisc(wbfs_disc_t *disc); void WBFS_CloseDisc(wbfs_disc_t *disc);
bool WBFS_Close(); bool WBFS_Close(int part);
bool WBFS_Mounted(); void WBFS_CloseAll();
bool WBFS_Selected(); bool WBFS_Selected();
int MountWBFS(bool ShowGUI); int MountWBFS(bool ShowGUI);

View File

@ -7,26 +7,14 @@
#include "Controls/DeviceHandler.hpp" #include "Controls/DeviceHandler.hpp"
#include "usbloader/sdhc.h" #include "usbloader/sdhc.h"
#include "usbloader/usbstorage2.h" #include "usbloader/usbstorage2.h"
#include "usbloader/wbfs.h"
#include "wbfs_rw.h" #include "wbfs_rw.h"
#include "wbfs_base.h" #include "wbfs_base.h"
s32 Wbfs::done = -1; Wbfs::Wbfs(u32 dev, u32 l, u32 s)
s32 Wbfs::total = -1; : hdd(NULL), device(dev), lba(l), size(s)
u32 Wbfs::nb_sectors;
Wbfs::Wbfs(u32 device, u32 lba, u32 size) :
hdd(NULL)
{ {
this->device = device;
this->lba = lba;
this->size = size;
}
void Wbfs::GetProgressValue(s32 * d, s32 * m)
{
*d = done;
*m = total;
} }
s32 Wbfs::Init(u32 device) s32 Wbfs::Init(u32 device)
@ -58,9 +46,6 @@ s32 Wbfs::Init(u32 device)
/* Setup callbacks */ /* Setup callbacks */
readCallback = __ReadSDHC; readCallback = __ReadSDHC;
writeCallback = __WriteSDHC; writeCallback = __WriteSDHC;
/* Device info */
nb_sectors = 0;
} }
else return -1; else return -1;
break; break;
@ -114,11 +99,6 @@ s32 Wbfs::GameSize(u8 *discid, f32 *size)
return 0; return 0;
} }
wbfs_t *Wbfs::GetHddInfo()
{
return hdd;
}
bool Wbfs::ShowFreeSpace(void) bool Wbfs::ShowFreeSpace(void)
{ {
return true; return true;

View File

@ -13,11 +13,9 @@ class Wbfs
public: public:
Wbfs(u32, u32, u32); Wbfs(u32, u32, u32);
void GetProgressValue(s32 * d, s32 * m);
static s32 Init(u32); static s32 Init(u32);
s32 CheckGame(u8 *); s32 CheckGame(u8 *);
s32 GameSize(u8 *, f32 *); s32 GameSize(u8 *, f32 *);
wbfs_t *GetHddInfo(void);
bool IsMounted() { return hdd == 0; }; bool IsMounted() { return hdd == 0; };
virtual int GetFragList(u8 *id) { return 0; }; virtual int GetFragList(u8 *id) { return 0; };
virtual bool ShowFreeSpace(void); virtual bool ShowFreeSpace(void);
@ -35,13 +33,12 @@ class Wbfs
virtual s32 RenameGame(u8 *, const void *) = 0; virtual s32 RenameGame(u8 *, const void *) = 0;
virtual s32 ReIDGame(u8 *discid, const void *newID) = 0; virtual s32 ReIDGame(u8 *discid, const void *newID) = 0;
virtual u64 EstimateGameSize(void) = 0; virtual u64 EstimateGameSize(void) = 0;
virtual const u8 GetFSType(void) const = 0;
const wbfs_t *GetHDDHandle(void) const { return hdd; }
protected: protected:
static u32 nb_sectors;
wbfs_t *hdd; wbfs_t *hdd;
u32 device, lba, size; u32 device, lba, size;
private: u8 wbfs_part_fs;
static s32 total, done;
}; };
#endif //_H #endif //_H

View File

@ -1,18 +0,0 @@
#include <ext2.h>
#include "usbloader/usbstorage2.h"
#include "wbfs_ext.h"
extern int wbfs_part_fs;
sec_t ext_wbfs_sec = 0;
s32 Wbfs_Ext::Open()
{
s32 ret = Wbfs_Fat::Open();
if(ret == 0)
{
ext_wbfs_sec = lba;
wbfs_part_fs = PART_FS_EXT;
}
return 0;
}

View File

@ -1,7 +1,6 @@
#ifndef _WBFS_EXT_H #ifndef _WBFS_EXT_H
#define _WBFS_EXT_H #define _WBFS_EXT_H
#include <ext2.h>
#include "wbfs_fat.h" #include "wbfs_fat.h"
class Wbfs_Ext: public Wbfs_Fat class Wbfs_Ext: public Wbfs_Fat
@ -11,9 +10,7 @@ class Wbfs_Ext: public Wbfs_Fat
Wbfs_Fat(device, lba, size) Wbfs_Fat(device, lba, size)
{ {
} }
virtual const u8 GetFSType(void) const { return PART_FS_EXT; }
virtual s32 Open();
bool ShowFreeSpace(void) { return true; };
}; };
#endif //_WBFS_NTFS_H #endif //_WBFS_NTFS_H

View File

@ -34,18 +34,14 @@
using namespace std; using namespace std;
int wbfs_part_fs = -1; static const char wbfs_fat_dir[] = "/wbfs";
static const char invalid_path[] = "/\\:|<>?*\"'";
char Wbfs_Fat::wbfs_fs_drive[16]; static const u32 fat_sector_size = 512;
char Wbfs_Fat::wbfs_fat_dir[16] = "/wbfs";
char Wbfs_Fat::invalid_path[] = "/\\:|<>?*\"'";
struct discHdr *Wbfs_Fat::fat_hdr_list = NULL;
u32 Wbfs_Fat::fat_hdr_count = 0;
u32 Wbfs_Fat::fat_sector_size = 512;
Wbfs_Fat::Wbfs_Fat(u32 device, u32 lba, u32 size) : Wbfs_Fat::Wbfs_Fat(u32 device, u32 lba, u32 size) :
Wbfs(device, lba, size) Wbfs(device, lba, size), fat_hdr_list(NULL), fat_hdr_count(0)
{ {
memset(wbfs_fs_drive, 0, sizeof(wbfs_fs_drive));
} }
s32 Wbfs_Fat::Open() s32 Wbfs_Fat::Open()
@ -59,7 +55,6 @@ s32 Wbfs_Fat::Open()
if (device == WBFS_DEVICE_USB && lba == usbHandle->GetLBAStart(i)) if (device == WBFS_DEVICE_USB && lba == usbHandle->GetLBAStart(i))
{ {
sprintf(wbfs_fs_drive, "%s:", usbHandle->MountName(i)); sprintf(wbfs_fs_drive, "%s:", usbHandle->MountName(i));
wbfs_part_fs = PART_FS_FAT;
return 0; return 0;
} }
} }
@ -75,7 +70,6 @@ void Wbfs_Fat::Close()
hdd = NULL; hdd = NULL;
} }
wbfs_part_fs = -1;
memset(wbfs_fs_drive, 0, sizeof(wbfs_fs_drive)); memset(wbfs_fs_drive, 0, sizeof(wbfs_fs_drive));
} }
@ -102,9 +96,17 @@ wbfs_disc_t* Wbfs_Fat::OpenDisc(u8 *discid)
return iso_file; return iso_file;
} }
wbfs_t *part = OpenPart(fname); hdd = OpenPart(fname);
if (!part) return NULL; if (!hdd) return NULL;
return wbfs_open_disc(part, discid);
wbfs_disc_t *disc = wbfs_open_disc(hdd, discid);
if(!disc)
{
ClosePart(hdd);
return NULL;
}
return disc;
} }
void Wbfs_Fat::CloseDisc(wbfs_disc_t* disc) void Wbfs_Fat::CloseDisc(wbfs_disc_t* disc)
@ -152,18 +154,14 @@ s32 Wbfs_Fat::GetHeaders(struct discHdr *outbuf, u32 cnt, u32 len)
{ {
len = sizeof(struct discHdr); len = sizeof(struct discHdr);
} }
#ifdef DEBUG_WBFS
gprintf( "\n\tGetHeaders" );
#endif
for (i = 0; i < cnt && i < fat_hdr_count; i++) for (i = 0; i < cnt && i < fat_hdr_count; i++)
{ {
memcpy(&outbuf[i], &fat_hdr_list[i], len); memcpy(&outbuf[i], &fat_hdr_list[i], len);
} }
SAFE_FREE( fat_hdr_list ); SAFE_FREE( fat_hdr_list );
fat_hdr_count = 0; fat_hdr_count = 0;
#ifdef DEBUG_WBFS
gprintf( "...ok" );
#endif
return 0; return 0;
} }
@ -184,10 +182,7 @@ s32 Wbfs_Fat::AddGame(void)
/* Add game to device */ /* Add game to device */
partition_selector_t part_sel = (partition_selector_t) Settings.InstallPartitions; partition_selector_t part_sel = (partition_selector_t) Settings.InstallPartitions;
wbfs_t *old_hdd = hdd; ret = wbfs_add_disc(part, __ReadDVD, NULL, ShowProgress, part_sel, 0);
hdd = part; // used by spinner
ret = wbfs_add_disc(hdd, __ReadDVD, NULL, ShowProgress, part_sel, 0);
hdd = old_hdd;
wbfs_trim(part); wbfs_trim(part);
ClosePart(part); ClosePart(part);
@ -210,17 +205,18 @@ s32 Wbfs_Fat::RemoveGame(u8 *discid)
// game is in subdir // game is in subdir
// remove optional .txt file // remove optional .txt file
DIR_ITER *dir_iter; DIR *dir = NULL;
struct stat st; struct dirent *dirent = NULL;
char path[MAX_FAT_PATH]; char path[MAX_FAT_PATH];
char name[MAX_FAT_PATH]; char name[MAX_FAT_PATH];
strncpy(path, fname, sizeof(path)); strncpy(path, fname, sizeof(path));
char *p = strrchr(path, '/'); char *p = strrchr(path, '/');
if (p) *p = 0; if (p) *p = 0;
dir_iter = diropen(path); dir = opendir(path);
if (!dir_iter) return 0; if (!dir) return 0;
while (dirnext(dir_iter, name, &st) == 0) while ((dirent = readdir(dir)) != 0)
{ {
snprintf(name, sizeof(name), dirent->d_name);
if (name[0] == '.') continue; if (name[0] == '.') continue;
if (name[6] != '_') continue; if (name[6] != '_') continue;
if (strncmp(name, (char*) discid, 6) != 0) continue; if (strncmp(name, (char*) discid, 6) != 0) continue;
@ -231,7 +227,7 @@ s32 Wbfs_Fat::RemoveGame(u8 *discid)
remove(fname); remove(fname);
break; break;
} }
dirclose(dir_iter); closedir(dir);
// remove game subdir // remove game subdir
unlink(path); unlink(path);
@ -382,8 +378,8 @@ s32 Wbfs_Fat::GetHeadersCount()
char dir_title[65]; char dir_title[65];
char fname_title[TITLE_LEN]; char fname_title[TITLE_LEN];
const char *title; const char *title;
DIR_ITER *dir_iter; DIR *dir_iter;
struct dirent *dirent;
//dbg_time1(); //dbg_time1();
SAFE_FREE( fat_hdr_list ); SAFE_FREE( fat_hdr_list );
@ -392,14 +388,18 @@ s32 Wbfs_Fat::GetHeadersCount()
strcpy(path, wbfs_fs_drive); strcpy(path, wbfs_fs_drive);
strcat(path, wbfs_fat_dir); strcat(path, wbfs_fat_dir);
dir_iter = diropen(path); dir_iter = opendir(path);
if (!dir_iter) return 0; if (!dir_iter) return 0;
dir_iter = diropen(path); while ((dirent = readdir(dir_iter)) != 0)
if (!dir_iter) return 0;
while (dirnext(dir_iter, fname, &st) == 0)
{ {
snprintf(fname, sizeof(fname), "%s/%s", path, dirent->d_name);
if(stat(fname, &st) != 0)
continue;
snprintf(fname, sizeof(fname), dirent->d_name);
//printf("found: %s\n", fname); Wpad_WaitButtonsCommon(); //printf("found: %s\n", fname); Wpad_WaitButtonsCommon();
if ((char) fname[0] == '.') continue; if ((char) fname[0] == '.') continue;
len = strlen(fname); len = strlen(fname);
@ -584,7 +584,7 @@ s32 Wbfs_Fat::GetHeadersCount()
fat_hdr_list = (struct discHdr *) realloc(fat_hdr_list, fat_hdr_count * sizeof(struct discHdr)); fat_hdr_list = (struct discHdr *) realloc(fat_hdr_list, fat_hdr_count * sizeof(struct discHdr));
memcpy(&fat_hdr_list[fat_hdr_count - 1], &tmpHdr, sizeof(struct discHdr)); memcpy(&fat_hdr_list[fat_hdr_count - 1], &tmpHdr, sizeof(struct discHdr));
} }
dirclose(dir_iter); closedir(dir_iter);
//dbg_time2("\nFAT_GetCount"); Wpad_WaitButtonsCommon(); //dbg_time2("\nFAT_GetCount"); Wpad_WaitButtonsCommon();
return 0; return 0;
@ -604,19 +604,26 @@ int Wbfs_Fat::FindFilename(u8 *id, char *fname, int len)
if (stat(fname, &st) == 0) return 1; if (stat(fname, &st) == 0) return 1;
// direct file not found, check subdirs // direct file not found, check subdirs
*fname = 0; *fname = 0;
DIR_ITER *dir_iter; DIR *dir_iter;
struct dirent *dirent;
char path[MAX_FAT_PATH]; char path[MAX_FAT_PATH];
char name[MAX_FAT_PATH]; char name[MAX_FAT_PATH];
strcpy(path, wbfs_fs_drive); strcpy(path, wbfs_fs_drive);
strcat(path, wbfs_fat_dir); strcat(path, wbfs_fat_dir);
dir_iter = diropen(path); dir_iter = opendir(path);
//printf("dir: %s %p\n", path, dir); Wpad_WaitButtons(); //printf("dir: %s %p\n", path, dir); Wpad_WaitButtons();
if (!dir_iter) if (!dir_iter)
{ {
return 0; return 0;
} }
while (dirnext(dir_iter, name, &st) == 0) while ((dirent = readdir(dir_iter)) != 0)
{ {
snprintf(name, sizeof(name), "%s/%s", path, dirent->d_name);
if(stat(name, &st) != 0)
continue;
snprintf(name, sizeof(name), dirent->d_name);
//dbg_printf("name:%s\n", name); //dbg_printf("name:%s\n", name);
if (name[0] == '.') continue; if (name[0] == '.') continue;
int n = strlen(name); int n = strlen(name);
@ -660,7 +667,7 @@ int Wbfs_Fat::FindFilename(u8 *id, char *fname, int len)
if (stat(fname, &st) == 0) break; if (stat(fname, &st) == 0) break;
*fname = 0; *fname = 0;
} }
dirclose(dir_iter); closedir(dir_iter);
if (*fname) if (*fname)
{ {
// found // found
@ -739,7 +746,7 @@ wbfs_t* Wbfs_Fat::CreatePart(u8 *id, char *path)
// 1 cluster less than 4gb // 1 cluster less than 4gb
u64 OPT_split_size = 4LL * 1024 * 1024 * 1024 - 32 * 1024; u64 OPT_split_size = 4LL * 1024 * 1024 * 1024 - 32 * 1024;
if(Settings.GameSplit == GAMESPLIT_NONE && wbfs_part_fs != PART_FS_FAT) if(Settings.GameSplit == GAMESPLIT_NONE && gameList.GetGameFS(id) != PART_FS_FAT)
OPT_split_size = (u64) 100LL * 1024 * 1024 * 1024 - 32 * 1024; OPT_split_size = (u64) 100LL * 1024 * 1024 * 1024 - 32 * 1024;
else if(Settings.GameSplit == GAMESPLIT_2GB) else if(Settings.GameSplit == GAMESPLIT_2GB)
@ -860,7 +867,7 @@ int Wbfs_Fat::GetFragList(u8 *id)
int ret = FindFilename(id, fname, sizeof(fname)); int ret = FindFilename(id, fname, sizeof(fname));
if (!ret) return -1; if (!ret) return -1;
return get_frag_list_for_file(fname, id); return get_frag_list_for_file(fname, id, GetFSType(), lba);
} }
bool Wbfs_Fat::ShowFreeSpace(void) bool Wbfs_Fat::ShowFreeSpace(void)

View File

@ -31,19 +31,16 @@ class Wbfs_Fat: public Wbfs
u64 EstimateGameSize(); u64 EstimateGameSize();
int GetFragList(u8 *); virtual int GetFragList(u8 *);
virtual bool ShowFreeSpace(void); virtual bool ShowFreeSpace(void);
virtual const u8 GetFSType(void) const { return PART_FS_FAT; }
protected: protected:
static char wbfs_fs_drive[16];
private:
split_info_t split; split_info_t split;
static u32 fat_sector_size; struct discHdr *fat_hdr_list;
static char wbfs_fat_dir[16]; u32 fat_hdr_count;
static char invalid_path[]; char wbfs_fs_drive[16];
static struct discHdr *fat_hdr_list;
static u32 fat_hdr_count;
wbfs_t* OpenPart(char *fname); wbfs_t* OpenPart(char *fname);
void ClosePart(wbfs_t* part); void ClosePart(wbfs_t* part);

View File

@ -1,19 +0,0 @@
#include <ntfs.h>
#include <locale.h>
#include "wbfs_ntfs.h"
#include "usbloader/usbstorage2.h"
extern int wbfs_part_fs;
sec_t ntfs_wbfs_sec = 0;
s32 Wbfs_Ntfs::Open()
{
s32 ret = Wbfs_Fat::Open();
if(ret == 0)
{
ntfs_wbfs_sec = lba;
wbfs_part_fs = PART_FS_NTFS;
}
return 0;
}

View File

@ -10,10 +10,7 @@ class Wbfs_Ntfs: public Wbfs_Fat
Wbfs_Fat(device, lba, size) Wbfs_Fat(device, lba, size)
{ {
} }
virtual const u8 GetFSType(void) const { return PART_FS_NTFS; }
virtual s32 Open();
bool ShowFreeSpace(void) { return true; };
}; };
#endif //_WBFS_NTFS_H #endif //_WBFS_NTFS_H

View File

@ -4,7 +4,6 @@
#include "usbloader/wbfs.h" #include "usbloader/wbfs.h"
#include "wbfs_rw.h" #include "wbfs_rw.h"
extern int wbfs_part_fs;
extern u32 hdd_sector_size; extern u32 hdd_sector_size;
s32 Wbfs_Wbfs::Open() s32 Wbfs_Wbfs::Open()
@ -42,8 +41,6 @@ s32 Wbfs_Wbfs::Open()
Close(); Close();
hdd = part; hdd = part;
wbfs_part_fs = PART_FS_WBFS;
return 0; return 0;
} }
@ -54,8 +51,6 @@ void Wbfs_Wbfs::Close()
wbfs_close(hdd); wbfs_close(hdd);
hdd = NULL; hdd = NULL;
} }
wbfs_part_fs = -1;
} }
wbfs_disc_t* Wbfs_Wbfs::OpenDisc(u8 *discid) wbfs_disc_t* Wbfs_Wbfs::OpenDisc(u8 *discid)
@ -212,5 +207,5 @@ s32 Wbfs_Wbfs::GetFragList(u8 *id)
{ {
//! Doesn't have to be called ".iso" just something different than .wbfs but with a dot. //! Doesn't have to be called ".iso" just something different than .wbfs but with a dot.
//! So that the code doesn't fail. //! So that the code doesn't fail.
return get_frag_list_for_file((char *) ".iso", id); return get_frag_list_for_file((char *) ".iso", id, GetFSType(), lba);
} }

View File

@ -3,6 +3,7 @@
#include "wbfs_base.h" #include "wbfs_base.h"
#include "libs/libwbfs/libwbfs.h" #include "libs/libwbfs/libwbfs.h"
#include "usbloader/wbfs.h"
#include "wbfs_rw.h" #include "wbfs_rw.h"
class Wbfs_Wbfs: public Wbfs class Wbfs_Wbfs: public Wbfs
@ -32,8 +33,9 @@ class Wbfs_Wbfs: public Wbfs
u64 EstimateGameSize(); u64 EstimateGameSize();
int GetFragList(u8 *id); int GetFragList(u8 *id);
virtual const u8 GetFSType(void) const { return PART_FS_WBFS; }
private: private:
_WBFS_PartInfo PartInfo; WBFS_PartInfo PartInfo;
}; };
#endif //_WBFS_WBFS_H #endif //_WBFS_WBFS_H