summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorSepalani <sepalani@hotmail.fr>2018-12-01 18:22:54 +0400
committerSepalani <sepalani@hotmail.fr>2018-12-01 22:28:58 +0400
commit5bb7cd251e7d3ea818a55f84601a6904a379786e (patch)
tree65dbf3699e80e219bc1c84e5cbe5d548bad564e4 /Source/Core
parentf351280061635f455e783e07fa9616fb872de1c0 (diff)
WFSI: Handle PATCH_TYPE_2 properly in IOCTL_WFSI_FINALIZE_TITLE_INSTALL
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/IOS/WFS/WFSI.cpp66
-rw-r--r--Source/Core/Core/IOS/WFS/WFSI.h1
2 files changed, 49 insertions, 18 deletions
diff --git a/Source/Core/Core/IOS/WFS/WFSI.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp
index 0694ca0c42..ac18c400c1 100644
--- a/Source/Core/Core/IOS/WFS/WFSI.cpp
+++ b/Source/Core/Core/IOS/WFS/WFSI.cpp
@@ -117,6 +117,15 @@ void WFSI::SetImportTitleIdAndGroupId(u64 tid, u16 gid)
m_import_group_id_str = GroupIdStr(gid);
}
+void WFSI::FinalizePatchInstall()
+{
+ const std::string current_title_dir =
+ StringFromFormat("/vol/%s/title/%s/%s", m_device_name.c_str(), m_current_group_id_str.c_str(),
+ m_current_title_id_str.c_str());
+ const std::string patch_dir = current_title_dir + "/_patch";
+ File::CopyDir(WFS::NativePath(patch_dir), WFS::NativePath(current_title_dir), true);
+}
+
IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
{
s32 return_error_code = IPC_SUCCESS;
@@ -258,20 +267,31 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
case IOCTL_WFSI_FINALIZE_TITLE_INSTALL:
{
std::string tmd_path;
- if (m_patch_type == NOT_A_PATCH)
+
+ switch (m_patch_type)
{
- std::string title_install_dir = StringFromFormat("/vol/%s/_install/%s", m_device_name.c_str(),
- m_import_title_id_str.c_str());
- std::string title_final_dir =
- StringFromFormat("/vol/%s/title/%s/%s", m_device_name.c_str(),
- m_import_group_id_str.c_str(), m_import_title_id_str.c_str());
- File::Rename(WFS::NativePath(title_install_dir), WFS::NativePath(title_final_dir));
+ case PATCH_TYPE_2:
+ {
+ // Delete content's default.dol
+ const std::string title_content_dir =
+ StringFromFormat("/vol/%s/title/%s/%s/content/", m_device_name.c_str(),
+ m_current_group_id_str.c_str(), m_current_title_id_str.c_str());
+ File::Delete(WFS::NativePath(title_content_dir + "default.dol"));
- tmd_path = StringFromFormat("/vol/%s/title/%s/%s/meta/%016" PRIx64 ".tmd",
- m_device_name.c_str(), m_import_group_id_str.c_str(),
- m_import_title_id_str.c_str(), m_import_title_id);
+ // Copy content's _default.dol to patch's directory
+ const std::string patch_dir =
+ StringFromFormat("/vol/%s/title/%s/%s/_patch/", m_device_name.c_str(),
+ m_current_group_id_str.c_str(), m_current_title_id_str.c_str());
+ const std::string patch_content_dir = patch_dir + "content/";
+ File::CreateDir(WFS::NativePath(patch_dir));
+ File::CreateDir(WFS::NativePath(patch_content_dir));
+ File::Rename(WFS::NativePath(title_content_dir + "_default.dol"),
+ WFS::NativePath(patch_content_dir + "default.dol"));
+
+ FinalizePatchInstall();
+ [[fallthrough]];
}
- else
+ case PATCH_TYPE_1:
{
std::string patch_dir =
StringFromFormat("/vol/%s/title/%s/%s/_patch", m_device_name.c_str(),
@@ -281,6 +301,22 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
tmd_path = StringFromFormat("/vol/%s/title/%s/%s/meta/%016" PRIx64 ".tmd",
m_device_name.c_str(), m_current_group_id_str.c_str(),
m_current_title_id_str.c_str(), m_import_title_id);
+ break;
+ }
+ case NOT_A_PATCH:
+ {
+ std::string title_install_dir = StringFromFormat("/vol/%s/_install/%s", m_device_name.c_str(),
+ m_import_title_id_str.c_str());
+ std::string title_final_dir =
+ StringFromFormat("/vol/%s/title/%s/%s", m_device_name.c_str(),
+ m_import_group_id_str.c_str(), m_import_title_id_str.c_str());
+ File::Rename(WFS::NativePath(title_install_dir), WFS::NativePath(title_final_dir));
+
+ tmd_path = StringFromFormat("/vol/%s/title/%s/%s/meta/%016" PRIx64 ".tmd",
+ m_device_name.c_str(), m_import_group_id_str.c_str(),
+ m_import_title_id_str.c_str(), m_import_title_id);
+ break;
+ }
}
File::IOFile tmd_file(WFS::NativePath(tmd_path), "wb");
@@ -292,13 +328,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
{
INFO_LOG(IOS_WFS, "IOCTL_WFSI_FINALIZE_PATCH_INSTALL");
if (m_patch_type != NOT_A_PATCH)
- {
- std::string current_title_dir =
- StringFromFormat("/vol/%s/title/%s/%s", m_device_name.c_str(),
- m_current_group_id_str.c_str(), m_current_title_id_str.c_str());
- std::string patch_dir = current_title_dir + "/_patch";
- File::CopyDir(WFS::NativePath(patch_dir), WFS::NativePath(current_title_dir), true);
- }
+ FinalizePatchInstall();
break;
}
diff --git a/Source/Core/Core/IOS/WFS/WFSI.h b/Source/Core/Core/IOS/WFS/WFSI.h
index c862493775..2434289bb7 100644
--- a/Source/Core/Core/IOS/WFS/WFSI.h
+++ b/Source/Core/Core/IOS/WFS/WFSI.h
@@ -46,6 +46,7 @@ private:
void SetCurrentTitleIdAndGroupId(u64 tid, u16 gid);
void SetImportTitleIdAndGroupId(u64 tid, u16 gid);
+ void FinalizePatchInstall();
s32 CancelTitleImport(bool continue_install);
s32 CancelPatchImport(bool continue_install);