mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-29 00:35: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 listMode{request.Pop<vfs::Directory::ListMode>()};
|
||||||
auto directory{backing->OpenDirectory(path, 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);
|
manager.RegisterService(std::make_shared<IDirectory>(std::move(directory), backing, state, manager), session, response);
|
||||||
return {};
|
return {};
|
||||||
|
@ -134,11 +134,7 @@ namespace skyline::vfs {
|
|||||||
* @return A shared pointer to a Directory object of the directory
|
* @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}) {
|
std::shared_ptr<Directory> OpenDirectory(const std::string &path, Directory::ListMode listMode = {true, true}) {
|
||||||
auto dir{OpenDirectoryUnchecked(path, listMode)};
|
return OpenDirectoryUnchecked(path, listMode);
|
||||||
if (dir == nullptr)
|
|
||||||
throw exception("Failed to open directory: {}", path);
|
|
||||||
|
|
||||||
return dir;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,12 @@ namespace skyline::vfs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Directory> OsFileSystem::OpenDirectoryImpl(const std::string &path, Directory::ListMode listMode) {
|
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)) {}
|
OsFileSystemDirectory::OsFileSystemDirectory(std::string path, Directory::ListMode listMode) : Directory(listMode), path(std::move(path)) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user