Kernel: Update ErrorOr API and add path find to VFS

These two are done on the same commit since Changes to Shell were
annoying to make work with only one change
This commit is contained in:
Bananymous
2023-02-22 01:23:11 +02:00
parent 9aab67fed8
commit 5d31e89574
5 changed files with 80 additions and 47 deletions

View File

@@ -1,3 +1,5 @@
#include <BAN/StringView.h>
#include <BAN/Vector.h>
#include <kernel/FS/VirtualFileSystem.h>
namespace Kernel
@@ -23,4 +25,18 @@ namespace Kernel
return s_instance != nullptr;
}
BAN::ErrorOr<BAN::RefCounted<Inode>> VirtualFileSystem::from_absolute_path(BAN::StringView path)
{
if (path.front() != '/')
return BAN::Error::from_string("Path must be an absolute path");
auto inode = root_inode();
auto path_parts = TRY(path.split('/'));
for (BAN::StringView part : path_parts)
inode = TRY(inode->directory_find(part));
return inode;
}
}