Merge pull request #6651 from leoetlino/nand-paths

NandPaths: Return paths that are relative to Wii NAND
This commit is contained in:
Léo Lam
2018-05-05 11:01:35 +02:00
committed by GitHub
11 changed files with 61 additions and 42 deletions

View File

@ -472,7 +472,7 @@ void StateFlags::UpdateChecksum()
void UpdateStateFlags(std::function<void(StateFlags*)> update_function)
{
const std::string file_path =
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) + WII_STATE;
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) + "/" WII_STATE;
File::IOFile file;
StateFlags state;

View File

@ -227,7 +227,7 @@ bool CBoot::SetupWiiMemory()
SettingsHandler gen;
std::string serno;
const std::string settings_file_path(
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) + WII_SETTING);
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) + "/" WII_SETTING);
if (File::Exists(settings_file_path) && gen.Open(settings_file_path))
{
serno = gen.GetValue("SERNO");
@ -328,7 +328,7 @@ bool CBoot::SetupWiiMemory()
static void WriteEmptyPlayRecord()
{
const std::string file_path =
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) + "play_rec.dat";
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) + "/play_rec.dat";
File::IOFile playrec_file(file_path, "r+b");
std::vector<u8> empty_record(0x80);
playrec_file.WriteBytes(empty_record.data(), empty_record.size());

View File

@ -181,7 +181,7 @@ void CWiiSaveCrypted::ReadHDR()
m_valid = false;
return;
}
std::string banner_file_path = m_wii_title_path + "banner.bin";
std::string banner_file_path = m_wii_title_path + "/banner.bin";
if (!File::Exists(banner_file_path) ||
AskYesNoT("%s already exists. Consider making a backup of the current save files before "
"overwriting.\nOverwrite now?",
@ -203,7 +203,7 @@ void CWiiSaveCrypted::WriteHDR()
return;
memset(&m_header, 0, HEADER_SZ);
std::string banner_file_path = m_wii_title_path + "banner.bin";
std::string banner_file_path = m_wii_title_path + "/banner.bin";
u32 banner_size = static_cast<u32>(File::GetSize(banner_file_path));
m_header.hdr.BannerSize = Common::swap32(banner_size);
@ -347,7 +347,7 @@ void CWiiSaveCrypted::ImportWiiSaveFiles()
// Special characters in path components will be escaped such as /../
std::string file_path = Common::EscapePath(reinterpret_cast<const char*>(file_hdr_tmp.name));
std::string file_path_full = m_wii_title_path + file_path;
std::string file_path_full = m_wii_title_path + '/' + file_path;
File::CreateFullPath(file_path_full);
const File::FileInfo file_info(file_path_full);
if (file_hdr_tmp.type == 1)
@ -585,7 +585,7 @@ bool CWiiSaveCrypted::getPaths(bool for_export)
return false;
}
if (!File::Exists(m_wii_title_path + "banner.bin"))
if (!File::Exists(m_wii_title_path + "/banner.bin"))
{
m_valid = false;
ERROR_LOG(CONSOLE, "No banner file found for title %s", game_id);

View File

@ -42,7 +42,8 @@ static IOS::ES::TMDReader FindTMD(u64 title_id, const std::string& tmd_path)
IOS::ES::TMDReader ES::FindImportTMD(u64 title_id) const
{
return FindTMD(title_id, Common::GetImportTitlePath(title_id) + "/content/title.tmd");
return FindTMD(title_id, Common::GetImportTitlePath(title_id, Common::FROM_SESSION_ROOT) +
"/content/title.tmd");
}
IOS::ES::TMDReader ES::FindInstalledTMD(u64 title_id) const
@ -218,7 +219,8 @@ bool ES::InitImport(u64 title_id)
// IOS moves the title content directory to /import if the TMD exists during an import.
if (File::Exists(Common::GetTMDFileName(title_id, Common::FROM_SESSION_ROOT)))
{
const std::string import_content_dir = Common::GetImportTitlePath(title_id) + "/content";
const std::string import_content_dir =
Common::GetImportTitlePath(title_id, Common::FROM_SESSION_ROOT) + "/content";
File::CreateFullPath(import_content_dir);
if (!File::Rename(content_dir, import_content_dir))
{
@ -233,7 +235,8 @@ bool ES::InitImport(u64 title_id)
bool ES::FinishImport(const IOS::ES::TMDReader& tmd)
{
const u64 title_id = tmd.GetTitleId();
const std::string import_content_dir = Common::GetImportTitlePath(title_id) + "/content";
const std::string import_content_dir =
Common::GetImportTitlePath(title_id, Common::FROM_SESSION_ROOT) + "/content";
// Remove everything not listed in the TMD.
std::unordered_set<std::string> expected_entries = {"title.tmd"};
@ -274,7 +277,8 @@ bool ES::WriteImportTMD(const IOS::ES::TMDReader& tmd)
return false;
}
const std::string dest = Common::GetImportTitlePath(tmd.GetTitleId()) + "/content/title.tmd";
const std::string dest = Common::GetImportTitlePath(tmd.GetTitleId(), Common::FROM_SESSION_ROOT) +
"/content/title.tmd";
return File::Rename(tmd_path, dest);
}
@ -282,7 +286,8 @@ void ES::FinishStaleImport(u64 title_id)
{
const auto import_tmd = FindImportTMD(title_id);
if (!import_tmd.IsValid())
File::DeleteDirRecursively(Common::GetImportTitlePath(title_id) + "/content");
File::DeleteDirRecursively(Common::GetImportTitlePath(title_id, Common::FROM_SESSION_ROOT) +
"/content");
else
FinishImport(import_tmd);
}
@ -305,7 +310,7 @@ std::string ES::GetContentPath(const u64 title_id, const IOS::ES::Content& conte
return content_map.GetFilenameFromSHA1(content.sha1).value_or("");
return Common::GetTitleContentPath(title_id, Common::FROM_SESSION_ROOT) +
StringFromFormat("%08x.app", content.id);
StringFromFormat("/%08x.app", content.id);
}
} // namespace Device
} // namespace HLE

View File

@ -342,7 +342,8 @@ static bool CheckIfContentHashMatches(const std::vector<u8>& content, const IOS:
static std::string GetImportContentPath(u64 title_id, u32 content_id)
{
return Common::GetImportTitlePath(title_id) + StringFromFormat("/content/%08x.app", content_id);
return Common::GetImportTitlePath(title_id, Common::FROM_SESSION_ROOT) +
StringFromFormat("/content/%08x.app", content_id);
}
ReturnCode ES::ImportContentEnd(Context& context, u32 content_fd)
@ -604,7 +605,7 @@ ReturnCode ES::DeleteContent(u64 title_id, u32 content_id) const
return ES_EINVAL;
if (!File::Delete(Common::GetTitleContentPath(title_id, Common::FROM_SESSION_ROOT) +
StringFromFormat("%08x.app", content_id)))
StringFromFormat("/%08x.app", content_id)))
{
return FS_ENOENT;
}

