mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 22:15:07 +00:00
Kernel: Make SharedMemory inherit from File.
This commit is contained in:
parent
a6d407fec5
commit
a104d7cc93
5 changed files with 57 additions and 20 deletions
|
@ -23,11 +23,6 @@ Retained<FileDescriptor> FileDescriptor::create(RetainPtr<File>&& file)
|
|||
return adopt(*new FileDescriptor(move(file)));
|
||||
}
|
||||
|
||||
Retained<FileDescriptor> FileDescriptor::create(RetainPtr<SharedMemory>&& shared_memory)
|
||||
{
|
||||
return adopt(*new FileDescriptor(move(shared_memory)));
|
||||
}
|
||||
|
||||
Retained<FileDescriptor> FileDescriptor::create(RetainPtr<Socket>&& socket, SocketRole role)
|
||||
{
|
||||
return adopt(*new FileDescriptor(move(socket), role));
|
||||
|
@ -53,11 +48,6 @@ FileDescriptor::FileDescriptor(RetainPtr<File>&& file)
|
|||
{
|
||||
}
|
||||
|
||||
FileDescriptor::FileDescriptor(RetainPtr<SharedMemory>&& shared_memory)
|
||||
: m_shared_memory(move(shared_memory))
|
||||
{
|
||||
}
|
||||
|
||||
FileDescriptor::FileDescriptor(RetainPtr<Socket>&& socket, SocketRole role)
|
||||
: m_socket(move(socket))
|
||||
{
|
||||
|
@ -448,3 +438,22 @@ KResult FileDescriptor::truncate(off_t length)
|
|||
ASSERT(is_shared_memory());
|
||||
return shared_memory()->truncate(length);
|
||||
}
|
||||
|
||||
bool FileDescriptor::is_shared_memory() const
|
||||
{
|
||||
return m_file && m_file->is_shared_memory();
|
||||
}
|
||||
|
||||
SharedMemory* FileDescriptor::shared_memory()
|
||||
{
|
||||
if (!is_shared_memory())
|
||||
return nullptr;
|
||||
return static_cast<SharedMemory*>(m_file.ptr());
|
||||
}
|
||||
|
||||
const SharedMemory* FileDescriptor::shared_memory() const
|
||||
{
|
||||
if (!is_shared_memory())
|
||||
return nullptr;
|
||||
return static_cast<const SharedMemory*>(m_file.ptr());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue