FreeNOS
Public Member Functions | Protected Attributes
File Class Reference

Represents a file present on a FileSystem. More...

#include <File.h>

Inheritance diagram for File:
Device Directory EthernetAddress ICMPFactory IPV4Address LinnFile LogLevelFile NetworkSocket PseudoFile UDPFactory

Public Member Functions

 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 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...
 
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...
 

Protected Attributes

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

Represents a file present on a FileSystem.

See also
FileSystem

Definition at line 39 of file File.h.

Constructor & Destructor Documentation

◆ File()

File::File ( const u32  inode,
const FileSystem::FileType  type = FileSystem::RegularFile,
const UserID  uid = ZERO,
const GroupID  gid = ZERO 
)

Constructor function.

Parameters
inodeThe inode number of this file.
typeType of file.
uidUser identity.
gidGroup identity.

Definition at line 21 of file File.cpp.

◆ ~File()

File::~File ( )
virtual

Destructor function.

Definition at line 34 of file File.cpp.

Member Function Documentation

◆ canRead()

bool File::canRead ( ) const
virtual

Check if the File has data ready for reading.

When this function returns true, it can be read without blocking.

Returns
Boolean

Reimplemented in UDPSocket.

Definition at line 74 of file File.cpp.

◆ canWrite()

bool File::canWrite ( ) const
virtual

Check if the File can be written to.

When this function returns true, it can be written without blocking.

Returns
Boolean

Definition at line 79 of file File.cpp.

◆ getInode()

u32 File::getInode ( ) const

Get inode number.

Returns
Inode number

Definition at line 38 of file File.cpp.

References m_inode.

Referenced by FileSystemServer::clearFileCache(), FileSystemServer::insertFileCache(), and FileSystemServer::lookupFile().

◆ getType()

FileSystem::FileType File::getType ( ) const

Retrieve our filetype.

Returns
FileType object.

Definition at line 43 of file File.cpp.

References m_type.

Referenced by FileSystemServer::lookupFile(), and FileSystemServer::registerFile().

◆ read()

FileSystem::Result File::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 in ATAController, Terminal, NS16550, VGA, Time, PL011, i8250, Directory, Keyboard, ICMPSocket, UDPSocket, LinnDirectory, PseudoFile, ARPSocket, LinnFile, ICMPFactory, UDPFactory, EthernetAddress, IPV4Address, and LogLevelFile.

Definition at line 48 of file File.cpp.

References FileSystem::NotSupported.

Referenced by FileSystemServer::inodeHandler().

◆ status()

FileSystem::Result File::status ( FileSystem::FileStat st)
virtual

◆ write()

FileSystem::Result File::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 in Terminal, NS16550, VGA, PL011, i8250, ICMPSocket, UDPSocket, PseudoFile, ARPSocket, EthernetAddress, IPV4Address, and LogLevelFile.

Definition at line 55 of file File.cpp.

References FileSystem::NotSupported.

Referenced by FileSystemServer::inodeHandler(), and DeviceLog::write().

Field Documentation

◆ m_access

FileSystem::FileModes File::m_access
protected

◆ m_gid

GroupID File::m_gid
protected

Group of the file.

Definition at line 142 of file File.h.

Referenced by status().

◆ m_inode

const u32 File::m_inode
protected

Inode number.

Definition at line 133 of file File.h.

Referenced by getInode(), and status().

◆ m_size

Size File::m_size
protected

◆ m_type

const FileSystem::FileType File::m_type
protected

Type of this file.

Definition at line 136 of file File.h.

Referenced by getType(), and status().

◆ m_uid

UserID File::m_uid
protected

Owner of the file.

Definition at line 139 of file File.h.

Referenced by status().


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