The FileUtils class provides some static methods to execute file operations.
More...
#include <fileutils.h>
The FileUtils class provides some static methods to execute file operations.
◆ FileUtils() [1/2]
◆ FileUtils() [2/2]
◆ readFile()
QByteArray readFile |
( |
const FilePath & |
filepath | ) |
|
|
static |
Read the content of a file into a QByteArray.
- Parameters
-
- Returns
- The content of the file
- Exceptions
-
◆ writeFile()
void writeFile |
( |
const FilePath & |
filepath, |
|
|
const QByteArray & |
content |
|
) |
| |
|
static |
Write the content of a QByteArray into a file.
If the file does not exist, it will be created (with all parent directories).
- Parameters
-
filepath | The file to (over)write |
content | The content to write |
- Exceptions
-
◆ copyFile()
Copy a single file.
- Parameters
-
source | Filepath to an existing file. |
dest | Filepath to a non-existing file (if it exists already, an exception will be thrown). |
- Exceptions
-
◆ copyDirRecursively()
Copy a directory recursively.
- Parameters
-
source | Filepath to an existing directory. |
dest | Filepath to a non-existing directory (if it exists already, an exception will be thrown). |
- Exceptions
-
◆ move()
Move/rename a file or directory.
- Parameters
-
source | Filepath to an existing file or directory. |
dest | Filepath to a non-existing file/directory (if it exists already, an exception will be thrown). |
- Exceptions
-
◆ removeFile()
void removeFile |
( |
const FilePath & |
file | ) |
|
|
static |
Remove a single file.
- Parameters
-
file | Filepath to a file (may or may not exist). |
- Exceptions
-
◆ removeDirRecursively()
void removeDirRecursively |
( |
const FilePath & |
dir | ) |
|
|
static |
Remove a directory recursively.
- Parameters
-
dir | Filepath to a directory (may or may not exist). |
- Exceptions
-
◆ makePath()
Create a directory with all parent directories.
- Parameters
-
path | Filepath to a directory (may or may not exist). |
◆ getFilesInDirectory()
QList< FilePath > getFilesInDirectory |
( |
const FilePath & |
dir, |
|
|
const QStringList & |
filters = QStringList() , |
|
|
bool |
recursive = false , |
|
|
bool |
skipHiddenFiles = false |
|
) |
| |
|
static |
Get all files in a given directory (optionally filtered by extension)
- Parameters
-
dir | Filepath to a directory (must exist) |
filters | Only files matching this filters are returned |
recursive | If true, also subdirectories are searched for files. |
skipHiddenFiles | If true, hidden files won't be returned. |
- Returns
- A list of filepaths to files in the specified directory
◆ findDirectories()
Get all directories within a given directory.
- Parameters
-
rootDir | Filepath to a directory (may or may not exist). |
- Returns
- A list of filepaths to directories in the specified directory (empty if the directory doesn't exist).
◆ operator=()
The documentation for this class was generated from the following files: