ladybird/VirtualFileSystem/InodeIdentifier.h
Andreas Kling ec1d16b307 Add a "pwd" utility to userland.
It's implemented as a separate process. How cute is that.
Tasks now have a current working directory. Spawned tasks inherit their
parent task's working directory.
Currently everyone just uses "/" as there's no way to chdir().
2018-10-24 14:28:22 +02:00

45 lines
1 KiB
C++

#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Types.h>
class FileSystem;
struct InodeMetadata;
class InodeIdentifier {
public:
InodeIdentifier() { }
InodeIdentifier(dword fileSystemID, dword inode)
: m_fileSystemID(fileSystemID)
, m_index(inode)
{
}
bool isValid() const { return m_fileSystemID != 0 && m_index != 0; }
dword fileSystemID() const { return m_fileSystemID; }
dword index() const { return m_index; }
FileSystem* fileSystem();
const FileSystem* fileSystem() const;
bool operator==(const InodeIdentifier& other) const
{
return m_fileSystemID == other.m_fileSystemID && m_index == other.m_index;
}
bool operator!=(const InodeIdentifier& other) const
{
return m_fileSystemID != other.m_fileSystemID || m_index != other.m_index;
}
InodeMetadata metadata() const;
bool isRootInode() const;
ByteBuffer readEntireFile() const;
private:
dword m_fileSystemID { 0 };
dword m_index { 0 };
};