Public Member Functions | |
NFile (void) | |
Constructs a NFile object. | |
NFile (const NString &path, NIODevice::Mode mode=NIODevice::ReadWrite) | |
Constructs a NFile object. | |
~NFile (void) | |
Destroys a NFile object releasing used resources. | |
bool | atEnd (void) const |
Tests whether the file is at the end. | |
bool | exists (void) const |
Tests whether the file exists. | |
int | handle (void) const |
Obtains the current file handle. | |
void | open (NIODevice::Mode mode) |
Opens the file. | |
void | closeDevice (void) |
Closes the file. | |
nint32 | read (NDataStream *buffer) |
Reads data from the file. | |
nint32 | read (NDataStream *buffer, nuint32 bytes) |
Reads at most 'bytes' of data from the file. | |
nint32 | readLine (NDataStream *buffer) |
Reads data from the file until find a newline. | |
nint32 | write (const NDataStream &data, nuint32 bytes=0) |
Writes data to the file. | |
nint64 | size (void) const |
Returns the size of the file. | |
void | setFileName (const NString &path) |
Sets the name of the file to manipulate. | |
NString | getFileName (void) const |
Gets the name of the file to manipulate. | |
Static Public Member Functions | |
static bool | exists (const NString &filepath) |
Tests whether the file exists. |
Definition at line 45 of file nfile.h.
NFile | ( | const NString & | path, | |
NIODevice::Mode | mode = NIODevice::ReadWrite | |||
) |
Constructs a NFile object.
path | The path of the file to open | |
mode | The mode to open the file as defined by the enum NIODevice::Mode |
Definition at line 32 of file nfile.cpp.
References open(), and setFileName().
bool atEnd | ( | void | ) | const |
Tests whether the file is at the end.
Definition at line 47 of file nfile.cpp.
Referenced by NShaHash::calculateFile(), NSha1Hash::calculateFile(), NMd5Hash::calculateFile(), NMd4Hash::calculateFile(), and NMd2Hash::calculateFile().
bool exists | ( | void | ) | const |
Tests whether the file exists.
Definition at line 56 of file nfile.cpp.
References NException::BASEIO, NIOException::FILE, and NString::toChar().
Referenced by open().
bool exists | ( | const NString & | filepath | ) | [static] |
Tests whether the file exists.
filepath | A filename with the path to it. |
Definition at line 73 of file nfile.cpp.
References NException::BASEIO, NIOException::FILE, and NString::toChar().
int handle | ( | void | ) | const |
Obtains the current file handle.
Definition at line 90 of file nfile.cpp.
Referenced by NXmlSchemaParser::parse(), NXmlParser::parse(), and size().
void open | ( | NIODevice::Mode | mode | ) | [virtual] |
Opens the file.
mode | The mode to open the file as defined by the enum NIODevice::Mode |
Implements NIODevice.
Definition at line 113 of file nfile.cpp.
References NException::BASEIO, exists(), NIOException::FILE, NIOException::getFlagByErr(), NIODevice::ReadOnly, and NString::toChar().
Referenced by NFile().
nint32 read | ( | NDataStream * | buffer | ) | [virtual] |
Reads data from the file.
buffer | A NDataStream buffer to store read data |
Implements NIODevice.
Definition at line 141 of file nfile.cpp.
References NIODevice::m_readBufferSize, and NDataStream::set().
Referenced by NShaHash::calculateFile(), NSha1Hash::calculateFile(), NMd5Hash::calculateFile(), NMd4Hash::calculateFile(), and NMd2Hash::calculateFile().
nint32 read | ( | NDataStream * | buffer, | |
nuint32 | bytes | |||
) | [virtual] |
Reads at most 'bytes' of data from the file.
buffer | A NDataStream buffer to store read data | |
bytes | Max number of bytes to read |
Implements NIODevice.
Definition at line 162 of file nfile.cpp.
References NDataStream::append().
nint32 readLine | ( | NDataStream * | buffer | ) | [virtual] |
Reads data from the file until find a newline.
buffer | A NDataStream buffer to store read data |
Implements NIODevice.
Definition at line 187 of file nfile.cpp.
References NDataStream::append().
nint32 write | ( | const NDataStream & | data, | |
nuint32 | bytes = 0 | |||
) | [virtual] |
Writes data to the file.
data | Data to be written to the file | |
bytes | Max number of bytes to write |
Implements NIODevice.
Definition at line 211 of file nfile.cpp.
References NDataStream::data(), and NDataStream::size().
nint64 size | ( | void | ) | const |
Returns the size of the file.
Definition at line 228 of file nfile.cpp.
References NException::BASEIO, NIOException::FILE, and handle().
void setFileName | ( | const NString & | path | ) |
Sets the name of the file to manipulate.
path | The path of the file |
Definition at line 242 of file nfile.cpp.
References closeDevice(), and NString::isNull().
Referenced by NFile().
NString getFileName | ( | void | ) | const |