Implemented sys_fs_mount() and sys_fs_unmount()

This commit is contained in:
brian218 2022-10-28 04:53:12 +08:00 committed by Megamouse
parent 5210df6882
commit 61a371b106
6 changed files with 126 additions and 18 deletions

View file

@ -33,7 +33,7 @@ struct vfs_manager
vfs_directory root{};
};
bool vfs::mount(std::string_view vpath, std::string_view path)
bool vfs::mount(std::string_view vpath, std::string_view path, bool create_dir)
{
if (vpath.empty())
{
@ -42,6 +42,12 @@ bool vfs::mount(std::string_view vpath, std::string_view path)
return false;
}
if (create_dir && !fs::is_dir(std::string(path)) && !fs::create_dir(std::string(path)))
{
vfs_log.error("Cannot create directory \"%s\"", path);
return false;
}
// Workaround
g_fxo->need<vfs_manager>();