LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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())
 Get all files in a given directory (optionally filtered by extension) More...
 

Detailed Description

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

Author
ubruhin
Date
2016-08-07

Constructor & Destructor Documentation

FileUtils ( )
delete
FileUtils ( const FileUtils other)
delete

Member Function Documentation

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:

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:

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:

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:

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:

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:

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:

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:

QList< FilePath > getFilesInDirectory ( const FilePath dir,
const QStringList &  filters = QStringList() 
)
static

Get all files in a given directory (optionally filtered by extension)

Parameters
dirFilepath to a directory (must exist)
filterOnly files matching this filter are 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:

FileUtils& operator= ( const FileUtils rhs)
delete

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