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

Deprecate HDD0/disc, make RPCS3/games movable #13265

Merged
merged 6 commits into from Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 17 additions & 11 deletions rpcs3/Emu/System.cpp
Expand Up @@ -408,7 +408,18 @@ void Emulator::Init(bool add_only)
}
}

make_path_verbose(dev_hdd0 + "disc/");
const std::string games_common_dir = g_cfg_vfs.get(g_cfg_vfs.games_dir, emu_dir);

if (make_path_verbose(games_common_dir))
{
fs::write_file(games_common_dir + "/Disc Games Can Be Put Here For Automatic Detection.txt", fs::create + fs::excl + fs::write, ""s);

if (std::string rpcs3_shortcuts = games_common_dir + "/shortcuts"; make_path_verbose(rpcs3_shortcuts))
{
fs::write_file(rpcs3_shortcuts + "/Copyable Shortcuts For Installed Games Would Be Added Here.txt", fs::create + fs::excl + fs::write, ""s);
Megamouse marked this conversation as resolved.
Show resolved Hide resolved
}
}

make_path_verbose(dev_hdd0 + "savedata/");
make_path_verbose(dev_hdd0 + "savedata/vmc/");
make_path_verbose(dev_hdd0 + "photo/");
Expand All @@ -422,11 +433,6 @@ void Emulator::Init(bool add_only)
make_path_verbose(fs::get_config_dir() + "sounds/");
make_path_verbose(patch_engine::get_patches_path());

if (const std::string games_common = fs::get_config_dir() + "/games/"; make_path_verbose(games_common))
{
fs::write_file(games_common + "/Disc Games Can Be Put Here For Automatic Detection.txt", fs::create + fs::excl + fs::write, ""s);
}

if (add_only)
{
// We don't need to initialize the rest if we only add games
Expand Down Expand Up @@ -1459,18 +1465,18 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
// Booting disc game from wrong location
sys_log.error("Disc game %s found at invalid location /dev_hdd0/game/", m_title_id);

const std::string hdd0_disc = vfs::get("/dev_hdd0/disc/");
const std::string dst_dir = hdd0_disc + sfb_dir.substr(hdd0_game.size());
const std::string games_common = g_cfg_vfs.get(g_cfg_vfs.games_dir, rpcs3::utils::get_emu_dir());
const std::string dst_dir = games_common + sfb_dir.substr(hdd0_game.size());

// Move and retry from correct location
if (fs::create_path(fs::get_parent_dir(dst_dir)) && fs::rename(sfb_dir, dst_dir, false))
{
sys_log.success("Disc game %s moved to special location /dev_hdd0/disc/", m_title_id);
m_path = hdd0_disc + m_path.substr(hdd0_game.size());
sys_log.success("Disc game %s moved to special location '%s'", m_title_id, dst_dir);
m_path = games_common + m_path.substr(hdd0_game.size());
return Load(m_title_id, add_only);
}

sys_log.error("Failed to move disc game %s to /dev_hdd0/disc/ (%s)", m_title_id, fs::g_tls_error);
sys_log.error("Failed to move disc game %s to '%s' (%s)", m_title_id, dst_dir, fs::g_tls_error);
return game_boot_result::wrong_disc_location;
}
}
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/vfs_config.h
Expand Up @@ -16,6 +16,7 @@ struct cfg_vfs : cfg::node
cfg::string dev_flash2{ this, "/dev_flash2/", "$(EmulatorDir)dev_flash2/" };
cfg::string dev_flash3{ this, "/dev_flash3/", "$(EmulatorDir)dev_flash3/" };
cfg::string dev_bdvd{ this, "/dev_bdvd/", "$(EmulatorDir)dev_bdvd/" }; // Only mounted in some special cases
cfg::string games_dir{ this, "/games/", "$(EmulatorDir)games/" }; // Not mounted
cfg::string app_home{ this, "/app_home/" }; // Not mounted

cfg::device_entry dev_usb{ this, "/dev_usb***/",
Expand Down
10 changes: 8 additions & 2 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Expand Up @@ -456,7 +456,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)

if (Emu.IsStopped())
{
Emu.AddGamesFromDir(fs::get_config_dir() + "/games");
Emu.AddGamesFromDir(g_cfg_vfs.get(g_cfg_vfs.games_dir, rpcs3::utils::get_emu_dir()));
}

const std::string _hdd = rpcs3::utils::get_hdd0_dir();
Expand Down Expand Up @@ -514,7 +514,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
};

add_dir(_hdd + "game/", false);
add_dir(_hdd + "disc/", true);
add_dir(_hdd + "disc/", true); // Deprecated

auto get_games = []() -> YAML::Node
{
Expand Down Expand Up @@ -564,6 +564,12 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
if (frag.find_first_of('/') + 1 == 0)
{
game_list_log.trace("Removed duplicate for %s: %s", pair.first.Scalar(), pair.second.Scalar());

if (static std::unordered_set<std::string> warn_once_list; warn_once_list.emplace(game_dir).second)
{
game_list_log.todo("Game at '%s' is using deprecated directory '/dev_hdd0/disc/'.\nConsider moving into '%s'.", game_dir, g_cfg_vfs.get(g_cfg_vfs.games_dir, rpcs3::utils::get_emu_dir()));
}

continue;
}
}
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/gui_settings.h
Expand Up @@ -190,6 +190,7 @@ namespace gui
const gui_save fs_dev_flash2_list = gui_save(fs, "dev_flash2_list", QStringList());
const gui_save fs_dev_flash3_list = gui_save(fs, "dev_flash3_list", QStringList());
const gui_save fs_dev_bdvd_list = gui_save(fs, "dev_bdvd_list", QStringList());
const gui_save fs_games_list = gui_save(fs, "games_list", QStringList());
const gui_save fs_dev_usb_list = gui_save(fs, "dev_usb00X_list", QStringList()); // Used as a template for all usb paths

const gui_save l_tty = gui_save(logger, "TTY", true);
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/rpcs3qt/vfs_dialog.cpp
Expand Up @@ -34,6 +34,7 @@ vfs_dialog::vfs_dialog(std::shared_ptr<gui_settings> _gui_settings, QWidget* par
vfs_dialog_tab* dev_flash3_tab = new vfs_dialog_tab("dev_flash3", gui::fs_dev_flash3_list, &g_cfg_vfs.dev_flash3, m_gui_settings, this);
vfs_dialog_tab* dev_bdvd_tab = new vfs_dialog_tab("dev_bdvd", gui::fs_dev_bdvd_list, &g_cfg_vfs.dev_bdvd, m_gui_settings, this);
vfs_dialog_usb_tab* dev_usb_tab = new vfs_dialog_usb_tab(&g_cfg_vfs.dev_usb, m_gui_settings, this);
vfs_dialog_tab* games_tab = new vfs_dialog_tab("games", gui::fs_games_list, &g_cfg_vfs.games_dir, m_gui_settings, this);

tabs->addTab(emulator_tab, "$(EmulatorDir)");
tabs->addTab(dev_hdd0_tab, "dev_hdd0");
Expand All @@ -43,6 +44,7 @@ vfs_dialog::vfs_dialog(std::shared_ptr<gui_settings> _gui_settings, QWidget* par
tabs->addTab(dev_flash3_tab, "dev_flash3");
tabs->addTab(dev_bdvd_tab, "dev_bdvd");
tabs->addTab(dev_usb_tab, "dev_usb");
tabs->addTab(games_tab, "games");

// Create buttons
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close | QDialogButtonBox::Save | QDialogButtonBox::RestoreDefaults);
Expand Down