usbloadergx/source/usbloader/SavePath.cpp
dimok321 de2fbe11fa *Added NAND Emulation for d2x v4+ cIOS ONLY. You can emulate partial (mainly titles path (including gamesaves and does not include Miis)) or full nand emulation. The Nand path can be chosen (should not be the same drive as game drive and must be a FAT/FAT32 partition (e.g. sd:/nand/). Just put your NAND FS in that path.
IF YOU USE RETURN TO OPTION THEN THE UNEO TITLE MUST BE ON EMU NAND AS WELL FOR PARTIAL AND FULL EMULATION.

*Added back our old font as fallback font in case the wii system font can't be loaded. Also the use of the Wii System Font can be disabled in the settings (don't forget to set font scale back to 1.0 for old font)
2011-07-24 16:32:09 +00:00

86 lines
2.6 KiB
C++

/****************************************************************************
* Copyright (C) 2011
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <gctypes.h>
#include <stdio.h>
#include "settings/CSettings.h"
#include "usbloader/disc.h"
#include "usbloader/wbfs.h"
#include "usbloader/nand.h"
#include "FileOperations/fileops.h"
#include "gecko.h"
void CreateTitleTMD(const char *path, const struct discHdr *hdr)
{
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) hdr->id);
if (!disc)
return;
wiidisc_t *wdisc = wd_open_disc((int(*)(void *, u32, u32, void *)) wbfs_disc_read, disc);
if (!wdisc)
{
WBFS_CloseDisc(disc);
return;
}
u8 *titleTMD = wd_extract_file(wdisc, ONLY_GAME_PARTITION, (char *) "TMD");
int tmd_size = wdisc->extracted_size;
wd_close_disc(wdisc);
WBFS_CloseDisc(disc);
if(!titleTMD)
return;
FILE *f = fopen(path, "wb");
if(f)
{
fwrite(titleTMD, 1, tmd_size, f);
fclose(f);
gprintf("Written Game Title TDM to: %s\n", path);
}
free(titleTMD);
}
void CreateSavePath(const struct discHdr *hdr)
{
char contentPath[512];
char dataPath[512];
snprintf(contentPath, sizeof(contentPath), "%s/title/00010000/%02x%02x%02x%02x/content", Settings.NandEmuPath, hdr->id[0], hdr->id[1], hdr->id[2], hdr->id[3]);
snprintf(dataPath, sizeof(dataPath), "%s/title/00010000/%02x%02x%02x%02x/data", Settings.NandEmuPath, hdr->id[0], hdr->id[1], hdr->id[2], hdr->id[3]);
if(CheckFile(contentPath) && CheckFile(dataPath))
return;
gprintf("Creating Save Path: %s\n", contentPath);
gprintf("Creating Save Path: %s\n", dataPath);
CreateSubfolder(contentPath);
CreateSubfolder(dataPath);
strcat(contentPath, "/title.tmd");
CreateTitleTMD(contentPath, hdr);
}