QtilitiesFileInfo is a class which extends QFileInfo with additional functionality. More...
#include <QtilitiesFileInfo.h>
Public Member Functions | |
QString | absoluteToRelativeFilePath () const |
Gives the file path made absolute to relativeToPath(). | |
QString | absoluteToRelativePath () const |
Gives the path made absolute to relativeToPath(). | |
QString | actualFilePath () const |
Returns the actual file path without you needing to know if the file is relative or absolute. | |
QString | actualPath () const |
Returns the actual path without you needing to know if the file is relative or absolute. | |
bool | compareActualFilePaths (const QtilitiesFileInfo &ref) const |
Compares the actual file paths of QtilitiesFileInfo objects and returns true if they are the same, false otherwise. | |
bool | hasRelativeToPath () const |
Indicates if a relative to path has been set. | |
bool | operator!= (const QtilitiesFileInfo &ref) const |
Operator overload to compare two QtilitiesFileInfo objects are not equal. | |
bool | operator== (const QtilitiesFileInfo &ref) const |
Operator overload to compare two QtilitiesFileInfo objects with each other. | |
QtilitiesFileInfo (const QString &file=QString(), const QString &relative_to_path=QString()) | |
Constructs a new QtilitiesFileInfo that gives information about the given file. | |
QString | relativeToPath () const |
Gets the relative to path of the file. | |
virtual void | setFileName (const QString &new_file_name) |
Sets the the file name part of the file. | |
void | setRelativeToPath (const QString &relative_to_path) |
Gets the relative to path of the file. | |
bool | updateRelativeToPath (const QString &old_relative_to_path, const QString &new_relative_to_path) |
Replaces the relative to path if it matches the old relative to path. |
Static Public Member Functions | |
static QString | invalidFileNameCharacters () |
Returns the invalid characters which are checked in isValidFileName() in a QString seperated by spaces. | |
static QString | invalidFilePathCharacters () |
Returns the invalid characters which are checked in isValidFilePath() in a QString seperated by spaces. | |
static bool | isValidFileName (const QString file_name) |
Indicates if a file name is valid. | |
static bool | isValidFilePath (const QString file_path) |
Indicates if a file path is valid. |
QtilitiesFileInfo is a class which extends QFileInfo with additional functionality.
QtilitiesFileInfo extends the way that QFileInfo handles relative files so that the path which relative to files are relative to can be specified. Normally QFileInfo::makeAbsolute() will make relative to paths relative to the application path. QtilitiesFileInfo allows you to specify the relative to path using setRelativeToPath() and provides a relativeToPath() access function. It is also possible to set the relativeToPath() as part of the constructor.
The actualPath() and actualFilePath() functions allows you to get the actual path of a file without needing to know if it is relative or not (for relative files, a relativeToPath must be specified to get the actual path).
Additional extended functions include:
The following example shows how the class works and you will notice that it is very close to QFileInfo, except for the additional functionality:
In the same way that QFileInfo handles Unix file names, the above example will always begin with the root, '/', directory.
This class was added in Qtilities v1.0.
Qtilities::Core::QtilitiesFileInfo::QtilitiesFileInfo | ( | const QString & | file = QString() , |
const QString & | relative_to_path = QString() |
||
) |
Constructs a new QtilitiesFileInfo that gives information about the given file.
file | The file for which information is required. |
relative_to_path | A path that indicates to what file is relative to if it is a relative to path. |
QString Qtilities::Core::QtilitiesFileInfo::absoluteToRelativeFilePath | ( | ) | const |
Gives the file path made absolute to relativeToPath().
This function only does something is the file is relative.
QString Qtilities::Core::QtilitiesFileInfo::absoluteToRelativePath | ( | ) | const |
Gives the path made absolute to relativeToPath().
This function only does something is the file is relative.
QString Qtilities::Core::QtilitiesFileInfo::actualFilePath | ( | ) | const |
Returns the actual file path without you needing to know if the file is relative or absolute.
This function will return the file actual path of the file in the following way:
QString Qtilities::Core::QtilitiesFileInfo::actualPath | ( | ) | const |
Returns the actual path without you needing to know if the file is relative or absolute.
This function will return the actual path of the file in the following way:
bool Qtilities::Core::QtilitiesFileInfo::hasRelativeToPath | ( | ) | const |
Indicates if a relative to path has been set.
|
inlinestatic |
Returns the invalid characters which are checked in isValidFileName() in a QString seperated by spaces.
|
inlinestatic |
Returns the invalid characters which are checked in isValidFilePath() in a QString seperated by spaces.
|
static |
Indicates if a file name is valid.
Checks if the file name is valid. Thus checks that it does not contain any of the following characters:
|
static |
Indicates if a file path is valid.
Checks if the file name is valid. Thus checks that it does not contain any of the following characters:
bool Qtilities::Core::QtilitiesFileInfo::operator!= | ( | const QtilitiesFileInfo & | ref | ) | const |
Operator overload to compare two QtilitiesFileInfo objects are not equal.
This function was added in Qtilities v1.2.
bool Qtilities::Core::QtilitiesFileInfo::operator== | ( | const QtilitiesFileInfo & | ref | ) | const |
Operator overload to compare two QtilitiesFileInfo objects with each other.
This function was added in Qtilities v1.2.
QString Qtilities::Core::QtilitiesFileInfo::relativeToPath | ( | ) | const |
Gets the relative to path of the file.
|
virtual |
Sets the the file name part of the file.
void Qtilities::Core::QtilitiesFileInfo::setRelativeToPath | ( | const QString & | relative_to_path | ) |
Gets the relative to path of the file.
bool Qtilities::Core::QtilitiesFileInfo::updateRelativeToPath | ( | const QString & | old_relative_to_path, |
const QString & | new_relative_to_path | ||
) |
Replaces the relative to path if it matches the old relative to path.
updateRelateiveToPath
old_relative_to_path | The old relative to path that must be matched in order for the update operation to happen. |
new_relative_to_path | The replacement relative to path. |
This function was added in Qtilities v1.2.
Qtilities : Reference Documentation | Back to top |
Copyright © 2009-2013, Jaco Naudé
|