FreeNOS
Public Types | Public Member Functions | Private Attributes
BufferedFile Class Reference

Provides a buffered abstract interface to a file. More...

#include <BufferedFile.h>

Public Types

enum  Result { Success, NotFound, IOError }
 Result codes. More...
 

Public Member Functions

 BufferedFile (const char *path)
 Constructor. More...
 
 ~BufferedFile ()
 Destructor. More...
 
const char * path () const
 Get file path. More...
 
const void * buffer () const
 Get file buffer. More...
 
const Size size () const
 Get file size. More...
 
Result read ()
 Read the file (buffered) More...
 
Result write (const void *data, const Size size) const
 Write the file (unbuffered) More...
 

Private Attributes

const char * m_path
 Path to the file. More...
 
u8m_buffer
 Stored contents of the file. More...
 
Size m_size
 Size of the file in bytes. More...
 

Detailed Description

Provides a buffered abstract interface to a file.

Definition at line 34 of file BufferedFile.h.

Member Enumeration Documentation

◆ Result

Result codes.

Enumerator
Success 
NotFound 
IOError 

Definition at line 41 of file BufferedFile.h.

Constructor & Destructor Documentation

◆ BufferedFile()

BufferedFile::BufferedFile ( const char *  path)

Constructor.

Definition at line 28 of file BufferedFile.cpp.

◆ ~BufferedFile()

BufferedFile::~BufferedFile ( )

Destructor.

Definition at line 35 of file BufferedFile.cpp.

References m_buffer, and ZERO.

Member Function Documentation

◆ buffer()

const void * BufferedFile::buffer ( ) const

Get file buffer.

Returns
File buffer

Definition at line 48 of file BufferedFile.cpp.

References m_buffer.

Referenced by Decompress::decompressFile(), DhcpClient::initialize(), MpiTarget::initializeMaster(), and MpiProxy::startRemoteProcess().

◆ path()

const char * BufferedFile::path ( ) const

Get file path.

Returns
File path pointer

Definition at line 43 of file BufferedFile.cpp.

References m_path.

Referenced by Decompress::decompressFile().

◆ read()

BufferedFile::Result BufferedFile::read ( )

◆ size()

const Size BufferedFile::size ( ) const

Get file size.

Returns
File size in bytes

Definition at line 53 of file BufferedFile.cpp.

References m_size.

Referenced by Decompress::decompressFile(), MpiTarget::initializeMaster(), MpiProxy::startRemoteProcess(), and write().

◆ write()

BufferedFile::Result BufferedFile::write ( const void *  data,
const Size  size 
) const

Write the file (unbuffered)

Note
Does not update the internal buffer
Parameters
dataInput data to write
sizeNumber of bytes to write
Returns
Result code

Definition at line 99 of file BufferedFile.cpp.

References close(), errno, ERROR, IOError, m_path, O_RDWR, open(), size(), strerror(), and Success.

Referenced by DhcpClient::setIpAddress().

Field Documentation

◆ m_buffer

u8* BufferedFile::m_buffer
private

Stored contents of the file.

Definition at line 106 of file BufferedFile.h.

Referenced by buffer(), read(), and ~BufferedFile().

◆ m_path

const char* BufferedFile::m_path
private

Path to the file.

Definition at line 103 of file BufferedFile.h.

Referenced by path(), read(), and write().

◆ m_size

Size BufferedFile::m_size
private

Size of the file in bytes.

Definition at line 109 of file BufferedFile.h.

Referenced by read(), and size().


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