From 2d1409c7063be5c5e7fad0564b04dbae71687b49 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 1 Jul 2014 16:21:55 +0400 Subject: [PATCH] FileExists() fixed --- rpcs3/Emu/FS/vfsLocalFile.cpp | 5 +++++ rpcs3/Emu/FS/vfsLocalFile.h | 1 + rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 6 ++++++ rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp | 8 +++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/FS/vfsLocalFile.cpp b/rpcs3/Emu/FS/vfsLocalFile.cpp index 7eceb1e8d6..7a6e71c09c 100644 --- a/rpcs3/Emu/FS/vfsLocalFile.cpp +++ b/rpcs3/Emu/FS/vfsLocalFile.cpp @@ -115,3 +115,8 @@ bool vfsLocalFile::IsOpened() const { return m_file.IsOpened() && vfsFileBase::IsOpened(); } + +bool vfsLocalFile::Exists(const std::string& path) +{ + return rFileExists(path); +} \ No newline at end of file diff --git a/rpcs3/Emu/FS/vfsLocalFile.h b/rpcs3/Emu/FS/vfsLocalFile.h index a7aac7b1ea..c61dd495e7 100644 --- a/rpcs3/Emu/FS/vfsLocalFile.h +++ b/rpcs3/Emu/FS/vfsLocalFile.h @@ -12,6 +12,7 @@ public: virtual bool Open(const std::string& path, vfsOpenMode mode = vfsRead) override; virtual bool Create(const std::string& path) override; virtual bool Close() override; + virtual bool Exists(const std::string& path) override; virtual u64 GetSize() override; diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index aaff7e08b1..20dc321c69 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -30,6 +30,12 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr) sceNp->Warning("sceNpDrmIsAvailable(k_licensee_addr=0x%x, drm_path_addr=0x%x)", k_licensee_addr, drm_path_addr); std::string drm_path = Memory.ReadString(drm_path_addr); + if (!Emu.GetVFS().ExistsFile(drm_path)) + { + sceNp->Warning("sceNpDrmIsAvailable(): '%s' not found", drm_path.c_str()); + return CELL_ENOENT; + } + std::string k_licensee_str; u8 k_licensee[0x10]; for(int i = 0; i < 0x10; i++) diff --git a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp index 6e8a6c4e01..15fe4a6d86 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp @@ -116,6 +116,12 @@ int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) return CELL_EINVAL; } + if (!Emu.GetVFS().ExistsFile(ppath)) + { + sys_fs->Error("\"%s\" not found! flags: 0x%08x", ppath.c_str(), flags); + return CELL_ENOENT; + } + vfsFileBase* stream = Emu.GetVFS().OpenFile(ppath, o_mode); if(!stream || !stream->IsOpened()) @@ -126,7 +132,7 @@ int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) } fd = sys_fs->GetNewId(stream, IDFlag_File); - LOG_WARNING(HLE, "*** cellFsOpen(path=\"%s\"): fd = %d", path.c_str(), fd.GetValue()); + LOG_WARNING(HLE, "\"%s\" opened: fd = %d", path.c_str(), fd.GetValue()); return CELL_OK; }