1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

Import all this stuff into a single repo called Serenity.

This commit is contained in:
Andreas Kling 2018-10-10 11:53:07 +02:00
commit 5a30055157
67 changed files with 8836 additions and 0 deletions

View 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;
}