Debian Codegraph @

Source/Core/Common/NandPaths.h

raw symbols SCIP
1 // Copyright 2008 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <optional>
7 #include <string>
8
9 #include "Common/CommonTypes.h"
10
11 namespace Common
12 {
13 enum class FromWhichRoot
14 {
15 Configured, // not related to currently running game - use D_WIIROOT_IDX
16 Session, // request from currently running game - use D_SESSION_WIIROOT_IDX
17 Banners, // fallback for Wii savegame banners - use D_BANNERS_WIIROOT_IDX
18 };
19
20 std::string RootUserPath(FromWhichRoot from);
21
22 // The following functions return paths relative to the NAND root.
23 // If a FromWhichRoot is passed, the NAND root on the host filesystem will be prepended to the path.
24 // TODO: remove the from parameter after all code is migrated off direct FS access.
25
26 // Returns /import/%08x/%08x. Intended for use by ES.
27 std::string GetImportTitlePath(u64 title_id, std::optional<FromWhichRoot> from = {});
28
29 std::string GetTicketFileName(u64 title_id, std::optional<FromWhichRoot> from = {});
30 std::string GetV1TicketFileName(u64 title_id, std::optional<FromWhichRoot> from = {});
31 std::string GetTitlePath(u64 title_id, std::optional<FromWhichRoot> from = {});
32 std::string GetTitleDataPath(u64 title_id, std::optional<FromWhichRoot> from = {});
33 std::string GetTitleContentPath(u64 title_id, std::optional<FromWhichRoot> from = {});
34 std::string GetTMDFileName(u64 title_id, std::optional<FromWhichRoot> from = {});
35 std::string GetMiiDatabasePath(std::optional<FromWhichRoot> from = {});
36
37 // Returns whether a path is within an installed title's directory.
38 bool IsTitlePath(const std::string& path, std::optional<FromWhichRoot> from = {},
39 u64* title_id = nullptr);
40
41 // Escapes characters that are invalid or have special meanings in the host file system
42 std::string EscapeFileName(const std::string& filename);
43 // Escapes characters that are invalid or have special meanings in the host file system
44 std::string EscapePath(const std::string& path);
45 // Reverses escaping done by EscapeFileName
46 std::string UnescapeFileName(const std::string& filename);
47 // Tests for a file name being "safe" as per the escaping defined in EscapeFileName
48 bool IsFileNameSafe(const std::string_view filename);
49 } // namespace Common