From 522f5ea64553cc7007f9b62ebe72028e5fe98c76 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 10 Dec 2018 14:40:59 +0300 Subject: [PATCH] Fix cellFsGetFreeSize (following #5304) Simplify device name extraction --- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 4689c369b7..0f22241a2f 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -982,23 +982,15 @@ error_code sys_fs_fcntl(u32 fd, u32 op, vm::ptr _arg, u32 _size) const auto arg = vm::static_ptr_cast(_arg); const std::string_view vpath = arg->path.get_ptr(); + const std::size_t non_slash = vpath.find_first_not_of('/'); - if (vpath[0] != '/') + if (non_slash == -1) { return {CELL_EPERM, vpath}; } // Extract device from path - std::size_t lastslash = vpath.find_first_not_of('/', 1); - if (lastslash != std::string_view::npos) - { - lastslash = vpath.find_first_of('/', lastslash + 1); - } - - if (lastslash == std::string_view::npos) lastslash = vpath.length(); - else lastslash++; - - const std::string_view device_path = vpath.substr(0, lastslash); + const std::string_view device_path = vpath.substr(0, vpath.find_first_of('/', non_slash)); const std::string local_path = vfs::get(device_path); if (local_path.empty())