C

QSafeFile Class

class SafeRenderer::QSafeFile

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

Header: #include <QSafeFile>
Since: QtSafeRenderer 1.0

This class was introduced in QtSafeRenderer 1.0.

Public Types

enum FileException { FailureToOpen, SeekError, ReadError }

Public Functions

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

Detailed Description

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(const SafeRenderer::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.

SafeRenderer::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(SafeRenderer::quchar *const buffer, const SafeRenderer::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.

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