*re-eveluate partition size after installing games and such (from r-win)

This commit is contained in:
giantpune 2010-02-01 11:22:48 +00:00
parent 1c6c607cf1
commit aeb7aff9ea
2 changed files with 27 additions and 41 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>1.0 r901</version> <version>1.0 r902</version>
<release_date>201001312334</release_date> <release_date>201002011014</release_date>
<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.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller. The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

View File

@ -34,11 +34,6 @@ char wbfs_fs_drive[16];
char wbfs_fat_dir[16] = "/wbfs"; char wbfs_fat_dir[16] = "/wbfs";
char invalid_path[] = "/\\:|<>?*\"'"; char invalid_path[] = "/\\:|<>?*\"'";
int wbfs_fat_vfs_have = 0;
int wbfs_fat_vfs_lba = 0;
int wbfs_fat_vfs_dev = 0;
struct statvfs wbfs_fat_vfs;
split_info_t split; split_info_t split;
static u32 fat_sector_size = 512; static u32 fat_sector_size = 512;
@ -192,7 +187,7 @@ s32 _WBFS_FAT_GetHeadersCount()
} }
} }
// no title found, read it from wbfs file // no title found, read it from wbfs file
// but this is a little bit slower // but this is a little bit slower
// open 'partition' file // open 'partition' file
part = WBFS_FAT_OpenPart(fpath); part = WBFS_FAT_OpenPart(fpath);
if (!part) { if (!part) {
@ -317,27 +312,18 @@ s32 WBFS_FAT_DiskSpace(f32 *used, f32 *free)
{ {
f32 size; f32 size;
int ret; int ret;
struct statvfs wbfs_fat_vfs;
*used = 0; *used = 0;
*free = 0; *free = 0;
// statvfs is slow, so cache values ret = statvfs(wbfs_fs_drive, &wbfs_fat_vfs);
if (!wbfs_fat_vfs_have if (ret) return -1;
|| wbfs_fat_vfs_lba != wbfs_part_lba
|| wbfs_fat_vfs_dev != wbfsDev )
{
ret = statvfs(wbfs_fs_drive, &wbfs_fat_vfs);
if (ret) return 0;
wbfs_fat_vfs_have = 1;
wbfs_fat_vfs_lba = wbfs_part_lba;
wbfs_fat_vfs_dev = wbfsDev;
}
/* FS size in GB */ /* FS size in GB */
size = (f32)wbfs_fat_vfs.f_frsize * (f32)wbfs_fat_vfs.f_blocks / GB_SIZE; size = (f32)wbfs_fat_vfs.f_frsize * (f32)wbfs_fat_vfs.f_blocks / GB_SIZE;
*free = (f32)wbfs_fat_vfs.f_frsize * (f32)wbfs_fat_vfs.f_bfree / GB_SIZE; *free = (f32)wbfs_fat_vfs.f_frsize * (f32)wbfs_fat_vfs.f_bfree / GB_SIZE;
*used = size - *free; *used = size - *free;
return 0; return 0;
} }
@ -374,14 +360,14 @@ void title_filename(char *title)
} }
// trim trailing space - not allowed on windows directories // trim trailing space - not allowed on windows directories
while (len && title[len-1] == ' ') { while (len && title[len-1] == ' ') {
title[len-1] = 0; title[len-1] = 0;
len--; len--;
} }
// replace silly chars with '_' // replace silly chars with '_'
for (i=0; i<len; i++) { for (i=0; i<len; i++) {
if(strchr(invalid_path, title[i]) || iscntrl((int) title[i])) { if(strchr(invalid_path, title[i]) || iscntrl((int) title[i])) {
title[i] = '_'; title[i] = '_';
} }
} }
} }
@ -654,7 +640,7 @@ s32 WBFS_FAT_DVD_Size(u64 *comp_size, u64 *real_size)
wbfs_t *part = NULL; wbfs_t *part = NULL;
u64 size = (u64)143432*2*0x8000ULL; u64 size = (u64)143432*2*0x8000ULL;
u32 n_sector = size / fat_sector_size; u32 n_sector = size / fat_sector_size;
u32 wii_sec_sz; u32 wii_sec_sz;
// init a temporary dummy part // init a temporary dummy part
// as a placeholder for wbfs_size_disc // as a placeholder for wbfs_size_disc
@ -686,7 +672,7 @@ s32 WBFS_FAT_RenameGame(u8 *discid, const void *newname)
{ {
wbfs_t *part = WBFS_FAT_OpenPart((char *) discid); wbfs_t *part = WBFS_FAT_OpenPart((char *) discid);
if (!part) if (!part)
return -1; return -1;
s32 ret = wbfs_ren_disc(part, discid,(u8*)newname); s32 ret = wbfs_ren_disc(part, discid,(u8*)newname);
@ -699,7 +685,7 @@ s32 WBFS_FAT_ReIDGame(u8 *discid, const void *newID)
{ {
wbfs_t *part = WBFS_FAT_OpenPart((char *) discid); wbfs_t *part = WBFS_FAT_OpenPart((char *) discid);
if (!part) if (!part)
return -1; return -1;
s32 ret = wbfs_rID_disc(part, discid,(u8*)newID); s32 ret = wbfs_rID_disc(part, discid,(u8*)newID);
@ -711,19 +697,19 @@ s32 WBFS_FAT_ReIDGame(u8 *discid, const void *newID)
char fnamenew[100]; char fnamenew[100];
s32 cnt = 0x31; s32 cnt = 0x31;
WBFS_FAT_fname(discid, fname, sizeof(fname), NULL); WBFS_FAT_fname(discid, fname, sizeof(fname), NULL);
WBFS_FAT_fname((u8*) newID, fnamenew, sizeof(fnamenew), NULL); WBFS_FAT_fname((u8*) newID, fnamenew, sizeof(fnamenew), NULL);
int stringlength = strlen(fname); int stringlength = strlen(fname);
while(rename(fname, fnamenew) == 0) while(rename(fname, fnamenew) == 0)
{ {
fname[stringlength] = cnt; fname[stringlength] = cnt;
fname[stringlength+1] = 0; fname[stringlength+1] = 0;
fnamenew[stringlength] = cnt; fnamenew[stringlength] = cnt;
fnamenew[stringlength+1] = 0; fnamenew[stringlength+1] = 0;
cnt++; cnt++;
} }
} }
return ret; return ret;
@ -733,7 +719,7 @@ s32 WBFS_FAT_EstimateGameSize(void) {
wbfs_t *part = NULL; wbfs_t *part = NULL;
u64 size = (u64)143432*2*0x8000ULL; u64 size = (u64)143432*2*0x8000ULL;
u32 n_sector = size / fat_sector_size; u32 n_sector = size / fat_sector_size;
u32 wii_sec_sz; u32 wii_sec_sz;
// init a temporary dummy part // init a temporary dummy part
// as a placeholder for wbfs_size_disc // as a placeholder for wbfs_size_disc
@ -742,7 +728,7 @@ s32 WBFS_FAT_EstimateGameSize(void) {
NULL, fat_sector_size, n_sector, 0, 1); NULL, fat_sector_size, n_sector, 0, 1);
if (!part) return -1; if (!part) return -1;
wii_sec_sz = part->wii_sec_sz; wii_sec_sz = part->wii_sec_sz;
partition_selector_t part_sel; partition_selector_t part_sel;
if (Settings.fullcopy) { if (Settings.fullcopy) {
part_sel = ALL_PARTITIONS; part_sel = ALL_PARTITIONS;