mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 00:35:06 +00:00
Add support for removing directories.
It's really only supported in Ext2FS since SynthFS doesn't really want you mucking around with its files. This is pretty neat though :^) I ran into some trouble with HashMap while working on this but opted to work around it and leave that for a separate investigation.
This commit is contained in:
parent
031c62a21e
commit
c95228b128
19 changed files with 185 additions and 40 deletions
|
@ -200,7 +200,7 @@ InodeMetadata SynthFSInode::metadata() const
|
|||
return m_metadata;
|
||||
}
|
||||
|
||||
ssize_t SynthFSInode::read_bytes(off_t offset, size_t count, byte* buffer, FileDescriptor* descriptor)
|
||||
ssize_t SynthFSInode::read_bytes(off_t offset, size_t count, byte* buffer, FileDescriptor* descriptor) const
|
||||
{
|
||||
#ifdef SYNTHFS_DEBUG
|
||||
kprintf("SynthFS: read_bytes %u\n", index());
|
||||
|
@ -211,10 +211,10 @@ ssize_t SynthFSInode::read_bytes(off_t offset, size_t count, byte* buffer, FileD
|
|||
ByteBuffer generatedData;
|
||||
if (m_generator) {
|
||||
if (!descriptor) {
|
||||
generatedData = m_generator(*this);
|
||||
generatedData = m_generator(const_cast<SynthFSInode&>(*this));
|
||||
} else {
|
||||
if (!descriptor->generator_cache())
|
||||
descriptor->generator_cache() = m_generator(*this);
|
||||
descriptor->generator_cache() = m_generator(const_cast<SynthFSInode&>(*this));
|
||||
generatedData = descriptor->generator_cache();
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ ssize_t SynthFSInode::read_bytes(off_t offset, size_t count, byte* buffer, FileD
|
|||
return nread;
|
||||
}
|
||||
|
||||
bool SynthFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)> callback)
|
||||
bool SynthFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)> callback) const
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
#ifdef SYNTHFS_DEBUG
|
||||
|
@ -305,3 +305,10 @@ bool SynthFSInode::remove_child(const String& name, int& error)
|
|||
SynthFSInodeCustomData::~SynthFSInodeCustomData()
|
||||
{
|
||||
}
|
||||
|
||||
size_t SynthFSInode::directory_entry_count() const
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
// NOTE: The 2 is for '.' and '..'
|
||||
return m_children.size() + 2;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue