mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-08-31 09:09:08 +01:00
filesystem: Make CreateFactories() and InstallInterface() take a VfsFilesystem instance by reference
Neither of these functions alter the ownership of the provided pointer, so we can simply make the parameters a reference rather than a direct shared pointer alias. This way we also disallow passing incorrect memory values like nullptr.
This commit is contained in:
parent
1584fb6b38
commit
0149162dba
7 changed files with 19 additions and 20 deletions
|
@ -148,7 +148,7 @@ struct System::Impl {
|
||||||
telemetry_session = std::make_unique<Core::TelemetrySession>();
|
telemetry_session = std::make_unique<Core::TelemetrySession>();
|
||||||
service_manager = std::make_shared<Service::SM::ServiceManager>();
|
service_manager = std::make_shared<Service::SM::ServiceManager>();
|
||||||
|
|
||||||
Service::Init(service_manager, virtual_filesystem);
|
Service::Init(service_manager, *virtual_filesystem);
|
||||||
GDBStub::Init();
|
GDBStub::Init();
|
||||||
|
|
||||||
renderer = VideoCore::CreateRenderer(emu_window);
|
renderer = VideoCore::CreateRenderer(emu_window);
|
||||||
|
|
|
@ -361,19 +361,19 @@ FileSys::VirtualDir GetModificationLoadRoot(u64 title_id) {
|
||||||
return bis_factory->GetModificationLoadRoot(title_id);
|
return bis_factory->GetModificationLoadRoot(title_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateFactories(const FileSys::VirtualFilesystem& vfs, bool overwrite) {
|
void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) {
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
bis_factory = nullptr;
|
bis_factory = nullptr;
|
||||||
save_data_factory = nullptr;
|
save_data_factory = nullptr;
|
||||||
sdmc_factory = nullptr;
|
sdmc_factory = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto nand_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir),
|
auto nand_directory = vfs.OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir),
|
||||||
FileSys::Mode::ReadWrite);
|
FileSys::Mode::ReadWrite);
|
||||||
auto sd_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir),
|
auto sd_directory = vfs.OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir),
|
||||||
FileSys::Mode::ReadWrite);
|
FileSys::Mode::ReadWrite);
|
||||||
auto load_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir),
|
auto load_directory = vfs.OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir),
|
||||||
FileSys::Mode::ReadWrite);
|
FileSys::Mode::ReadWrite);
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
bis_factory = std::make_unique<FileSys::BISFactory>(nand_directory, load_directory);
|
bis_factory = std::make_unique<FileSys::BISFactory>(nand_directory, load_directory);
|
||||||
|
@ -383,7 +383,7 @@ void CreateFactories(const FileSys::VirtualFilesystem& vfs, bool overwrite) {
|
||||||
sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory));
|
sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs) {
|
void InstallInterfaces(SM::ServiceManager& service_manager, FileSys::VfsFilesystem& vfs) {
|
||||||
romfs_factory = nullptr;
|
romfs_factory = nullptr;
|
||||||
CreateFactories(vfs, false);
|
CreateFactories(vfs, false);
|
||||||
std::make_shared<FSP_LDR>()->InstallAsService(service_manager);
|
std::make_shared<FSP_LDR>()->InstallAsService(service_manager);
|
||||||
|
|
|
@ -57,9 +57,9 @@ FileSys::VirtualDir GetModificationLoadRoot(u64 title_id);
|
||||||
|
|
||||||
// Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function
|
// Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function
|
||||||
// above is called.
|
// above is called.
|
||||||
void CreateFactories(const FileSys::VirtualFilesystem& vfs, bool overwrite = true);
|
void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite = true);
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs);
|
void InstallInterfaces(SM::ServiceManager& service_manager, FileSys::VfsFilesystem& vfs);
|
||||||
|
|
||||||
// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of
|
// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of
|
||||||
// pointers and booleans. This makes using a VfsDirectory with switch services much easier and
|
// pointers and booleans. This makes using a VfsDirectory with switch services much easier and
|
||||||
|
|
|
@ -197,7 +197,7 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co
|
||||||
// Module interface
|
// Module interface
|
||||||
|
|
||||||
/// Initialize ServiceManager
|
/// Initialize ServiceManager
|
||||||
void Init(std::shared_ptr<SM::ServiceManager>& sm, const FileSys::VirtualFilesystem& rfs) {
|
void Init(std::shared_ptr<SM::ServiceManager>& sm, FileSys::VfsFilesystem& vfs) {
|
||||||
// NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
|
// NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
|
||||||
// here and pass it into the respective InstallInterfaces functions.
|
// here and pass it into the respective InstallInterfaces functions.
|
||||||
auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>();
|
auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>();
|
||||||
|
@ -220,7 +220,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, const FileSys::VirtualFilesys
|
||||||
EUPLD::InstallInterfaces(*sm);
|
EUPLD::InstallInterfaces(*sm);
|
||||||
Fatal::InstallInterfaces(*sm);
|
Fatal::InstallInterfaces(*sm);
|
||||||
FGM::InstallInterfaces(*sm);
|
FGM::InstallInterfaces(*sm);
|
||||||
FileSystem::InstallInterfaces(*sm, rfs);
|
FileSystem::InstallInterfaces(*sm, vfs);
|
||||||
Friend::InstallInterfaces(*sm);
|
Friend::InstallInterfaces(*sm);
|
||||||
GRC::InstallInterfaces(*sm);
|
GRC::InstallInterfaces(*sm);
|
||||||
HID::InstallInterfaces(*sm);
|
HID::InstallInterfaces(*sm);
|
||||||
|
|
|
@ -180,8 +180,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Initialize ServiceManager
|
/// Initialize ServiceManager
|
||||||
void Init(std::shared_ptr<SM::ServiceManager>& sm,
|
void Init(std::shared_ptr<SM::ServiceManager>& sm, FileSys::VfsFilesystem& vfs);
|
||||||
const std::shared_ptr<FileSys::VfsFilesystem>& vfs);
|
|
||||||
|
|
||||||
/// Shutdown ServiceManager
|
/// Shutdown ServiceManager
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
|
@ -176,7 +176,7 @@ GMainWindow::GMainWindow()
|
||||||
OnReinitializeKeys(ReinitializeKeyBehavior::NoWarning);
|
OnReinitializeKeys(ReinitializeKeyBehavior::NoWarning);
|
||||||
|
|
||||||
// Necessary to load titles from nand in gamelist.
|
// Necessary to load titles from nand in gamelist.
|
||||||
Service::FileSystem::CreateFactories(vfs);
|
Service::FileSystem::CreateFactories(*vfs);
|
||||||
game_list->LoadCompatibilityList();
|
game_list->LoadCompatibilityList();
|
||||||
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
||||||
|
|
||||||
|
@ -1139,7 +1139,7 @@ void GMainWindow::OnMenuSelectEmulatedDirectory(EmulatedDirectoryTarget target)
|
||||||
FileUtil::GetUserPath(target == EmulatedDirectoryTarget::SDMC ? FileUtil::UserPath::SDMCDir
|
FileUtil::GetUserPath(target == EmulatedDirectoryTarget::SDMC ? FileUtil::UserPath::SDMCDir
|
||||||
: FileUtil::UserPath::NANDDir,
|
: FileUtil::UserPath::NANDDir,
|
||||||
dir_path.toStdString());
|
dir_path.toStdString());
|
||||||
Service::FileSystem::CreateFactories(vfs);
|
Service::FileSystem::CreateFactories(*vfs);
|
||||||
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1410,7 +1410,7 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) {
|
||||||
|
|
||||||
const auto function = [this, &keys, &pdm] {
|
const auto function = [this, &keys, &pdm] {
|
||||||
keys.PopulateFromPartitionData(pdm);
|
keys.PopulateFromPartitionData(pdm);
|
||||||
Service::FileSystem::CreateFactories(vfs);
|
Service::FileSystem::CreateFactories(*vfs);
|
||||||
keys.DeriveETicket(pdm);
|
keys.DeriveETicket(pdm);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1450,7 +1450,7 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) {
|
||||||
prog.close();
|
prog.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Service::FileSystem::CreateFactories(vfs);
|
Service::FileSystem::CreateFactories(*vfs);
|
||||||
|
|
||||||
if (behavior == ReinitializeKeyBehavior::Warning) {
|
if (behavior == ReinitializeKeyBehavior::Warning) {
|
||||||
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
||||||
|
|
|
@ -175,7 +175,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
Core::System& system{Core::System::GetInstance()};
|
Core::System& system{Core::System::GetInstance()};
|
||||||
system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
|
system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
|
||||||
Service::FileSystem::CreateFactories(system.GetFilesystem());
|
Service::FileSystem::CreateFactories(*system.GetFilesystem());
|
||||||
|
|
||||||
SCOPE_EXIT({ system.Shutdown(); });
|
SCOPE_EXIT({ system.Shutdown(); });
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue