summaryrefslogtreecommitdiff
path: root/VirtualFileSystem/Ext2FileSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'VirtualFileSystem/Ext2FileSystem.cpp')
-rw-r--r--VirtualFileSystem/Ext2FileSystem.cpp44
1 files changed, 1 insertions, 43 deletions
diff --git a/VirtualFileSystem/Ext2FileSystem.cpp b/VirtualFileSystem/Ext2FileSystem.cpp
index 8e0dc9b87b..53fa6a3b66 100644
--- a/VirtualFileSystem/Ext2FileSystem.cpp
+++ b/VirtualFileSystem/Ext2FileSystem.cpp
@@ -6,6 +6,7 @@
#include <AK/kmalloc.h>
#include <AK/ktime.h>
#include <AK/kstdio.h>
+#include <AK/BufferStream.h>
#include "sys-errno.h"
//#define EXT2_DEBUG
@@ -431,49 +432,6 @@ bool Ext2FileSystem::addInodeToDirectory(unsigned directoryInode, unsigned inode
return writeDirectoryInode(directoryInode, move(entries));
}
-class BufferStream {
-public:
- explicit BufferStream(ByteBuffer& buffer)
- : m_buffer(buffer)
- {
- }
-
- void operator<<(byte value)
- {
- m_buffer[m_offset++] = value & 0xffu;
- }
-
- void operator<<(word value)
- {
- m_buffer[m_offset++] = value & 0xffu;
- m_buffer[m_offset++] = (byte)(value >> 8) & 0xffu;
- }
-
- void operator<<(dword value)
- {
- m_buffer[m_offset++] = value & 0xffu;
- m_buffer[m_offset++] = (byte)(value >> 8) & 0xffu;
- m_buffer[m_offset++] = (byte)(value >> 16) & 0xffu;
- m_buffer[m_offset++] = (byte)(value >> 24) & 0xffu;
- }
-
- void operator<<(const String& value)
- {
- for (unsigned i = 0; i < value.length(); ++i)
- m_buffer[m_offset++] = value[i];
- }
-
- void fillToEnd(byte ch)
- {
- while (m_offset < m_buffer.size())
- m_buffer[m_offset++] = ch;
- }
-
-private:
- ByteBuffer& m_buffer;
- Unix::size_t m_offset { 0 };
-};
-
bool Ext2FileSystem::writeDirectoryInode(unsigned directoryInode, Vector<DirectoryEntry>&& entries)
{
kprintf("[ext2fs] New directory inode %u contents to write:\n", directoryInode);