mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
Implement sys$chdir() and teach sh+ls to cd around and browse different dirs.
This commit is contained in:
parent
ac738b03d6
commit
2749e7f1c2
Notes:
sideshowbarker
2024-07-19 18:38:22 +09:00
Author: https://github.com/awesomekling
Commit: 2749e7f1c2
16 changed files with 147 additions and 33 deletions
|
@ -168,9 +168,9 @@ void VirtualFileSystem::freeNode(Node* node)
|
|||
m_nodeFreeList.append(move(node));
|
||||
}
|
||||
|
||||
bool VirtualFileSystem::isDirectory(const String& path)
|
||||
bool VirtualFileSystem::isDirectory(const String& path, Node* base)
|
||||
{
|
||||
auto inode = resolvePath(path);
|
||||
auto inode = resolvePath(path, base);
|
||||
if (!inode.isValid())
|
||||
return false;
|
||||
|
||||
|
@ -355,11 +355,11 @@ bool VirtualFileSystem::touch(const String& path)
|
|||
return inode.fileSystem()->setModificationTime(inode, ktime(nullptr));
|
||||
}
|
||||
|
||||
OwnPtr<FileHandle> VirtualFileSystem::open(const String& path)
|
||||
OwnPtr<FileHandle> VirtualFileSystem::open(const String& path, Node* base)
|
||||
{
|
||||
Locker locker(VirtualFileSystem::lock());
|
||||
|
||||
auto inode = resolvePath(path);
|
||||
auto inode = resolvePath(path, base);
|
||||
if (!inode.isValid())
|
||||
return nullptr;
|
||||
auto vnode = getOrCreateNode(inode);
|
||||
|
@ -368,7 +368,7 @@ OwnPtr<FileHandle> VirtualFileSystem::open(const String& path)
|
|||
return make<FileHandle>(move(vnode));
|
||||
}
|
||||
|
||||
OwnPtr<FileHandle> VirtualFileSystem::create(const String& path)
|
||||
OwnPtr<FileHandle> VirtualFileSystem::create(const String& path, Node* base)
|
||||
{
|
||||
Locker locker(VirtualFileSystem::lock());
|
||||
|
||||
|
@ -378,7 +378,7 @@ OwnPtr<FileHandle> VirtualFileSystem::create(const String& path)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
OwnPtr<FileHandle> VirtualFileSystem::mkdir(const String& path)
|
||||
OwnPtr<FileHandle> VirtualFileSystem::mkdir(const String& path, Node* base)
|
||||
{
|
||||
Locker locker(VirtualFileSystem::lock());
|
||||
|
||||
|
@ -398,10 +398,18 @@ InodeIdentifier VirtualFileSystem::resolveSymbolicLink(const String& basePath, I
|
|||
return resolvePath(buf);
|
||||
}
|
||||
|
||||
InodeIdentifier VirtualFileSystem::resolvePath(const String& path)
|
||||
InodeIdentifier VirtualFileSystem::resolvePath(const String& path, Node* base)
|
||||
{
|
||||
if (path.isEmpty())
|
||||
return { };
|
||||
|
||||
auto parts = path.split('/');
|
||||
InodeIdentifier inode = m_rootNode->inode;
|
||||
InodeIdentifier inode;
|
||||
|
||||
if (path[0] == '/')
|
||||
inode = m_rootNode->inode;
|
||||
else
|
||||
inode = base ? base->inode : m_rootNode->inode;
|
||||
|
||||
for (unsigned i = 0; i < parts.size(); ++i) {
|
||||
auto& part = parts[i];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue