FreeNOS
|
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... | |
u8 * | m_buffer |
Stored contents of the file. More... | |
Size | m_size |
Size of the file in bytes. More... | |
Provides a buffered abstract interface to a file.
Definition at line 34 of file BufferedFile.h.
enum BufferedFile::Result |
BufferedFile::BufferedFile | ( | const char * | path | ) |
Constructor.
Definition at line 28 of file BufferedFile.cpp.
BufferedFile::~BufferedFile | ( | ) |
const void * BufferedFile::buffer | ( | ) | const |
Get file buffer.
Definition at line 48 of file BufferedFile.cpp.
References m_buffer.
Referenced by Decompress::decompressFile(), DhcpClient::initialize(), MpiTarget::initializeMaster(), and MpiProxy::startRemoteProcess().
const char * BufferedFile::path | ( | ) | const |
Get file path.
Definition at line 43 of file BufferedFile.cpp.
References m_path.
Referenced by Decompress::decompressFile().
BufferedFile::Result BufferedFile::read | ( | ) |
Read the file (buffered)
Definition at line 58 of file BufferedFile.cpp.
References assert, close(), errno, ERROR, IOError, m_buffer, m_path, m_size, NotFound, O_RDONLY, open(), stat::st_size, stat(), strerror(), Success, and ZERO.
Referenced by Decompress::decompressFile(), DhcpClient::initialize(), MpiTarget::initializeMaster(), and MpiProxy::startRemoteProcess().
const Size BufferedFile::size | ( | ) | const |
Get file size.
Definition at line 53 of file BufferedFile.cpp.
References m_size.
Referenced by Decompress::decompressFile(), MpiTarget::initializeMaster(), MpiProxy::startRemoteProcess(), and write().
BufferedFile::Result BufferedFile::write | ( | const void * | data, |
const Size | size | ||
) | const |
Write the file (unbuffered)
data | Input data to write |
size | Number of bytes to write |
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().
|
private |
Stored contents of the file.
Definition at line 106 of file BufferedFile.h.
Referenced by buffer(), read(), and ~BufferedFile().
|
private |
Path to the file.
Definition at line 103 of file BufferedFile.h.
|
private |
Size of the file in bytes.
Definition at line 109 of file BufferedFile.h.