mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-05 02:55:07 +01:00
d62e41d601
*Added sources of the custom libs to the branches *Fixed crash when switching from list layout to grid/carousel layout *Removed 1:1 copy option because its meaningless and almost the same as installing all partitions *Fixed install partition selection. This option needs a reset. Go to settings and reselect your option for this. *Fixed schinese and tchinese language modes (filename bugs. has to be schinese.lang and tchinese.lang like on SVN) *Fixed bug in sound buffer circle *Fixed incorrect behaviour of x-flip when selecting system like (thx Cyan for the patch) *Accept ios revision 65535 for Waninkokos IOSes (thx to PPSainity for pointing it out) *Merged the new theming style branch into trunk. Just as a reminder: ALL old themes will not work until the themers did port it to the new style! *Removed old theme style completely Theme example: The example file of the theme is the Default.them file. It can be found in the SVN trunk. Change in loading of themes: When selecting a theme now a list of all .them files in a folder is displayed. The image folder of that theme has to be in the same folder as the .them file. The image path is defined in the head of the .them file in the line with "Image-Folder: Example\n".
169 lines
3.2 KiB
C++
169 lines
3.2 KiB
C++
#include "wbfs_wbfs.h"
|
|
#include "prompts/ProgressWindow.h"
|
|
#include "settings/CSettings.h"
|
|
#include "wbfs_rw.h"
|
|
|
|
extern u32 sector_size;
|
|
|
|
s32 Wbfs_Wbfs::Open()
|
|
{
|
|
wbfs_t *part = NULL;
|
|
|
|
/* Open partition */
|
|
part = wbfs_open_partition(readCallback, writeCallback, NULL, sector_size, size, lba, 0);
|
|
if (!part) return -1;
|
|
|
|
/* Close current hard disk */
|
|
Close();
|
|
hdd = part;
|
|
|
|
// Save the new sector size, so it will be used in read and write calls
|
|
sector_size = 1 << hdd->head->hd_sec_sz_s;
|
|
|
|
return 0;
|
|
}
|
|
|
|
wbfs_disc_t* Wbfs_Wbfs::OpenDisc(u8 *discid)
|
|
{
|
|
/* No device open */
|
|
if (!hdd) return NULL;
|
|
|
|
/* Open disc */
|
|
return wbfs_open_disc(hdd, discid);
|
|
}
|
|
|
|
void Wbfs_Wbfs::CloseDisc(wbfs_disc_t *disc)
|
|
{
|
|
/* No device open */
|
|
if (!hdd || !disc) return;
|
|
|
|
/* Close disc */
|
|
wbfs_close_disc(disc);
|
|
}
|
|
|
|
s32 Wbfs_Wbfs::Format()
|
|
{
|
|
wbfs_t *partition = NULL;
|
|
|
|
/* Reset partition */
|
|
partition = wbfs_open_partition(readCallback, writeCallback, NULL, sector_size, size, lba, 1);
|
|
if (!partition) return -1;
|
|
|
|
/* Free memory */
|
|
wbfs_close(partition);
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs_Wbfs::GetCount(u32 *count)
|
|
{
|
|
/* No device open */
|
|
if (!hdd) return -1;
|
|
|
|
/* Get list length */
|
|
*count = wbfs_count_discs(hdd);
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs_Wbfs::GetHeaders(struct discHdr *outbuf, u32 cnt, u32 len)
|
|
{
|
|
u32 idx, size;
|
|
s32 ret;
|
|
|
|
/* No device open */
|
|
if (!hdd) return -1;
|
|
|
|
for (idx = 0; idx < cnt; idx++)
|
|
{
|
|
u8 *ptr = ((u8 *) outbuf) + (idx * len);
|
|
|
|
/* Get header */
|
|
ret = wbfs_get_disc_info(hdd, idx, ptr, len, &size);
|
|
if (ret < 0) return ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs_Wbfs::AddGame()
|
|
{
|
|
s32 ret;
|
|
|
|
/* No device open */
|
|
if (!hdd) return -1;
|
|
|
|
partition_selector_t part_sel = (partition_selector_t) Settings.InstallPartitions;
|
|
|
|
/* Add game to device */
|
|
ret = wbfs_add_disc(hdd, __ReadDVD, NULL, ProgressCallback, part_sel, 0);
|
|
if (ret < 0) return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs_Wbfs::RemoveGame(u8 *discid)
|
|
{
|
|
s32 ret;
|
|
|
|
/* No device open */
|
|
if (!hdd) return -1;
|
|
|
|
/* Remove game from USB device */
|
|
ret = wbfs_rm_disc(hdd, discid);
|
|
if (ret < 0) return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs_Wbfs::DiskSpace(f32 *used, f32 *free)
|
|
{
|
|
f32 ssize;
|
|
u32 cnt;
|
|
|
|
/* No device open */
|
|
if (!hdd) return -1;
|
|
|
|
/* Count used blocks */
|
|
cnt = wbfs_count_usedblocks(hdd);
|
|
|
|
/* Sector size in GB */
|
|
ssize = hdd->wbfs_sec_sz / GB_SIZE;
|
|
|
|
/* Copy values */
|
|
*free = ssize * cnt;
|
|
*used = ssize * (hdd->n_wbfs_sec - cnt);
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs_Wbfs::RenameGame(u8 *discid, const void *newname)
|
|
{
|
|
s32 ret;
|
|
|
|
/* No USB device open */
|
|
if (!hdd) return -1;
|
|
ret = wbfs_ren_disc(hdd, discid, (u8*) newname);
|
|
if (ret < 0) return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs_Wbfs::ReIDGame(u8 *discid, const void *newID)
|
|
{
|
|
s32 ret;
|
|
|
|
/* No USB device open */
|
|
if (!hdd) return -1;
|
|
ret = wbfs_rID_disc(hdd, discid, (u8*) newID);
|
|
if (ret < 0) return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
f32 Wbfs_Wbfs::EstimateGameSize()
|
|
{
|
|
partition_selector_t part_sel = (partition_selector_t) Settings.InstallPartitions;
|
|
return wbfs_estimate_disc(hdd, __ReadDVD, NULL, part_sel);
|
|
}
|