dolphin/Source/Core/Common/NandPaths.h
Léo Lam 8317a66ea5 NandPaths: Return paths that are relative to Wii NAND
Since all FS access will go through the new FS interface (PR #6421)
in order to keep track of metadata properly, there is no need to return
absolute paths anymore.

In fact, returning host paths is a roadblock to using the FS interface.

This starts the migration work by adding a way to get paths that are
relative to the Wii NAND instead of always getting absolute paths
on the host FS.

To prepare for future changes, this commit also makes returned paths
canonical by removing the trailing slash when it's unneeded.

Eventually, once everything has been migrated to the new interface,
we can remove the "from" parameter.
2018-05-04 19:52:17 +02:00

46 lines
1.8 KiB
C++

// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <optional>
#include <string>
#include "Common/CommonTypes.h"
namespace Common
{
enum FromWhichRoot
{
FROM_CONFIGURED_ROOT, // not related to currently running game - use D_WIIROOT_IDX
FROM_SESSION_ROOT, // request from currently running game - use D_SESSION_WIIROOT_IDX
};
std::string RootUserPath(FromWhichRoot from);
// 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.
// 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, 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);
// Escapes characters that are invalid or have special meanings in the host file system
std::string EscapePath(const std::string& path);
// Reverses escaping done by EscapeFileName
std::string UnescapeFileName(const std::string& filename);
}