View File

@ -83,7 +83,8 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_INITIAL)
{
const std::string settings_file_path(
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) + WII_SETTING);
Common::GetTitleDataPath(Titles::SYSTEM_MENU, Common::FROM_SESSION_ROOT) +
"/" WII_SETTING);
SettingsHandler gen;
std::string area, model;
bool got_settings = false;

View File

@ -1384,8 +1384,8 @@ void GetSettings()
if (SConfig::GetInstance().bWii)
{
u64 title_id = SConfig::GetInstance().GetTitleID();
s_bClearSave =
!File::Exists(Common::GetTitleDataPath(title_id, Common::FROM_SESSION_ROOT) + "banner.bin");
s_bClearSave = !File::Exists(Common::GetTitleDataPath(title_id, Common::FROM_SESSION_ROOT) +
"/banner.bin");
}
else
{

View File

@ -36,7 +36,7 @@ static void InitializeDeterministicWiiSaves()
else
{
// TODO: Check for the actual save data
Movie::SetClearSave(!File::Exists(user_save_path + "banner.bin"));
Movie::SetClearSave(!File::Exists(user_save_path + "/banner.bin"));
}
}
@ -44,7 +44,7 @@ static void InitializeDeterministicWiiSaves()
(Movie::IsMovieActive() && !Movie::IsStartingFromClearSave()))
{
// Copy the current user's save to the Blank NAND
if (File::Exists(user_save_path + "banner.bin"))
if (File::Exists(user_save_path + "/banner.bin"))
{
File::CopyDir(user_save_path, save_path);
}
@ -86,10 +86,10 @@ void ShutdownWiiRoot()
std::string user_backup_path = File::GetUserPath(D_BACKUP_IDX) +
StringFromFormat("%08x/%08x/", static_cast<u32>(title_id >> 32),
static_cast<u32>(title_id));
if (File::Exists(save_path + "banner.bin") && SConfig::GetInstance().bEnableMemcardSdWriting)
if (File::Exists(save_path + "/banner.bin") && SConfig::GetInstance().bEnableMemcardSdWriting)
{
// Backup the existing save just in case it's still needed.
if (File::Exists(user_save_path + "banner.bin"))
if (File::Exists(user_save_path + "/banner.bin"))
{
if (File::Exists(user_backup_path))
File::DeleteDirRecursively(user_backup_path);