diff --git a/rpcsx-os/vfs.cpp b/rpcsx-os/vfs.cpp index eba498aa3..083a12d51 100644 --- a/rpcsx-os/vfs.cpp +++ b/rpcsx-os/vfs.cpp @@ -6,7 +6,6 @@ #include "orbis/error/SysResult.hpp" #include #include -#include #include @@ -183,6 +182,20 @@ orbis::SysResult rx::vfs::open(std::string_view path, int flags, int mode, return device->open(file, devPath.c_str(), flags, mode, thread); } +bool rx::vfs::exists(std::string_view path, orbis::Thread *thread) { + auto [device, devPath] = get(path); + if (device == nullptr) { + return false; + } + + orbis::Ref file; + if (device->open(&file, devPath.c_str(), 0, 0, thread) != + orbis::ErrorCode{}) { + return false; + } + return true; +} + orbis::SysResult rx::vfs::mkdir(std::string_view path, int mode, orbis::Thread *thread) { auto [device, devPath] = get(path); diff --git a/rpcsx-os/vfs.hpp b/rpcsx-os/vfs.hpp index 2edb29e2d..8884d9399 100644 --- a/rpcsx-os/vfs.hpp +++ b/rpcsx-os/vfs.hpp @@ -17,6 +17,7 @@ get(const std::filesystem::path &guestPath); orbis::SysResult mount(const std::filesystem::path &guestPath, IoDevice *dev); orbis::SysResult open(std::string_view path, int flags, int mode, orbis::Ref *file, orbis::Thread *thread); +bool exists(std::string_view path, orbis::Thread *thread); orbis::SysResult mkdir(std::string_view path, int mode, orbis::Thread *thread); orbis::SysResult rmdir(std::string_view path, orbis::Thread *thread); orbis::SysResult rename(std::string_view from, std::string_view to,