FreeNOS
Public Member Functions | Private Attributes
PseudoFile Class Reference

Pseudo files only exist in memory. More...

#include <PseudoFile.h>

Inheritance diagram for PseudoFile:
File

Public Member Functions

 PseudoFile (const u32 inode)
 Default constructor. More...
 
 PseudoFile (const u32 inode, const char *str)
 Constructor. More...
 
virtual ~PseudoFile ()
 Destructor. More...
 
virtual FileSystem::Result read (IOBuffer &buffer, Size &size, const Size offset)
 Read bytes from the file. More...
 
virtual FileSystem::Result write (IOBuffer &buffer, Size &size, const Size offset)
 Write bytes to the file. More...
 
- Public Member Functions inherited from File
 File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO)
 Constructor function. More...
 
virtual ~File ()
 Destructor function. More...
 
u32 getInode () const
 Get inode number. More...
 
FileSystem::FileType getType () const
 Retrieve our filetype. More...
 
virtual FileSystem::Result status (FileSystem::FileStat &st)
 Retrieve file statistics. More...
 
virtual bool canRead () const
 Check if the File has data ready for reading. More...
 
virtual bool canWrite () const
 Check if the File can be written to. More...
 

Private Attributes

char * m_buffer
 Buffer from which we read. More...
 

Additional Inherited Members

- Protected Attributes inherited from File
const u32 m_inode
 Inode number. More...
 
const FileSystem::FileType m_type
 Type of this file. More...
 
UserID m_uid
 Owner of the file. More...
 
GroupID m_gid
 Group of the file. More...
 
FileSystem::FileModes m_access
 Access permissions. More...
 
Size m_size
 Size of the file, in bytes. More...
 

Detailed Description

Pseudo files only exist in memory.

Definition at line 36 of file PseudoFile.h.

Constructor & Destructor Documentation

◆ PseudoFile() [1/2]

PseudoFile::PseudoFile ( const u32  inode)

Default constructor.

Parameters
inodeInode number for this File

Definition at line 23 of file PseudoFile.cpp.

References File::m_access, m_buffer, File::m_size, FileSystem::OwnerRW, and ZERO.

◆ PseudoFile() [2/2]

PseudoFile::PseudoFile ( const u32  inode,
const char *  str 
)

Constructor.

Parameters
inodeInode number for this File
strText string with file data

Definition at line 31 of file PseudoFile.cpp.

References assert, MemoryBlock::copy(), String::length(), File::m_access, m_buffer, File::m_size, NULL, and FileSystem::OwnerRW.

◆ ~PseudoFile()

PseudoFile::~PseudoFile ( )
virtual

Destructor.

Definition at line 42 of file PseudoFile.cpp.

References m_buffer.

Member Function Documentation

◆ read()

FileSystem::Result PseudoFile::read ( IOBuffer buffer,
Size size,
const Size  offset 
)
virtual

Read bytes from the file.

Parameters
bufferInput/Output buffer to output bytes to.
sizeMaximum number of bytes to read on input. On output, the actual number of bytes read.
offsetOffset inside the file to start reading.
Returns
Result code

Reimplemented from File.

Definition at line 50 of file PseudoFile.cpp.

References m_buffer, File::m_size, FileSystem::Success, and IOBuffer::write().

◆ write()

FileSystem::Result PseudoFile::write ( IOBuffer buffer,
Size size,
const Size  offset 
)
virtual

Write bytes to the file.

Parameters
bufferInput/Output buffer to input bytes from.
sizeMaximum number of bytes to write on input. On output, the actual number of bytes written.
offsetOffset inside the file to start writing.
Returns
Result code

Reimplemented from File.

Definition at line 69 of file PseudoFile.cpp.

References assert, MemoryBlock::copy(), m_buffer, File::m_size, NULL, IOBuffer::read(), and MemoryBlock::set().

Field Documentation

◆ m_buffer

char* PseudoFile::m_buffer
private

Buffer from which we read.

Definition at line 92 of file PseudoFile.h.

Referenced by PseudoFile(), read(), write(), and ~PseudoFile().


The documentation for this class was generated from the following files: