The FileUtils class provides commonly used file related functionality. More...
#include <FileUtils.h>
Public Types | |
enum | ContainedTasks { TaskFindFilesUnderDir = 0 } |
Access names for tasks provided by FileUtils. More... |
Public Member Functions | |
QFileInfoList | findFilesUnderDir (const QString &dirName, const QString &file_filters=QString(), const QString &ignore_list=QString(), QDir::Filters filters=QDir::Files|QDir::NoDotAndDotDot, QDir::SortFlags sort=QDir::NoSort, bool first_run=true) |
Finds all files in the directory hierarhcy under a directory. | |
QFileInfoList | lastFilesUnderDir () |
Returns the last QFileInfoList produced by fileFilesUnderDir(). | |
QObject * | objectBase () |
Returns the QObject* base of the interface. | |
const QObject * | objectBase () const |
Returns a const QObject* base of the interface. | |
void | setFindFilesUnderDirParams (const QString &dirName, const QString &file_filters=QString(), const QString &ignore_list=QString(), QDir::Filters filters=QDir::Files|QDir::NoDotAndDotDot, QDir::SortFlags sort=QDir::NoSort) |
Sets up the paramaters for future findFilesUnderDir() runs. | |
QString | taskNameToString (ContainedTasks task_name) const |
ContainedTasks to string conversion function. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::ITaskContainer | |
void | disableTask (int task_id) |
Disables the creation and registering in the global object pool of a task object to monitor the progress of the task. | |
void | enableTask (int task_id) |
Enables the creation and registering in the global object pool of a task object to monitor the progress of the task. | |
int | findTaskID (const QString &task_name) const |
Returns the task ID for the task specified by the given task_name. | |
bool | isTaskActive (int task_id) const |
Checks if a specific task is active. | |
bool | isTaskGlobal (int task_id) const |
Checks if a specific task is global or local. See Qtilities::Core::Interfaces::ITask::TaskType. | |
void | setTaskGlobal (int task_id) |
Sets a task a global. See Qtilities::Core::Interfaces::ITask::TaskType. | |
void | setTaskLocal (int task_id) |
Sets a task a local. See Qtilities::Core::Interfaces::ITask::TaskType. | |
ITask * | task (int task_id) const |
Returns the task specified by the given task_id. | |
QList< ITask * > | tasks () const |
A list of tasks provided by the object. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::IObjectBase | |
QString | objectOriginID () const |
Allows interfaces to provide some sort of source identification. | |
void | setObjectOriginID (const QString &object_origin_id) |
Allows setting of the object source ID of this interface implementation. |
Static Public Member Functions | |
static QString | appendToFileName (const QString &fullFileName, const QString &append_string) |
Appends a string to the file name part of the file, that is after the file's name and before the extension. | |
static bool | compareFiles (const QString &file1, const QString &file2) |
Compares two files and returns true if they are exactly the same, false otherwise. | |
static bool | comparePaths (const QString &path1, const QString &path2, Qt::CaseSensitivity cs=Qt::CaseInsensitive) |
Compares two paths in a system independant way. | |
static int | fileHashCode (const QString &file) |
Calculates a hash code for a text file. | |
static bool | makeLocalCopyOfResource (const QString &resource_path, const QString &local_path, QString *errorMsg, QFile::Permissions local_permissions=QFile::ReadOwner|QFile::WriteOwner) |
Makes a local copy of the specified resource file. | |
static bool | pathStartsWith (const QString &child_path, const QString &parent_path, Qt::CaseSensitivity cs=Qt::CaseInsensitive) |
Check if one path starts with another path (does it checks if the one path is a parent of another path). | |
static bool | removeDir (const QString &dirName) |
Removes the specified directory along with all of its contents. | |
static QString | removeFromFileName (const QString &fullFileName, int len) |
Removes the specified number of characters from the end of the file name part of the file, that is after the file's name and before the extension. | |
static QString | toNativeSeparators (QString path) |
Converts a path to the native format of the underlying OS. |
Additional Inherited Members | |
Protected Member Functions inherited from Qtilities::Core::Interfaces::ITaskContainer | |
Task * | findTask (const QString &task_name) const |
Returns the Task object specified by the given task_name. | |
void | registerTask (Task *task, const QString &task_name) |
Registers a task in this container. |
The FileUtils class provides commonly used file related functionality.
This class was added in Qtilities v1.0.
Access names for tasks provided by FileUtils.
TaskFindFilesUnderDir |
The task which allows monitoring of the findFilesUnderDir() function's progress. |
|
static |
Compares two paths in a system independant way.
This function takes two paths and checks if they are the same. The function does the following:
If both files does not exist, the following check is done:
path1 | The first path to check. |
path2 | The second path to check against path1. |
cs | The case sensitivity of the check. This only applies to Windows. Only Unix based systems Qt::CaseSensitive is always used. |
This function was added in Qtilities v1.1.
|
static |
Calculates a hash code for a text file.
If something went wrong (for example if the file does not exist), -1 is returned as an error code.
QFileInfoList Qtilities::Core::FileUtils::findFilesUnderDir | ( | const QString & | dirName, |
const QString & | file_filters = QString() , |
||
const QString & | ignore_list = QString() , |
||
QDir::Filters | filters = QDir::Files | QDir::NoDotAndDotDot , |
||
QDir::SortFlags | sort = QDir::NoSort , |
||
bool | first_run = true |
||
) |
Finds all files in the directory hierarhcy under a directory.
Finds all files under in the complete directory hierarhcy under dirName. The ITask implementation on this object is linked to this function's processing. Thus if you call this function, you can monitor the progress of findFilesUnderDir() through the ITask interface implementation provided by the TaskFindFilesUnderDir task.
It is possible to find just directories by specifying the filters to be QDir::AllDirs without including QDir::Files.
dirName | Path of directory to search under. |
file_filters | The list of files which must be returned, when empty all files are returned. For example: *.bit *.log *.ngc, when empty all files added by default (*.*). |
ignore_list | Files which should be ignored. Must be in the format: *.svn *.bak *.tmp |
filters | The QDir::Filters to apply when searching for files and folders. |
sort | The QDir::SortFlags to apply when searching for files and folders. |
first_run | Ignore this parameter, used in recursive operations. |
|
static |
Makes a local copy of the specified resource file.
This function will create a local copy of a resource file.
resource_path | The resource to make a copy of. |
local_path | The target local path for the resource. |
errorMsg | When specified, will be populated by any error messages when the function returns false. |
local_permissions | The permissions to set on the local file after the copy process has been completed. |
This function was added in Qtilities v1.3.
|
inlinevirtual |
Returns a const QObject* base of the interface.
This function can be used in const methods, but make sure that you don't modify things that should stay const. An example where this is used is when we want to get a property on an object in a const method. This is a const operation.
Implements Qtilities::Core::Interfaces::IObjectBase.
|
static |
Check if one path starts with another path (does it checks if the one path is a parent of another path).
child_path | The child path. |
parent_path | The parent path. |
cs | The case sensitivity of the check. This only applies to Windows. Only Unix based systems Qt::CaseSensitive is always used. |
This function was added in Qtilities v1.2.
|
static |
Removes the specified directory along with all of its contents.
dirName | Path of directory to remove. |
void Qtilities::Core::FileUtils::setFindFilesUnderDirParams | ( | const QString & | dirName, |
const QString & | file_filters = QString() , |
||
const QString & | ignore_list = QString() , |
||
QDir::Filters | filters = QDir::Files | QDir::NoDotAndDotDot , |
||
QDir::SortFlags | sort = QDir::NoSort |
||
) |
Sets up the paramaters for future findFilesUnderDir() runs.
dirName | Path of directory to search under. |
file_filters | The list of files which must be returned, when empty all files are returned. For example: *.bit *.log *.ngc , when empty all files added by default (*.*). |
ignore_list | Files which should be ignored. Must be in the format: *.svn *.bak *.tmp |
filters | The QDir::Filters to apply when searching for files and folders. |
sort | The QDir::SortFlags to apply when searching for files and folders. |
first_run | Ignore this parameter, used in recursive operations. |
|
static |
Converts a path to the native format of the underlying OS.
This function is similar to QDir::toNativeSeparators(), but it supports linux as well.
This function was added in Qtilities v1.2.
Qtilities : Reference Documentation | Back to top |
Copyright © 2009-2013, Jaco Naudé
|