Base class of a file description. More...
Signals | |
void | fileNameChanged (const QString &fileName) |
Emitted when the file name has changed. More... | |
Public Member Functions | |
QtlFile (const QString &fileName, QObject *parent=0) | |
Constructor. More... | |
QtlFile (const QtlFile &other, QObject *parent=0) | |
Copy constructor. More... | |
QString | directoryName () const |
Get the directory name of the file. More... | |
QString | fileName () const |
Get the file name. More... | |
bool | isSet () const |
Check if the file name is set. More... | |
QtlByteBlock | readBinary (int maxSize=-1) const |
Read the binary content of the file. More... | |
QString | readText () const |
Read the text content of the file. More... | |
QStringList | readTextLines (int maxSize=-1) const |
Read the text content of the file. More... | |
virtual bool | setFileName (const QString &fileName) |
Set the file name. More... | |
QString | shortPath (bool keepOnError) const |
Get the "short path name" of the file. More... | |
bool | writeBinary (const QtlByteBlock &content) |
Write the binary content of the file. More... | |
bool | writeText (const QString &text) |
Write the text content of the file. More... | |
bool | writeTextLines (const QStringList &lines) |
Write the text content of the file. More... | |
Static Public Member Functions | |
static QString | absoluteNativeFilePath (const QString &path, bool removeSymLinks=false) |
Build an absolute file path with native directory separators. More... | |
static QStringList | commandSearchPath () |
Return the list of directories in the system search path. More... | |
static bool | createDirectory (const QString &path, bool createOnly=false) |
Create a directory and all parent directories if necessary. More... | |
static QString | enforceSuffix (const QString &path, const QString &suffix, Qt::CaseSensitivity cs=Qt::CaseInsensitive) |
Enforce a suffix in a file name. More... | |
static QStringList | expandFilePath (const QString &path, QtlFilePathFilterInterface *filter=0) |
Expand a file path containing wildcards to all existing files matching the specification. More... | |
static QString | parentPath (const QString &path, int upLevels=1) |
Get the absolute file path of the parent directory of a file. More... | |
template<typename T > | |
static bool | readBigEndianAt (QIODevice &device, qint64 position, T &data) |
Read a big endian integer in a binary file at a given position. More... | |
static bool | readBinary (QIODevice &device, QtlByteBlock &data, int maxSize=-1) |
Read a portion of a binary file at the current position. More... | |
static bool | readBinaryAt (QIODevice &device, qint64 position, QtlByteBlock &data, int maxSize=-1) |
Read a portion of a binary file at a given position. More... | |
static QtlByteBlock | readBinaryFile (const QString &fileName, int maxSize=-1) |
Read the content of a binary file. More... | |
static QString | readTextFile (const QString &fileName) |
Read the content of a text file. More... | |
static QStringList | readTextLinesFile (const QString &fileName, int maxSize=-1) |
Read the content of a text file. More... | |
static QString | search (const QString &baseName, const QStringList &searchPath, const QString &extension=QString(), QFile::Permissions permissions=QFile::Permissions()) |
Search a file in a list of directories. More... | |
static QString | searchExecutable (const QString &baseName, const QStringList &searchPath) |
Search an executable file in a list of directories. More... | |
static QString | searchParentSubdirectory (const QString &dir, const QString &subdir, int maxLevels=128) |
Search a subdirectory in the parent path. More... | |
static QString | shortPath (const QString &path, bool keepOnError) |
Get the "short path name" of a file path. More... | |
static QString | toFileName (const QUrl &url) |
Format the content of an URL into a file path if the URL scheme is file: More... | |
static bool | writeBinary (QIODevice &file, const QtlByteBlock &data) |
Write binary data into an open file. More... | |
static bool | writeBinary (QIODevice &file, const void *data, int size, bool processEvents=false) |
Write binary data into an open file. More... | |
static bool | writeBinaryFile (const QString &fileName, const QtlByteBlock &content) |
Write the content of a binary file. More... | |
static bool | writeTextFile (const QString &fileName, const QString &text) |
Write the content of a text file. More... | |
static bool | writeTextLinesFile (const QString &fileName, const QStringList &lines) |
Write the content of a text file. More... | |
Private Member Functions | |
QtlFile () Q_DECL_EQ_DELETE | |
Private Attributes | |
QString | _fileName |
File name. More... | |
Base class of a file description.
|
explicit |
Constructor.
[in] | fileName | File name. |
[in] | parent | Optional parent widget. |
|
explicit |
Copy constructor.
[in] | other | Other instance to copy (except parent). |
[in] | parent | Optional parent widget. |
|
private |
|
inline |
Get the file name.
QString QtlFile::directoryName | ( | ) | const |
Get the directory name of the file.
|
inline |
Check if the file name is set.
|
virtual |
Set the file name.
[in] | fileName | File path. |
Reimplemented in QtlMovieExecFile.
|
static |
Build an absolute file path with native directory separators.
[in] | path | The file path to transform. |
[in] | removeSymLinks | If true, remove symbolic links. |
|
static |
Return the list of directories in the system search path.
|
static |
Search a file in a list of directories.
[in] | baseName | Base file name. If baseName contains a directory specification, it is not searched into the list of directories. |
[in] | searchPath | List of directories to search. |
[in] | extension | If baseName does not end with extension, the file is searched with this extension. |
[in] | permissions | Keep only files having these permissions. |
|
inlinestatic |
Search an executable file in a list of directories.
[in] | baseName | Base file name. If baseName contains a directory specification, it is not searched into the list of directories. Do not add platform-specific extension such as ".exe". |
[in] | searchPath | List of directories to search. |
|
static |
Expand a file path containing wildcards to all existing files matching the specification.
The standard Unix wildcards '*' and '?' are recognized. Additionally, the non-standard wildcard "**", when used as a directory component, means all subdirectories.
[in] | path | The path containing wildcards. |
[in] | filter | Optional filter. If null, all files are matched. |
|
static |
Get the absolute file path of the parent directory of a file.
[in] | path | The path of the file. |
[in] | upLevels | The number of parent levels to climb. Default to 1. |
|
static |
Create a directory and all parent directories if necessary.
[in] | path | Directory path to create. |
[in] | createOnly | If true, the directory must be created, meaning that the operation fails if the directory already exists. |
|
static |
Search a subdirectory in the parent path.
First the subdirectory subdir is searched in the directory dir. If not found, it is searched in the parent of dir and then in its upper level, etc., until subdir is found or the root directory is reached.
[in] | dir | Start searching at dir. |
[in] | subdir | Name of the subdirectory to search. |
[in] | maxLevels | Maximum number of levels to search. |
|
static |
Get the "short path name" of a file path.
On Windows platforms, return the path name in DOS 8.3 convention. On other platforms, return the input path.
[in] | path | The path of the file or directory. If the file or directory does not exist, the result is unpredictable. |
[in] | keepOnError | If true and the conversion fails, return the same path. |
|
inline |
Get the "short path name" of the file.
On Windows platforms, return the path name in DOS 8.3 convention. On other platforms, return the input path.
[in] | keepOnError | If true and the conversion fails, return the same as fileName(). |
|
static |
Enforce a suffix in a file name.
If path does not end with suffix, it is added.
[in] | path | A file path. |
[in] | suffix | The suffix to check or add. |
[in] | cs | Indicates if the file names are case sensitive. |
|
static |
Format the content of an URL into a file path if the URL scheme is file:
[in] | url | The URL. |
|
static |
Write the content of a binary file.
Error reporting is minimal.
[in] | fileName | Name of file to write. |
[in] | content | Content of the file to write. |
|
inlinestatic |
Write binary data into an open file.
Loop on write operations until all data are written or an error occured. Error reporting is minimal.
[in] | file | An open file. |
[in] | data | Binary data to write. |
|
static |
Write binary data into an open file.
Loop on write operations until all data are written or an error occured. Error reporting is minimal.
[in] | file | An open file. |
[in] | data | Address of binary data to write. |
[in] | size | Size in bytes of binary data to write. |
[in] | processEvents | If true, process all pending events before each write operation. |
|
inline |
Write the binary content of the file.
Error reporting is minimal.
[in] | content | Content of the file to write. |
|
static |
Read the content of a binary file.
Error reporting is minimal.
[in] | fileName | Name of file to read. |
[in] | maxSize | Maximum size to read. If the file is larger than maxSize, skip the rest of the file. If negative, read the entire file. |
|
inline |
Read the binary content of the file.
Error reporting is minimal.
[in] | maxSize | Maximum size to read. If the file is larger than maxSize, skip the rest of the file. If negative, read the entire file. |
|
static |
Read the content of a text file.
Error reporting is minimal.
[in] | fileName | Name of file to read. |
[in] | maxSize | Maximum number of characters to return. If the file is larger than maxSize, skip the rest of the file. If negative, read the entire file. |
|
inline |
Read the text content of the file.
Error reporting is minimal.
[in] | maxSize | Maximum number of characters to return. If the file is larger than maxSize, skip the rest of the file (do not truncate the last line, so the actual number of returned characters may be larger). If negative, read the entire file. |
|
static |
Read the content of a text file.
Error reporting is minimal.
[in] | fileName | Name of file to read. |
|
inline |
Read the text content of the file.
Error reporting is minimal.
|
static |
Write the content of a text file.
Error reporting is minimal.
[in] | fileName | Name of file to write. |
[in] | lines | A list of strings containing the text lines of the file. |
|
inline |
Write the text content of the file.
Error reporting is minimal.
[in] | lines | A list of strings containing the text lines of the file. |
|
static |
Write the content of a text file.
Error reporting is minimal.
[in] | fileName | Name of file to write. |
[in] | text | The text content of the file. |
|
inline |
Write the text content of the file.
Error reporting is minimal.
[in] | text | The text content of the file. |
|
static |
Read a portion of a binary file at the current position.
[in,out] | device | I/O device to read. |
[out] | data | Returned byte array containing the read data. |
[in] | maxSize | Maximum size to read. If the file is larger than maxSize, skip the rest of the file. If negative, read the entire file. |
|
inlinestatic |
Read a portion of a binary file at a given position.
[in,out] | device | I/O device to read. |
[in] | position | Position to seek in the device before reading. |
[out] | data | Returned byte array containing the read data. |
[in] | maxSize | Maximum size to read. If the file is larger than maxSize, skip the rest of the file. If negative, read the entire file. |
|
inlinestatic |
Read a big endian integer in a binary file at a given position.
T | Integer type. |
[in,out] | device | I/O device to read. |
[in] | position | Position to seek in the device before reading. |
[out] | data | Read data. |
|
signal |
Emitted when the file name has changed.
[in] | fileName | Absolute file path. |
|
private |
File name.