sys_fs_open: support split files

This commit is contained in:
Nekotekina 2018-08-13 01:06:34 +03:00
parent 441541a42f
commit 62f9a2dc4b

View File

@ -282,6 +282,29 @@ error_code sys_fs_open(vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, s32 mode
fs::file file(local_path, open_mode);
if (!file && open_mode == fs::read && fs::g_tls_error == fs::error::noent)
{
// Try to gather split file (TODO)
std::vector<fs::file> fragments;
for (u32 i = 66600; i <= 66699; i++)
{
if (fs::file fragment{fmt::format("%s.%u", local_path, i)})
{
fragments.emplace_back(std::move(fragment));
}
else
{
break;
}
}
if (!fragments.empty())
{
file = fs::make_gather(std::move(fragments));
}
}
if (!file)
{
if (test(open_mode & fs::excl) && fs::g_tls_error == fs::error::exist)