C
QSafeFile Class
class SafeRenderer::QSafeFileThe QSafeFile class reads the data from the file. More...
Header: | #include <QSafeFile> |
Since: | QtSafeRenderer 1.0 |
Public Types
enum | FileException { FailureToOpen, SeekError, ReadError, OutOfBoundsError, WriteError } |
enum | OpenMode { ReadOnly, ReadAndWrite } |
Public Functions
QSafeFile(const SafeRenderer::qchar *const filenameArg, const SafeRenderer::QSafeFile::OpenMode modeArg = ReadOnly) | |
~QSafeFile() | |
SafeRenderer::quint32 | available() |
void | writeData(const SafeRenderer::quchar *const bufferArg, const SafeRenderer::quint32 size) const |
Member Type Documentation
enum QSafeFile::FileException
This enum describes the exception values in the QSafeFile class.
Constant | Value | Description |
---|---|---|
SafeRenderer::QSafeFile::FailureToOpen | 0 | Could not open the file for reading. |
SafeRenderer::QSafeFile::SeekError | 1 | Seek has failed on the opened file. For example, a filesystem error or file being a pipe may have caused the error. |
SafeRenderer::QSafeFile::ReadError | 2 | The requested number of bytes could not be read from the opened file. |
SafeRenderer::QSafeFile::OutOfBoundsError | 3 | The requested index is out of bounds. |
SafeRenderer::QSafeFile::WriteError | 4 | The requested value could not be written to the file. |
enum QSafeFile::OpenMode
This enum type is used to specify the open mode of a QSafeFile.
Constant | Value | Description |
---|---|---|
SafeRenderer::QSafeFile::ReadOnly | 0 | The file is opened in read-only mode. |
SafeRenderer::QSafeFile::ReadAndWrite | 1 | The file is opened in read-write mode. |
Member Function Documentation
QSafeFile::QSafeFile(const SafeRenderer::qchar *const filenameArg, const SafeRenderer::QSafeFile::OpenMode modeArg = ReadOnly)
Constructs the safe file object.
Opens the file named filenameArg with the open mode specified by modeArg.
modeArg is an optional parameter, with the default value being QSafeFile::OpenMode::ReadOnly. For possible open modes see QSafeFile::OpenMode.
In case of a failure, the following exception will be thrown:
Constant | Description |
---|---|
SafeRenderer::QSafeFile::FailureToOpen | The 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:
Constant | Description |
---|---|
SafeRenderer::QSafeFile::SeekError | Seek has failed on the opened file. For example, a filesystem error or file being a pipe may have caused the error. |
Note: close() will be called on the
Constant | Description |
---|---|
m_fileDescriptor | if exception is thrown. |
void QSafeFile::writeData(const SafeRenderer::quchar *const bufferArg, const SafeRenderer::quint32 size) const
writeData Writes size amount of data from the bufferArg to the opened file.
bufferArg Pointer to the data to be written. size The number of bytes to write. In case of a failure, the following exception will be thrown:
Constant | Description |
---|---|
SafeRenderer::QSafeFile::FailureToOpen | The file was not properly opened. |
SafeRenderer::QSafeFile::WriteError | An error occurred during the write operation. |
Available under certain Qt licenses.
Find out more.