From 8f74d02659fe633f991b95422c731b784d6146a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 4 Jan 2020 01:55:40 +0100 Subject: [PATCH] Core: Fix a few misuses of FS::CreateDirectory CreateDirectory does not create missing parent directories. If that behaviour is desired, CreateFullPath should be used instead. (These small misuses went unnoticed since the previous implementation of CreateDirectory automatically created parent directories.) --- Source/Core/Core/NetPlayClient.cpp | 8 ++++---- Source/Core/Core/WiiRoot.cpp | 20 +++++++------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index c64a2769a4..e769fc599b 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -904,8 +904,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) { auto buffer = DecompressPacketIntoBuffer(packet); - temp_fs->CreateDirectory(IOS::PID_KERNEL, IOS::PID_KERNEL, "/shared2/menu/FaceLib", 0, - fs_modes); + temp_fs->CreateFullPath(IOS::PID_KERNEL, IOS::PID_KERNEL, "/shared2/menu/FaceLib/", 0, + fs_modes); auto file = temp_fs->CreateAndOpenFile(IOS::PID_KERNEL, IOS::PID_KERNEL, Common::GetMiiDatabasePath(), fs_modes); @@ -924,8 +924,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) { u64 title_id = Common::PacketReadU64(packet); titles.push_back(title_id); - temp_fs->CreateDirectory(IOS::PID_KERNEL, IOS::PID_KERNEL, - Common::GetTitleDataPath(title_id), 0, fs_modes); + temp_fs->CreateFullPath(IOS::PID_KERNEL, IOS::PID_KERNEL, + Common::GetTitleDataPath(title_id) + '/', 0, fs_modes); auto save = WiiSave::MakeNandStorage(temp_fs.get(), title_id); bool exists; diff --git a/Source/Core/Core/WiiRoot.cpp b/Source/Core/Core/WiiRoot.cpp index 06be93900a..538cc394fb 100644 --- a/Source/Core/Core/WiiRoot.cpp +++ b/Source/Core/Core/WiiRoot.cpp @@ -34,9 +34,8 @@ static std::string s_temp_wii_root; static void CopySave(FS::FileSystem* source, FS::FileSystem* dest, const u64 title_id) { - dest->CreateDirectory(IOS::PID_KERNEL, IOS::PID_KERNEL, Common::GetTitleDataPath(title_id), 0, - {IOS::HLE::FS::Mode::ReadWrite, IOS::HLE::FS::Mode::ReadWrite, - IOS::HLE::FS::Mode::ReadWrite}); + dest->CreateFullPath(IOS::PID_KERNEL, IOS::PID_KERNEL, Common::GetTitleDataPath(title_id) + '/', + 0, {FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite}); const auto source_save = WiiSave::MakeNandStorage(source, title_id); const auto dest_save = WiiSave::MakeNandStorage(dest, title_id); WiiSave::Copy(source_save.get(), dest_save.get()); @@ -49,9 +48,8 @@ static bool CopyNandFile(FS::FileSystem* source_fs, const std::string& source_fi if (last_slash != std::string::npos && last_slash > 0) { const std::string dir = dest_file.substr(0, last_slash); - dest_fs->CreateDirectory(IOS::PID_KERNEL, IOS::PID_KERNEL, dir, 0, - {IOS::HLE::FS::Mode::ReadWrite, IOS::HLE::FS::Mode::ReadWrite, - IOS::HLE::FS::Mode::ReadWrite}); + dest_fs->CreateFullPath(IOS::PID_KERNEL, IOS::PID_KERNEL, dir + '/', 0, + {FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite}); } auto source_handle = @@ -190,7 +188,7 @@ static bool CopySysmenuFilesToFS(FS::FileSystem* fs, const std::string& host_sou if (entry.isDirectory) { - fs->CreateDirectory(IOS::SYSMENU_UID, IOS::SYSMENU_GID, nand_path, 0, public_modes); + fs->CreateFullPath(IOS::SYSMENU_UID, IOS::SYSMENU_GID, nand_path + '/', 0, public_modes); if (!CopySysmenuFilesToFS(fs, host_path, nand_path)) return false; } @@ -259,12 +257,8 @@ void CleanUpWiiFileSystemContents() // FS won't write the save if the directory doesn't exist const std::string title_path = Common::GetTitleDataPath(title_id); - if (!configured_fs->GetMetadata(IOS::PID_KERNEL, IOS::PID_KERNEL, title_path)) - { - configured_fs->CreateDirectory(IOS::PID_KERNEL, IOS::PID_KERNEL, title_path, 0, - {IOS::HLE::FS::Mode::ReadWrite, IOS::HLE::FS::Mode::ReadWrite, - IOS::HLE::FS::Mode::ReadWrite}); - } + configured_fs->CreateFullPath(IOS::PID_KERNEL, IOS::PID_KERNEL, title_path + '/', 0, + {FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite}); const auto user_save = WiiSave::MakeNandStorage(configured_fs.get(), title_id);