mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
Import all this stuff into a single repo called Serenity.
This commit is contained in:
commit
5a30055157
Notes:
sideshowbarker
2024-07-19 18:51:29 +09:00
Author: https://github.com/awesomekling 🔰
Commit: 5a30055157
67 changed files with 8836 additions and 0 deletions
45
VirtualFileSystem/FileSystem.cpp
Normal file
45
VirtualFileSystem/FileSystem.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <AK/Assertions.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include "FileSystem.h"
|
||||
|
||||
static dword s_lastFileSystemID = 0;
|
||||
|
||||
static HashMap<dword, FileSystem*>& fileSystems()
|
||||
{
|
||||
static auto* map = new HashMap<dword, FileSystem*>();
|
||||
return *map;
|
||||
}
|
||||
|
||||
FileSystem::FileSystem()
|
||||
: m_id(++s_lastFileSystemID)
|
||||
{
|
||||
fileSystems().set(m_id, this);
|
||||
}
|
||||
|
||||
FileSystem::~FileSystem()
|
||||
{
|
||||
// FIXME: Needs HashMap::remove()!
|
||||
//fileSystems().remove(m_id);
|
||||
}
|
||||
|
||||
FileSystem* FileSystem::fromID(dword id)
|
||||
{
|
||||
auto it = fileSystems().find(id);
|
||||
if (it != fileSystems().end())
|
||||
return (*it).value;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InodeIdentifier FileSystem::childOfDirectoryInodeWithName(InodeIdentifier inode, const String& name)
|
||||
{
|
||||
InodeIdentifier foundInode;
|
||||
enumerateDirectoryInode(inode, [&] (const DirectoryEntry& entry) {
|
||||
if (entry.name == name) {
|
||||
foundInode = entry.inode;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return foundInode;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue