sys_fs: Integrated get_mount_count() into sys_fs_get_mount_info_size()

This commit is contained in:
brian218 2022-12-08 13:26:27 +08:00 committed by Megamouse
parent a0f3704b41
commit 6d4379059c
2 changed files with 24 additions and 30 deletions

View File

@ -302,34 +302,6 @@ std::string lv2_fs_object::device_name_to_path(std::string_view device_name)
return {};
}
u64 lv2_fs_object::get_mount_count()
{
u64 count = 0;
for (auto mp = &g_mp_sys_dev_root; mp; mp = mp->next)
{
if (mp == &g_mp_sys_dev_usb)
{
for (int i = 0; i < 8; i++)
{
if (!vfs::get(fmt::format("%s%03d", mp->root, i)).empty())
{
count++;
}
}
}
else
{
if (!vfs::get(mp->root).empty())
{
count++;
}
}
}
return count;
}
bool lv2_fs_object::vfs_unmount(std::string_view vpath, bool no_error)
{
const std::string local_path = vfs::get(vpath);
@ -3072,7 +3044,30 @@ error_code sys_fs_get_mount_info_size(ppu_thread&, vm::ptr<u64> len)
return CELL_EFAULT;
}
*len = lv2_fs_object::get_mount_count();
u64 count = 0;
for (auto mp = &g_mp_sys_dev_root; mp; mp = mp->next)
{
if (mp == &g_mp_sys_dev_usb)
{
for (int i = 0; i < 8; i++)
{
if (!vfs::get(fmt::format("%s%03d", mp->root, i)).empty())
{
count++;
}
}
}
else
{
if (!vfs::get(mp->root).empty())
{
count++;
}
}
}
*len = count;
return CELL_OK;
}

View File

@ -192,7 +192,6 @@ public:
static std::string_view get_device_path(std::string_view filename);
static lv2_fs_mount_point* get_mp(std::string_view filename, std::string* vfs_path = nullptr);
static std::string device_name_to_path(std::string_view device_name);
static u64 get_mount_count();
static bool vfs_unmount(std::string_view vpath, bool no_error = false);
static std::array<char, 0x420> get_name(std::string_view filename)