C

QSafeFile Class

(SafeRenderer::QSafeFile)

The QSafeFile class reads the data from the file. More...

Header: #include <QSafeFile>
Since: QtSafeRenderer 1.0

Public Types

enum FileException { FailureToOpen, SeekError, ReadError }

Public Functions

QSafeFile()
QSafeFile(const qchar * const filename)
~QSafeFile()
quint32 available()
void readData(quchar * const buffer, const quint32 bytes)
quint32 readInteger()
void rewindToStart()

Detailed Description

The QSafeFile class reads the data from the file.

The QSafeFile uses the Posix API for file access.

Member Type Documentation

enum QSafeFile::FileException

This enum describes the exception values in the QSafeFile class.

ConstantValueDescription
SafeRenderer::QSafeFile::FailureToOpen0Could not open the file for reading.
SafeRenderer::QSafeFile::SeekError1Seek has failed on the opened file. For example, a filesystem error or file being a pipe may have caused the error.
SafeRenderer::QSafeFile::ReadError2The requested number of bytes could not be read from the opened file.

Member Function Documentation

QSafeFile::QSafeFile()

Default constructs an instance of QSafeFile.

QSafeFile::QSafeFile(const qchar * const filename)

Constructs the safe file object.

Opens the file named filename.

In case of a failure, the following exception will be thrown:

ConstantDescription
SafeRenderer::QSafeFile::FailureToOpenThe file could not be opened for reading.

QSafeFile::~QSafeFile()

Destructs a safe file object.

Closes the file if the file is open.

quint32 QSafeFile::available()

Returns the amount of bytes is available in the file.

In case of a failure, the following exception will be thrown:

ConstantDescription
SafeRenderer::QSafeFile::SeekErrorSeek has failed on the opened file. For example, a filesystem error or file being a pipe may have caused the error.

void QSafeFile::readData(quchar * const buffer, const quint32 bytes)

Reads bytes amount of data from the opened file to the buffer.

In case of a failure, the following exception will be thrown:

ConstantDescription
SafeRenderer::QSafeFile::ReadErrorThe requested number of bytes could not be read from the opened file.

quint32 QSafeFile::readInteger()

Returns quint32 value read from the file.

In case of a failure, the following exception will be thrown:

ConstantDescription
SafeRenderer::QSafeFile::ReadErrorThe requested number of bytes could not be read from the opened file.

void QSafeFile::rewindToStart()

Seeks to the beginning of the file.

In case of a failure, the following exception will be thrown:

ConstantDescription
SafeRenderer::QSafeFile::SeekErrorSeek has failed on the opened file. For example, a filesystem error or file being a pipe may have caused the error.

Available under certain Qt licenses.
Find out more.