summaryrefslogtreecommitdiff
path: root/Source/Core/Common/NandPaths.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2017-08-15 22:40:56 +0200
committerGitHub <noreply@github.com>2017-08-15 22:40:56 +0200
commit9b79e0ac728529de850aef2df30d155aba350352 (patch)
treeec7829a630f0622755d2d4e9f5c90d427115276f /Source/Core/Common/NandPaths.cpp
parent8fedd4fa0662daebcff91b82203773000d0b0ae7 (diff)
parent40c70469e5cf20124e49f8c41827173e87cbda3f (diff)
Merge pull request #5930 from delroth/wfs
Fix Dragon Quest X offline mode on Dolphin
Diffstat (limited to 'Source/Core/Common/NandPaths.cpp')
-rw-r--r--Source/Core/Common/NandPaths.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/Source/Core/Common/NandPaths.cpp b/Source/Core/Common/NandPaths.cpp
index 1fcbab38be..ec43b38484 100644
--- a/Source/Core/Common/NandPaths.cpp
+++ b/Source/Core/Common/NandPaths.cpp
@@ -58,6 +58,35 @@ std::string GetTMDFileName(u64 _titleID, FromWhichRoot from)
return GetTitleContentPath(_titleID, from) + "title.tmd";
}
+bool IsTitlePath(const std::string& path, FromWhichRoot from, u64* title_id)
+{
+ std::string expected_prefix = RootUserPath(from) + "/title/";
+ if (!StringBeginsWith(path, expected_prefix))
+ {
+ return false;
+ }
+
+ // Try to find a title ID in the remaining path.
+ std::string subdirectory = path.substr(expected_prefix.size());
+ std::vector<std::string> components = SplitString(subdirectory, '/');
+ if (components.size() < 2)
+ {
+ return false;
+ }
+
+ u32 title_id_high, title_id_low;
+ if (!AsciiToHex(components[0], title_id_high) || !AsciiToHex(components[1], title_id_low))
+ {
+ return false;
+ }
+
+ if (title_id != nullptr)
+ {
+ *title_id = (static_cast<u64>(title_id_high) << 32) | title_id_low;
+ }
+ return true;
+}
+
std::string EscapeFileName(const std::string& filename)
{
// Prevent paths from containing special names like ., .., ..., ...., and so on