And the rest that should have been committed with r323 ;)

This commit is contained in:
overjoy.psm 2012-05-08 01:05:33 +00:00
parent 26a1ca085c
commit 7c1093a2b2
5 changed files with 28 additions and 56 deletions

View File

@ -4,7 +4,7 @@
#define APPDATA_DIR "wiiflow"
#define APPDATA_DIR2 "apps/wiiflow"
#define STDEMU_DIR "/wiiflow/nandemu/"
#define STDEMU_DIR "/wiiflow/nandemu"
#define GAMES_DIR "%s:/wbfs"
#define HOMEBREW_DIR "%s:/apps"
#define DML_DIR "%s:/games"

View File

@ -50,64 +50,43 @@ static void CreateNandPath(const char *path, ...)
void CreateTitleTMD(const char *path, struct dir_discHdr *hdr)
{
struct stat filestat;
if (stat(path, &filestat) == 0)
{
gprintf("%s Exists!\n", path);
return;
}
gprintf("Creating Game TMD: %s\n", path);
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) &hdr->hdr.id, (char *)hdr->path);
if (!disc) return;
if(!disc)
return;
u8 *titleTMD = NULL;
u32 tmd_size = wbfs_extract_file(disc, (char *) "TMD", (void **)&titleTMD);
WBFS_CloseDisc(disc);
if(!titleTMD) return;
if(!titleTMD)
return;
FILE *file = fopen(path, "wb");
u32 highTID = *(u32*)(titleTMD+0x18c);
u32 lowTID = *(u32*)(titleTMD+0x190);
CreateNandPath("%s/title/%08x/%08x/data", path, highTID, lowTID);
CreateNandPath("%s/title/%08x/%08x/content", path, highTID, lowTID);
char nandpath[ISFS_MAXPATH];
snprintf(nandpath, sizeof(nandpath), "%s/title/%08x/%08x/content/title.tmd", path, highTID, lowTID);
struct stat filestat;
if (stat(nandpath, &filestat) == 0)
{
SAFE_FREE(titleTMD);
gprintf("%s Exists!\n", nandpath);
return;
}
gprintf("Creating Game TMD: %s\n", nandpath);
FILE *file = fopen(nandpath, "wb");
if(file)
{
fwrite(titleTMD, 1, tmd_size, file);
gprintf("Written Game TMD to: %s\n", path);
gprintf("Written Game TMD to: %s\n", nandpath);
fclose(file);
}
else gprintf("Openning %s failed returning %i\n", path, file);
else gprintf("Openning %s failed returning %i\n", nandpath, file);
SAFE_FREE(titleTMD);
}
void CreateSavePath(const char *basepath, struct dir_discHdr *hdr)
{
CreateNandPath("%s/import", basepath);
CreateNandPath("%s/meta", basepath);
CreateNandPath("%s/shared1", basepath);
CreateNandPath("%s/shared2", basepath);
CreateNandPath("%s/sys", basepath);
CreateNandPath("%s/ticket", basepath);
CreateNandPath("%s/tmp", basepath);
CreateNandPath("%s/title", basepath);
const char *titlePath = "/title/00010000";
if( memcmp(hdr->hdr.id, "RGW", 3) == 0)
titlePath = "/title/00010004";
char fullpath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
snprintf(fullpath, sizeof(fullpath), "%s%s", basepath, titlePath);
CreateNandPath(fullpath);
char nandPath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
snprintf(nandPath, sizeof(nandPath), "%s/%02x%02x%02x%02x", fullpath, hdr->hdr.id[0], hdr->hdr.id[1], hdr->hdr.id[2], hdr->hdr.id[3]);
CreateNandPath(nandPath);
CreateNandPath("%s/data", nandPath);
CreateNandPath("%s/content", nandPath);
strcat(nandPath, "/content/title.tmd");
CreateTitleTMD(nandPath, hdr);
}

View File

@ -7,7 +7,6 @@
extern "C" {
#endif /* __cplusplus */
void CreateSavePath(const char *basepath, struct dir_discHdr *hdr);
void CreateTitleTMD(const char *path, struct dir_discHdr *hdr);
#ifdef __cplusplus

View File

@ -164,14 +164,9 @@ s32 WBFS_Ext_RemoveGame(u8 *discid, char *gamepath)
if (!dir_iter) return 0;
while((ent = readdir(dir_iter)) != NULL)
{
//if(ent->d_name[0] == '.')
// continue;
if(strstr(ent->d_name, (char*)discid) != NULL)
{
snprintf(file, sizeof(file), "%s/%s", folder, ent->d_name);
//if(discid != NULL && strstr(file, (char*)discid) != NULL)
remove(file);
}
}
@ -218,8 +213,7 @@ s32 WBFS_Ext_AddGame(progress_callback_t spinner, void *spinner_data)
return -1;
}
wbfs_t *part = wbfs_open_partition(split_read_sector, split_write_sector,
&split, 512, n_sector, 0, 1);
wbfs_t *part = wbfs_open_partition(split_read_sector, split_write_sector, &split, 512, n_sector, 0, 1);
if (!part)
{
split_close(&split);

File diff suppressed because one or more lines are too long