|
Enroute Flight Navigation
A navigation app for VFR pilots
|
Base class for file reading classes. More...
#include <DataFileAbstract.h>
Public Member Functions | |
| bool | isValid () const |
| Validity check. | |
| QString | error () const |
| Error string. | |
| QStringList | warnings () const |
| Warnings. | |
Static Public Member Functions | |
| static QSharedPointer< QFile > | openFileURL (const QString &fileName) |
| Open file, file URL or Android content URL. | |
| static bool | saveFileAtomically (const QString &path, const QByteArray &data, QString *error=nullptr, QFileDevice::Permissions permissions={}) |
| Write data to a file atomically. | |
Base class for file reading classes.
This is an abstract base class for all classes that read data files, such as CUP, GeoJSON, GeoTIFF, …. Implementations should adhere to the following conventions:
Definition at line 44 of file DataFileAbstract.h.
|
inlinenodiscard |
Error string.
If the constructor found the file to be invalid, this method returns a human-readable, transated error string.
Definition at line 76 of file DataFileAbstract.h.
|
inlinenodiscard |
Validity check.
Use this method to check if the file is valid. If not, then all the other getter methods will typically return undefined results. Since all the heavy lifting is done in the constructor, this method is extremely lightweight.
This method is equivalent to !error().isEmpty()
Definition at line 67 of file DataFileAbstract.h.
|
staticnodiscard |
Open file, file URL or Android content URL.
This method opens a file. It handles file URLs and Android content URLs. The latter are downloaded to a temporary file.
| fileName | A file name, a file URL or an Android content URL |
|
staticnodiscard |
Write data to a file atomically.
The data is written through a QSaveFile, so that an existing file at the path is either replaced completely or left untouched, even if the app is killed while writing.
| path | Path of the file to write |
| data | Content to write |
| error | If non-null, receives a human-readable error message on failure |
| permissions | If non-empty, the permissions to set on the file before it replaces the old one (e.g. owner read/write only for files with secrets). If empty, the default permissions apply. |
|
inlinenodiscard |
Warnings.
If the constructor found non-critical issues in the file, this method returns a list of human-readable, transated warnings.
Definition at line 85 of file DataFileAbstract.h.