mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 08:55:29 +03:00
Fix crashes when opening non-existent directories
This commit is contained in:
parent
ec139b3027
commit
29e89a3950
@ -61,6 +61,8 @@ namespace skyline::service::fssrv {
|
||||
|
||||
auto listMode{request.Pop<vfs::Directory::ListMode>()};
|
||||
auto directory{backing->OpenDirectory(path, listMode)};
|
||||
if (!directory)
|
||||
return result::PathDoesNotExist;
|
||||
|
||||
manager.RegisterService(std::make_shared<IDirectory>(std::move(directory), backing, state, manager), session, response);
|
||||
return {};
|
||||
|
@ -134,11 +134,7 @@ namespace skyline::vfs {
|
||||
* @return A shared pointer to a Directory object of the directory
|
||||
*/
|
||||
std::shared_ptr<Directory> OpenDirectory(const std::string &path, Directory::ListMode listMode = {true, true}) {
|
||||
auto dir{OpenDirectoryUnchecked(path, listMode)};
|
||||
if (dir == nullptr)
|
||||
throw exception("Failed to open directory: {}", path);
|
||||
|
||||
return dir;
|
||||
return OpenDirectoryUnchecked(path, listMode);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -84,7 +84,12 @@ namespace skyline::vfs {
|
||||
}
|
||||
|
||||
std::shared_ptr<Directory> OsFileSystem::OpenDirectoryImpl(const std::string &path, Directory::ListMode listMode) {
|
||||
return std::make_shared<OsFileSystemDirectory>(basePath + path, listMode);
|
||||
struct dirent *entry;
|
||||
auto directory{opendir((basePath + path).c_str())};
|
||||
if (!directory)
|
||||
return nullptr;
|
||||
else
|
||||
return std::make_shared<OsFileSystemDirectory>(basePath + path, listMode);
|
||||
}
|
||||
|
||||
OsFileSystemDirectory::OsFileSystemDirectory(std::string path, Directory::ListMode listMode) : Directory(listMode), path(std::move(path)) {}
|
||||
|
Loading…
Reference in New Issue
Block a user