usbloadergx/source/usbloader/wbfs.cpp
dimok321 e6a87c05fe *Fixed display of partition size on WBFS partitions with a different wbfs sector size than 512bytes.
*Made the ProgressWindow for game installation more accurate
*Added displaying newly installed games (marked as new) on favorite list, so you don't have to change to full list when installing new games. (Thanks Cyan for the patch)
*Lot's a small fixes
*Added WDM Menu on game start. You can set it in the alternative DOL option (one new option there). The menu lists all DOLs on the disc and if a wdm file is provided in the WDM path (configurable in the settings) than the dol parameter and dol replacement name will be taken from the wdm. The DOLs that are not listed in the WDM but exist on the DISC will be listed at the end of the list.
*Added avoid of multiple app cleanup when game fails to boot

*Changed libfat to use FS info sector on FAT32 partitions. This speeds up the free space information getting to instant. For that the FS info sector has to have correct values. The values of all partitions where homebrews were writing to are currently incorrect because the official libfat does not support FS info sector (i submited a patch) (Windows does write it correct though). That is why there needs to be a synchronization of the FS info sector for partitions used with homebrews. For this purpose a new setting was added in the Loader Settings. You can synchronize all your FAT32 partitions on the USB with it once and you are done (if you don't write to that partition with current homebrews). After that you can enable free space display and it will be instant like on WBFS/NTFS/EXT partitions.
2011-01-16 13:12:07 +00:00

207 lines
4.1 KiB
C++

#include <ogcsys.h>
#include <unistd.h>
#include <time.h>
#include "Controls/DeviceHandler.hpp"
#include "usbloader/usbstorage2.h"
#include "wbfs.h"
#include "usbloader/wbfs/wbfs_base.h"
#include "usbloader/wbfs/wbfs_wbfs.h"
#include "usbloader/wbfs/wbfs_fat.h"
#include "usbloader/wbfs/wbfs_ntfs.h"
#include "usbloader/wbfs/wbfs_ext.h"
#include "usbloader/GameList.h"
#include "menu/menus.h"
#include "gecko.h"
static Wbfs *current = NULL;
/* WBFS device */
s32 wbfsDev = WBFS_MIN_DEVICE;
wbfs_disc_t* WBFS_OpenDisc(u8 *discid)
{
return current->OpenDisc(discid);
}
void WBFS_CloseDisc(wbfs_disc_t *disc)
{
current->CloseDisc(disc);
}
wbfs_t *GetHddInfo(void)
{
return current->GetHddInfo();
}
s32 WBFS_Init(u32 device)
{
return Wbfs::Init(device);
}
s32 WBFS_OpenPart(int part_num)
{
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
if(part_num < 0 || part_num >= usbHandle->GetPartitionCount())
return -1;
// close
WBFS_Close();
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)
{
current = new Wbfs_Fat(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
}
else if (strncmp(usbHandle->GetFSName(part_num), "NTFS", 4) == 0)
{
current = new Wbfs_Ntfs(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
}
else if (strncmp(usbHandle->GetFSName(part_num), "LINUX", 5) == 0)
{
current = new Wbfs_Ext(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
}
else if (strncmp(usbHandle->GetFSName(part_num), "WBFS", 4) == 0)
{
current = new Wbfs_Wbfs(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
}
else
{
return -1;
}
if (current->Open())
{
delete current;
current = NULL;
return -1;
}
return 0;
}
bool WBFS_Close(void)
{
if (current != NULL)
{
current->Close();
delete current;
current = NULL;
}
gameList.clear();
return 0;
}
bool WBFS_Mounted()
{
return (current != NULL && current->IsMounted());
}
s32 WBFS_Format(u32 lba, u32 size)
{
Wbfs_Wbfs Part(wbfsDev, lba, size);
return Part.Format();
}
s32 WBFS_GetCount(u32 *count)
{
return current->GetCount(count);
}
s32 WBFS_GetHeaders(struct discHdr *outbuf, u32 cnt, u32 len)
{
return current->GetHeaders(outbuf, cnt, len);
}
s32 WBFS_CheckGame(u8 *discid)
{
return current->CheckGame(discid);
}
s32 WBFS_AddGame(void)
{
s32 retval = current->AddGame();
if (retval == 0) gameList.clear();
return retval;
}
s32 WBFS_RemoveGame(u8 *discid)
{
s32 retval = current->RemoveGame(discid);
if (retval == 0) gameList.clear();
return retval;
}
s32 WBFS_GameSize(u8 *discid, f32 *size)
{
return current->GameSize(discid, size);
}
s32 WBFS_DiskSpace(f32 *used, f32 *free)
{
return current->DiskSpace(used, free);
}
s32 WBFS_RenameGame(u8 *discid, const void *newname)
{
s32 retval = current->RenameGame(discid, newname);
if (retval == 0) gameList.clear();
return retval;
}
s32 WBFS_ReIDGame(u8 *discid, const void *newID)
{
s32 retval = current->ReIDGame(discid, newID);
if (retval == 0) gameList.clear();
return retval;
}
u64 WBFS_EstimeGameSize(void)
{
return current->EstimateGameSize();
}
int WBFS_GetFragList(u8 *id)
{
return current->GetFragList(id);
}
bool WBFS_ShowFreeSpace(void)
{
return current->ShowFreeSpace();
}
int MountWBFS(bool ShowGUI)
{
if(ShowGUI)
return WBFS_Init(WBFS_DEVICE_USB);
int ret = -1;
time_t currTime = time(0);
while (time(0) - currTime < 30)
{
ret = WBFS_Init(WBFS_DEVICE_USB);
printf("%i...", int(time(0) - currTime));
if (ret < 0)
sleep(1);
else
break;
DeviceHandler::Instance()->UnMountAllUSB();
DeviceHandler::Instance()->MountAllUSB();
}
printf("\n");
return ret;
}