mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge pull request #6651 from leoetlino/nand-paths
NandPaths: Return paths that are relative to Wii NAND
This commit is contained in:
@ -21,41 +21,46 @@ std::string RootUserPath(FromWhichRoot from)
|
||||
return File::GetUserPath(idx);
|
||||
}
|
||||
|
||||
std::string GetImportTitlePath(u64 title_id, FromWhichRoot from)
|
||||
static std::string RootUserPath(std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return from ? RootUserPath(*from) : "";
|
||||
}
|
||||
|
||||
std::string GetImportTitlePath(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return RootUserPath(from) + StringFromFormat("/import/%08x/%08x",
|
||||
static_cast<u32>(title_id >> 32),
|
||||
static_cast<u32>(title_id));
|
||||
}
|
||||
|
||||
std::string GetTicketFileName(u64 title_id, FromWhichRoot from)
|
||||
std::string GetTicketFileName(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return StringFromFormat("%s/ticket/%08x/%08x.tik", RootUserPath(from).c_str(),
|
||||
static_cast<u32>(title_id >> 32), static_cast<u32>(title_id));
|
||||
}
|
||||
|
||||
std::string GetTitlePath(u64 title_id, FromWhichRoot from)
|
||||
std::string GetTitlePath(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return StringFromFormat("%s/title/%08x/%08x/", RootUserPath(from).c_str(),
|
||||
return StringFromFormat("%s/title/%08x/%08x", RootUserPath(from).c_str(),
|
||||
static_cast<u32>(title_id >> 32), static_cast<u32>(title_id));
|
||||
}
|
||||
|
||||
std::string GetTitleDataPath(u64 title_id, FromWhichRoot from)
|
||||
std::string GetTitleDataPath(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return GetTitlePath(title_id, from) + "data/";
|
||||
return GetTitlePath(title_id, from) + "/data";
|
||||
}
|
||||
|
||||
std::string GetTitleContentPath(u64 title_id, FromWhichRoot from)
|
||||
std::string GetTitleContentPath(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return GetTitlePath(title_id, from) + "content/";
|
||||
return GetTitlePath(title_id, from) + "/content";
|
||||
}
|
||||
|
||||
std::string GetTMDFileName(u64 title_id, FromWhichRoot from)
|
||||
std::string GetTMDFileName(u64 title_id, std::optional<FromWhichRoot> from)
|
||||
{
|
||||
return GetTitleContentPath(title_id, from) + "title.tmd";
|
||||
return GetTitleContentPath(title_id, from) + "/title.tmd";
|
||||
}
|
||||
|
||||
bool IsTitlePath(const std::string& path, FromWhichRoot from, u64* title_id)
|
||||
bool IsTitlePath(const std::string& path, std::optional<FromWhichRoot> from, u64* title_id)
|
||||
{
|
||||
std::string expected_prefix = RootUserPath(from) + "/title/";
|
||||
if (!StringBeginsWith(path, expected_prefix))
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -18,17 +19,22 @@ enum FromWhichRoot
|
||||
|
||||
std::string RootUserPath(FromWhichRoot from);
|
||||
|
||||
// Returns /import/%08x/%08x. Intended for use by ES.
|
||||
std::string GetImportTitlePath(u64 title_id, FromWhichRoot from = FROM_SESSION_ROOT);
|
||||
// The following functions return paths relative to the NAND root.
|
||||
// If a FromWhichRoot is passed, the NAND root on the host filesystem will be prepended to the path.
|
||||
// TODO: remove the from parameter after all code is migrated off direct FS access.
|
||||
|
||||
std::string GetTicketFileName(u64 title_id, FromWhichRoot from);
|
||||
std::string GetTitlePath(u64 title_id, FromWhichRoot from);
|
||||
std::string GetTitleDataPath(u64 title_id, FromWhichRoot from);
|
||||
std::string GetTitleContentPath(u64 title_id, FromWhichRoot from);
|
||||
std::string GetTMDFileName(u64 title_id, FromWhichRoot from);
|
||||
// Returns /import/%08x/%08x. Intended for use by ES.
|
||||
std::string GetImportTitlePath(u64 title_id, std::optional<FromWhichRoot> from = {});
|
||||
|
||||
std::string GetTicketFileName(u64 title_id, std::optional<FromWhichRoot> from = {});
|
||||
std::string GetTitlePath(u64 title_id, std::optional<FromWhichRoot> from = {});
|
||||
std::string GetTitleDataPath(u64 title_id, std::optional<FromWhichRoot> from = {});
|
||||
std::string GetTitleContentPath(u64 title_id, std::optional<FromWhichRoot> from = {});
|
||||
std::string GetTMDFileName(u64 title_id, std::optional<FromWhichRoot> from = {});
|
||||
|
||||
// Returns whether a path is within an installed title's directory.
|
||||
bool IsTitlePath(const std::string& path, FromWhichRoot from, u64* title_id = nullptr);
|
||||
bool IsTitlePath(const std::string& path, std::optional<FromWhichRoot> from = {},
|
||||
u64* title_id = nullptr);
|
||||
|
||||
// Escapes characters that are invalid or have special meanings in the host file system
|
||||
std::string EscapeFileName(const std::string& filename);
|
||||
|
Reference in New Issue
Block a user