Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VFS: Fix mounting non-existant paths #13488

Merged
merged 5 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rpcs3/Emu/VFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ bool vfs::mount(std::string_view vpath, std::string_view path, bool is_dir)
{
// Mounting completed; fixup for directories due to resolve_path messing with trailing /
list.back()->path = Emu.GetCallbacks().resolve_path(path);
if (list.back()->path.empty())
list.back()->path = std::string(path); // Fallback when resolving failed
if (is_dir && !list.back()->path.ends_with('/'))
list.back()->path += '/';
if (!is_dir && list.back()->path.ends_with('/'))
Expand Down
11 changes: 10 additions & 1 deletion rpcs3/main_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QFileInfo> // This shouldn't be outside rpcs3qt...
#include <QImageReader> // This shouldn't be outside rpcs3qt...
#include <thread>
#include <iostream>

LOG_CHANNEL(sys_log, "SYS");

Expand Down Expand Up @@ -327,7 +328,15 @@ EmuCallbacks main_application::CreateCallbacks()

callbacks.resolve_path = [](std::string_view sv)
{
return QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();
const std::string result = QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();

if (result.empty())
{
// May fail if path does not exist
std::clog << fmt::format("main_application: resolve_path(): Failed to resolve path \'%s\'\n", sv);
}

return result;
};

return callbacks;
Expand Down