LibrePCB Developers Documentation
FileUtils Class Referencefinal

The FileUtils class provides some static methods to execute file operations. More...

#include <fileutils.h>

+ Collaboration diagram for FileUtils:

Public Member Functions

 FileUtils ()=delete
 
 FileUtils (const FileUtils &other)=delete
 
FileUtilsoperator= (const FileUtils &rhs)=delete
 

Static Public Member Functions

static QByteArray readFile (const FilePath &filepath)
 Read the content of a file into a QByteArray. More...
 
static void writeFile (const FilePath &filepath, const QByteArray &content)
 Write the content of a QByteArray into a file. More...
 
static void copyFile (const FilePath &source, const FilePath &dest)
 Copy a single file. More...
 
static void copyDirRecursively (const FilePath &source, const FilePath &dest)
 Copy a directory recursively. More...
 
static void move (const FilePath &source, const FilePath &dest)
 Move/rename a file or directory. More...
 
static void removeFile (const FilePath &file)
 Remove a single file. More...
 
static void removeDirRecursively (const FilePath &dir)
 Remove a directory recursively. More...
 
static void makePath (const FilePath &path)
 Create a directory with all parent directories. More...
 
static QList< FilePathgetFilesInDirectory (const FilePath &dir, const QStringList &filters=QStringList(), bool recursive=false, bool skipHiddenFiles=false)
 Get all files in a given directory (optionally filtered by extension) More...
 
static QList< FilePathfindDirectories (const FilePath &rootDir)
 Get all directories within a given directory. More...
 

Detailed Description

The FileUtils class provides some static methods to execute file operations.

Constructor & Destructor Documentation

◆ FileUtils() [1/2]

FileUtils ( )
delete

◆ FileUtils() [2/2]

FileUtils ( const FileUtils other)
delete

Member Function Documentation

◆ readFile()

QByteArray readFile ( const FilePath filepath)
static

Read the content of a file into a QByteArray.

Parameters
filepathThe file to read
Returns
The content of the file
Exceptions
ExceptionIf an error occurs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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
filepathThe file to (over)write
contentThe content to write
Exceptions
ExceptionIf an error occurs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyFile()

void copyFile ( const FilePath source,
const FilePath dest 
)
static

Copy a single file.

Parameters
sourceFilepath to an existing file.
destFilepath to a non-existing file (if it exists already, an exception will be thrown).
Exceptions
ExceptionIf an error occurs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyDirRecursively()

void copyDirRecursively ( const FilePath source,
const FilePath dest 
)
static

Copy a directory recursively.

Parameters
sourceFilepath to an existing directory.
destFilepath to a non-existing directory (if it exists already, an exception will be thrown).
Exceptions
ExceptionIf an error occurs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ move()

void move ( const FilePath source,
const FilePath dest 
)
static

Move/rename a file or directory.

Parameters
sourceFilepath to an existing file or directory.
destFilepath to a non-existing file/directory (if it exists already, an exception will be thrown).
Exceptions
ExceptionIf an error occurs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFile()

void removeFile ( const FilePath file)
static

Remove a single file.

Parameters
fileFilepath to a file (may or may not exist).
Exceptions
ExceptionIf an error occurs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeDirRecursively()

void removeDirRecursively ( const FilePath dir)
static

Remove a directory recursively.

Parameters
dirFilepath to a directory (may or may not exist).
Exceptions
ExceptionIf an error occurs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makePath()

void makePath ( const FilePath path)
static

Create a directory with all parent directories.

Parameters
pathFilepath to a directory (may or may not exist).
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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
dirFilepath to a directory (must exist)
filtersOnly files matching this filters are returned
recursiveIf true, also subdirectories are searched for files.
skipHiddenFilesIf true, hidden files won't be returned.
Returns
A list of filepaths to files in the specified directory
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDirectories()

QList< FilePath > findDirectories ( const FilePath rootDir)
static

Get all directories within a given directory.

Parameters
rootDirFilepath 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).
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

FileUtils & operator= ( const FileUtils rhs)
delete

The documentation for this class was generated from the following files: