Restore /dev_flash/ config

This commit is contained in:
Nekotekina 2018-06-23 09:26:11 +03:00
parent cd92d9bcdf
commit d62b0c88b0
11 changed files with 48 additions and 16 deletions

View File

@ -140,11 +140,11 @@ namespace rsx
fallback_fonts.push_back("/usr/share/fonts/TTF/DejaVuSans.ttf"); //arch
#endif
//Search dev_flash for the font too
font_dirs.push_back(fs::get_config_dir() + "dev_flash/data/font/");
font_dirs.push_back(fs::get_config_dir() + "dev_flash/data/font/SONY-CC/");
font_dirs.push_back(g_cfg.vfs.get_dev_flash() + "data/font/");
font_dirs.push_back(g_cfg.vfs.get_dev_flash() + "data/font/SONY-CC/");
//Attempt to load a font from dev_flash as a last resort
fallback_fonts.push_back(fs::get_config_dir() + "dev_flash/data/font/SCE-PS3-VR-R-LATIN.TTF");
fallback_fonts.push_back(g_cfg.vfs.get_dev_flash() + "data/font/SCE-PS3-VR-R-LATIN.TTF");
//Attemt to load requested font
std::string file_path;

View File

@ -679,7 +679,7 @@ void Emulator::Load(bool add_only)
vfs::mount("", fs::get_config_dir() + "delete_this_dir/");
vfs::mount("dev_hdd0", fmt::replace_all(g_cfg.vfs.dev_hdd0, "$(EmulatorDir)", emu_dir));
vfs::mount("dev_hdd1", fmt::replace_all(g_cfg.vfs.dev_hdd1, "$(EmulatorDir)", emu_dir));
vfs::mount("dev_flash", fs::get_config_dir() + "dev_flash/");
vfs::mount("dev_flash", g_cfg.vfs.get_dev_flash());
vfs::mount("dev_usb", fmt::replace_all(g_cfg.vfs.dev_usb000, "$(EmulatorDir)", emu_dir));
vfs::mount("dev_usb000", fmt::replace_all(g_cfg.vfs.dev_usb000, "$(EmulatorDir)", emu_dir));
vfs::mount("app_home", home_dir.empty() ? elf_dir + '/' : fmt::replace_all(home_dir, "$(EmulatorDir)", emu_dir));
@ -1362,6 +1362,16 @@ void Emulator::Stop(bool restart)
m_force_boot = false;
}
std::string cfg_root::node_vfs::get(const cfg::string& _cfg, const char* _def) const
{
if (_cfg.get().empty())
{
return fs::get_config_dir() + _def;
}
return fmt::replace_all(_cfg.get(), "$(EmulatorDir)", emulator_dir.get().empty() ? fs::get_config_dir() : emulator_dir.get());
}
s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_info* sup2, u64 arg2)
{
static thread_local std::unordered_map<std::string, std::size_t> g_tls_error_stats;

View File

@ -354,13 +354,21 @@ struct cfg_root : cfg::node
{
node_vfs(cfg::node* _this) : cfg::node(_this, "VFS") {}
std::string get(const cfg::string&, const char*) const;
cfg::string emulator_dir{this, "$(EmulatorDir)"}; // Default (empty): taken from fs::get_config_dir()
cfg::string dev_hdd0{this, "/dev_hdd0/", "$(EmulatorDir)dev_hdd0/"};
cfg::string dev_hdd1{this, "/dev_hdd1/", "$(EmulatorDir)dev_hdd1/"};
cfg::string dev_flash{this, "/dev_flash/"};
cfg::string dev_usb000{this, "/dev_usb000/", "$(EmulatorDir)dev_usb000/"};
cfg::string dev_bdvd{this, "/dev_bdvd/"}; // Not mounted
cfg::string app_home{this, "/app_home/"}; // Not mounted
std::string get_dev_flash() const
{
return get(dev_flash, "dev_flash/");
}
cfg::_bool host_root{this, "Enable /host_root/"};
} vfs{this};

View File

@ -86,12 +86,12 @@ fs::file tar_object::get_file(std::string path)
largest_offset = offset;
}
}
return fs::file();
}
}
bool tar_object::extract(std::string path)
bool tar_object::extract(std::string path, std::string ignore)
{
if (!m_file) return false;
@ -99,25 +99,32 @@ bool tar_object::extract(std::string path)
for (auto iter : m_map)
{
TARHeader header = read_header(iter.second);
if (std::string(header.name).empty()) continue;
if (!header.name[0]) continue;
std::string result = path + header.name;
if (result.compare(path.size(), ignore.size(), ignore) == 0)
{
result.erase(path.size(), ignore.size());
}
switch (header.filetype)
{
case '0':
{
fs::file file(path + header.name, fs::rewrite);
fs::file file(result, fs::rewrite);
file.write(get_file(header.name).to_vector<u8>());
break;
}
case '5':
{
fs::create_dir(path + header.name);
fs::create_dir(result);
break;
}
default:
LOG_ERROR(GENERAL,"Tar loader: unknown file type: %c", header.filetype);
LOG_ERROR(GENERAL, "TAR Loader: unknown file type: 0x%x", header.filetype);
return false;
}
}

View File

@ -34,5 +34,5 @@ public:
fs::file get_file(std::string path);
bool extract(std::string path); // extract all files in archive to path
bool extract(std::string path, std::string ignore = ""); // extract all files in archive to path
};

View File

@ -397,7 +397,7 @@ void rpcs3_app::OnChangeStyleSheetRequest(const QString& sheetFilePath)
QString config_dir = qstr(fs::get_config_dir());
// Add PS3 fonts
QDirIterator ps3_font_it(qstr(fs::get_config_dir() + "dev_flash/data/font/"), QStringList() << "*.ttf", QDir::Files, QDirIterator::Subdirectories);
QDirIterator ps3_font_it(qstr(g_cfg.vfs.get_dev_flash() + "data/font/"), QStringList() << "*.ttf", QDir::Files, QDirIterator::Subdirectories);
while (ps3_font_it.hasNext())
QFontDatabase::addApplicationFont(ps3_font_it.next());

View File

@ -111,6 +111,7 @@ public:
emulatorLocation,
dev_hdd0Location,
dev_hdd1Location,
dev_flashLocation,
dev_usb000Location,
};
@ -280,6 +281,7 @@ private:
{ emulatorLocation, { "VFS", "$(EmulatorDir)"}},
{ dev_hdd0Location, { "VFS", "/dev_hdd0/" }},
{ dev_hdd1Location, { "VFS", "/dev_hdd1/" }},
{ dev_flashLocation, { "VFS", "/dev_flash/"}},
{ dev_usb000Location, { "VFS", "/dev_usb000/"}},
};

View File

@ -180,6 +180,7 @@ namespace gui
const gui_save fs_emulator_dir_list = gui_save(fs, "emulator_dir_list", QStringList());
const gui_save fs_dev_hdd0_list = gui_save(fs, "dev_hdd0_list", QStringList());
const gui_save fs_dev_hdd1_list = gui_save(fs, "dev_hdd1_list", QStringList());
const gui_save fs_dev_flash_list = gui_save(fs, "dev_flash_list", QStringList());
const gui_save fs_dev_usb000_list = gui_save(fs, "dev_usb000_list", QStringList());
const gui_save l_tty = gui_save(logger, "TTY", true);

View File

@ -566,7 +566,7 @@ void main_window::InstallPup(const QString& dropPath)
}
tar_object dev_flash_tar(dev_flash_tar_f[2]);
if (!dev_flash_tar.extract(fs::get_config_dir()))
if (!dev_flash_tar.extract(g_cfg.vfs.get_dev_flash(), "dev_flash/"))
{
LOG_ERROR(GENERAL, "Error while installing firmware: TAR contents are invalid.");
QMessageBox::critical(this, tr("Failure!"), tr("Error while installing firmware: TAR contents are invalid."));
@ -607,7 +607,7 @@ void main_window::InstallPup(const QString& dropPath)
guiSettings->ShowInfoBox(gui::ib_pup_success, tr("Success!"), tr("Successfully installed PS3 firmware and LLE Modules!"), this);
Emu.SetForceBoot(true);
Emu.BootGame(fs::get_config_dir() + "dev_flash/sys/external/", true);
Emu.BootGame(g_cfg.vfs.get_dev_flash() + "sys/external/", true);
}
}

View File

@ -300,7 +300,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
ui->lleList->addItem(item);
}
const std::string lle_dir = fs::get_config_dir() + "dev_flash/sys/external/";
const std::string lle_dir = g_cfg.vfs.get_dev_flash() + "sys/external/";
std::unordered_set<std::string> set(loadedLibs.begin(), loadedLibs.end());
std::vector<std::string> lle_module_list_unselected;

View File

@ -22,12 +22,16 @@ vfs_dialog::vfs_dialog(std::shared_ptr<gui_settings> guiSettings, std::shared_pt
vfs_dialog_tab* dev_hdd1_tab = new vfs_dialog_tab({ "dev_hdd1", emu_settings::dev_hdd1Location, gui::fs_dev_hdd1_list, &g_cfg.vfs.dev_hdd1 },
m_gui_settings, m_emu_settings, this);
vfs_dialog_tab* dev_flash_tab = new vfs_dialog_tab({ "dev_flash", emu_settings::dev_flashLocation, gui::fs_dev_flash_list, &g_cfg.vfs.dev_flash },
m_gui_settings, m_emu_settings, this);
vfs_dialog_tab* dev_usb000_tab = new vfs_dialog_tab({ "dev_usb000", emu_settings::dev_usb000Location, gui::fs_dev_usb000_list, &g_cfg.vfs.dev_usb000 },
m_gui_settings, m_emu_settings, this);
tabs->addTab(emulator_tab, "$(EmulatorDir)");
tabs->addTab(dev_hdd0_tab, "dev_hdd0");
tabs->addTab(dev_hdd1_tab, "dev_hdd1");
tabs->addTab(dev_flash_tab, "dev_flash");
tabs->addTab(dev_usb000_tab, "dev_usb000");
// Create buttons