forked from Bananymous/banan-os
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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user