Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qdir.h>
Public Types | |
enum | Filter { Dirs = 0x001 , Files = 0x002 , Drives = 0x004 , NoSymLinks = 0x008 , AllEntries = Dirs | Files | Drives , TypeMask = 0x00f , Readable = 0x010 , Writable = 0x020 , Executable = 0x040 , PermissionMask = 0x070 , Modified = 0x080 , Hidden = 0x100 , System = 0x200 , AccessMask = 0x3F0 , AllDirs = 0x400 , CaseSensitive = 0x800 , NoDot = 0x2000 , NoDotDot = 0x4000 , NoDotAndDotDot = NoDot | NoDotDot , NoFilter = -1 } |
This enum describes the filtering options available to QDir; e.g. More... | |
enum | SortFlag { Name = 0x00 , Time = 0x01 , Size = 0x02 , Unsorted = 0x03 , SortByMask = 0x03 , DirsFirst = 0x04 , Reversed = 0x08 , IgnoreCase = 0x10 , DirsLast = 0x20 , LocaleAware = 0x40 , Type = 0x80 , NoSort = -1 } |
This enum describes the sort options available to QDir, e.g. More... | |
Public Member Functions | |
QDir (const QDir &) | |
Constructs a QDir object that is a copy of the QDir object for directory dir. | |
QDir (const QString &path=QString()) | |
Constructs a QDir pointing to the given directory path. | |
QDir (const QString &path, const QString &nameFilter, SortFlags sort=SortFlags(Name|IgnoreCase), Filters filter=AllEntries) | |
Constructs a QDir with path path, that filters its entries by name using nameFilter and by attributes using filters. | |
~QDir () | |
Destroys the QDir object frees up its resources. | |
QDir & | operator= (const QDir &) |
Move-assigns other to this QDir instance. | |
void | swap (QDir &other) noexcept |
void | setPath (const QString &path) |
Sets the path of the directory to path. | |
QString | path () const |
Returns the path. | |
QString | absolutePath () const |
Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators. | |
QString | canonicalPath () const |
Returns the canonical path, i.e. | |
QString | dirName () const |
Returns the name of the directory; this is not the same as the path, e.g. | |
QString | filePath (const QString &fileName) const |
Returns the path name of a file in the directory. | |
QString | absoluteFilePath (const QString &fileName) const |
Returns the absolute path name of a file in the directory. | |
QString | relativeFilePath (const QString &fileName) const |
Returns the path to fileName relative to the directory. | |
bool | cd (const QString &dirName) |
Changes the QDir's directory to dirName. | |
bool | cdUp () |
Changes directory by moving one directory up from the QDir's current directory. | |
QStringList | nameFilters () const |
Returns the string list set by setNameFilters() | |
void | setNameFilters (const QStringList &nameFilters) |
Sets the name filters used by entryList() and entryInfoList() to the list of filters specified by nameFilters. | |
Filters | filter () const |
Returns the value set by setFilter() | |
void | setFilter (Filters filter) |
Sets the filter used by entryList() and entryInfoList() to filters. | |
SortFlags | sorting () const |
Returns the value set by setSorting() | |
void | setSorting (SortFlags sort) |
Sets the sort order used by entryList() and entryInfoList(). | |
qsizetype | count (QT6_DECL_NEW_OVERLOAD) const |
Returns the total number of directories and files in the directory. | |
bool | isEmpty (Filters filters=Filters(AllEntries|NoDotAndDotDot)) const |
Returns whether the directory is empty. | |
QString | operator[] (qsizetype) const |
Returns the file name at position pos in the list of file names. | |
QStringList | entryList (Filters filters=NoFilter, SortFlags sort=NoSort) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a list of the names of all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting(). | |
QStringList | entryList (const QStringList &nameFilters, Filters filters=NoFilter, SortFlags sort=NoSort) const |
Returns a list of the names of all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting(). | |
QFileInfoList | entryInfoList (Filters filters=NoFilter, SortFlags sort=NoSort) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a list of QFileInfo objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting(). | |
QFileInfoList | entryInfoList (const QStringList &nameFilters, Filters filters=NoFilter, SortFlags sort=NoSort) const |
Returns a list of QFileInfo objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting(). | |
bool | mkdir (const QString &dirName) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Creates a sub-directory called dirName with default permissions. | |
bool | mkdir (const QString &dirName, QFile::Permissions permissions) const |
Creates a sub-directory called dirName. | |
bool | rmdir (const QString &dirName) const |
Removes the directory specified by dirName. | |
bool | mkpath (const QString &dirPath) const |
Creates the directory path dirPath. | |
bool | rmpath (const QString &dirPath) const |
Removes the directory path dirPath. | |
bool | removeRecursively () |
bool | isReadable () const |
Returns true if the directory is readable and we can open files by name; otherwise returns false . | |
bool | exists () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the directory exists; otherwise returns false . | |
bool | isRoot () const |
Returns true if the directory is the root directory; otherwise returns false . | |
bool | isRelative () const |
Returns true if the directory path is relative; otherwise returns false. | |
bool | isAbsolute () const |
Returns true if the directory's path is absolute; otherwise returns false . | |
bool | makeAbsolute () |
Converts the directory path to an absolute path. | |
bool | remove (const QString &fileName) |
Removes the file, fileName. | |
bool | rename (const QString &oldName, const QString &newName) |
Renames a file or directory from oldName to newName, and returns true if successful; otherwise returns false . | |
bool | exists (const QString &name) const |
Returns true if the file called name exists; otherwise returns false. | |
void | refresh () const |
Refreshes the directory information. | |
Static Public Member Functions | |
static void | setSearchPaths (const QString &prefix, const QStringList &searchPaths) |
static void | addSearchPath (const QString &prefix, const QString &path) |
static QStringList | searchPaths (const QString &prefix) |
static QString | toNativeSeparators (const QString &pathName) |
static QString | fromNativeSeparators (const QString &pathName) |
static QStringList | nameFiltersFromString (const QString &nameFilter) |
static bool | isRelativePath (const QString &path) |
Returns true if path is relative; returns false if it is absolute. | |
static bool | isAbsolutePath (const QString &path) |
Returns true if path is absolute; returns false if it is relative. | |
static QFileInfoList | drives () |
Returns a list of the root directories on this system. | |
static constexpr QChar | listSeparator () noexcept |
static QChar | separator () |
Returns the native directory separator: "/" under Unix and "\\" under Windows. | |
static bool | setCurrent (const QString &path) |
Sets the application's current working directory to path. | |
static QDir | current () |
Returns the application's current directory. | |
static QString | currentPath () |
Returns the absolute path of the application's current directory. | |
static QDir | home () |
Returns the user's home directory. | |
static QString | homePath () |
Returns the absolute path of the user's home directory. | |
static QDir | root () |
Returns the root directory. | |
static QString | rootPath () |
Returns the absolute path of the root directory. | |
static QDir | temp () |
Returns the system's temporary directory. | |
static QString | tempPath () |
Returns the absolute canonical path of the system's temporary directory. | |
static QString | cleanPath (const QString &path) |
Returns path with directory separators normalized (that is, platform-native separators converted to "/") and redundant ones removed, and "."s and ".."s resolved (as far as possible). | |
Protected Member Functions | |
QDir (QDirPrivate &d) | |
Protected Attributes | |
QSharedDataPointer< QDirPrivate > | d_ptr |
Friends | |
class | QDirIterator |
class | QDirListing |
class | QDirListingPrivate |
Q_CORE_EXPORT bool | comparesEqual (const QDir &lhs, const QDir &rhs) |
\inmodule QtCore
The QDir class provides access to directory structures and their contents.
\reentrant
\compares equality
A QDir is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system. It can also be used to access Qt's \l{resource system}.
Qt uses "/" as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, Qt will translate your paths to conform to the underlying operating system.
A QDir can point to a file using either a relative or an absolute path. Absolute paths begin with the directory separator (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory.
Examples of absolute paths:
On Windows, the second example above will be translated to {C:\Users} when used to access files.
Examples of relative paths:
You can use the isRelative() or isAbsolute() functions to check if a QDir is using a relative or an absolute file path. Call makeAbsolute() to convert a relative QDir to an absolute one.
enum QDir::Filter |
This enum describes the filtering options available to QDir; e.g.
for entryList() and entryInfoList(). The filter value is specified by combining values from the following list using the bitwise OR operator:
\value Dirs List directories that match the filters. \value AllDirs List all directories; i.e. don't apply the filters to directory names. \value Files List files. \value Drives List disk drives (ignored under Unix). \value NoSymLinks Do not list symbolic links (ignored by operating systems that don't support symbolic links). \value NoDotAndDotDot Do not list the special entries "." and "..". \value NoDot Do not list the special entry ".". \value NoDotDot Do not list the special entry "..". \value AllEntries List directories, files, drives and symlinks (this does not list broken symlinks unless you specify System). \value Readable List files for which the application has read access. The Readable value needs to be combined with Dirs or Files. \value Writable List files for which the application has write access. The Writable value needs to be combined with Dirs or Files. \value Executable List files for which the application has execute access. The Executable value needs to be combined with Dirs or Files. \value Modified Only list files that have been modified (ignored on Unix). \value Hidden List hidden files (on Unix, files starting with a "."). \value System List system files (on Unix, FIFOs, sockets and device files are included; on Windows, {
.lnk} files are included) \value CaseSensitive The filter should be case sensitive.
\omitvalue TypeMask \omitvalue AccessMask \omitvalue PermissionMask \omitvalue NoFilter
Functions that use Filter enum values to filter lists of files and directories will include symbolic links to files and directories unless you set the NoSymLinks value.
A default constructed QDir will not filter out files based on their permissions, so entryList() and entryInfoList() will return all files that are readable, writable, executable, or any combination of the three. This makes the default easy to write, and at the same time useful.
For example, setting the Readable
, Writable
, and Files
flags allows all files to be listed for which the application has read access, write access or both. If the Dirs
and Drives
flags are also included in this combination then all drives, directories, all files that the application can read, write, or execute, and symlinks to such files/directories can be listed.
To retrieve the permissions for a directory, use the entryInfoList() function to get the associated QFileInfo objects and then use the QFileInfo::permissions() to obtain the permissions and ownership for each file.
Enumerator | |
---|---|
Dirs | |
Files | |
Drives | |
NoSymLinks | |
AllEntries | |
TypeMask | |
Readable | |
Writable | |
Executable | |
PermissionMask | |
Modified | |
Hidden | |
System | |
AccessMask | |
AllDirs | |
CaseSensitive | |
NoDot | |
NoDotDot | |
NoDotAndDotDot | |
NoFilter |
enum QDir::SortFlag |
This enum describes the sort options available to QDir, e.g.
for entryList() and entryInfoList(). The sort value is specified by OR-ing together values from the following list:
\value Name Sort by name. \value Time Sort by time (modification time). \value Size Sort by file size. \value Type Sort by file type (extension). \value Unsorted Do not sort. \value NoSort Not sorted by default.
\value DirsFirst Put the directories first, then the files. \value DirsLast Put the files first, then the directories. \value Reversed Reverse the sort order. \value IgnoreCase Sort case-insensitively. \value LocaleAware Sort items appropriately using the current locale settings.
\omitvalue SortByMask
You can only specify one of the first four.
If you specify both DirsFirst and Reversed, directories are still put first, but in reverse order; the files will be listed after the directories, again in reverse order.
Enumerator | |
---|---|
Name | |
Time | |
Size | |
Unsorted | |
SortByMask | |
DirsFirst | |
Reversed | |
IgnoreCase | |
DirsLast | |
LocaleAware | |
Type | |
NoSort |
QDir::QDir | ( | const QDir & | dir | ) |
Constructs a QDir object that is a copy of the QDir object for directory dir.
Constructs a QDir pointing to the given directory path.
If path is empty the program's working directory, ("."), is used.
QDir::QDir | ( | const QString & | path, |
const QString & | nameFilter, | ||
SortFlags | sort = SortFlags(Name | IgnoreCase), | ||
Filters | filters = AllEntries ) |
Constructs a QDir with path path, that filters its entries by name using nameFilter and by attributes using filters.
It also sorts the names using sort.
The default nameFilter is an empty string, which excludes nothing; the default filters is \l AllEntries, which also excludes nothing. The default sort is \l Name | \l IgnoreCase, i.e. sort by name case-insensitively.
If path is an empty string, QDir uses "." (the current directory). If nameFilter is an empty string, QDir uses the name filter "*" (all files).
QDir::~QDir | ( | ) |
|
explicitprotected |
Returns the absolute path name of a file in the directory.
Does not check if the file actually exists in the directory; but see exists(). Redundant multiple separators or "." and ".." directories in fileName are not removed (see cleanPath()).
QString QDir::absolutePath | ( | ) | const |
Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators.
Adds path to the search path for prefix.
QString QDir::canonicalPath | ( | ) | const |
Returns the canonical path, i.e.
a path without symbolic links or redundant "." or ".." elements.
On systems that do not have symbolic links this function will always return the same string that absolutePath() returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath() returns an empty string.
Example:
bool QDir::cd | ( | const QString & | dirName | ) |
bool QDir::cdUp | ( | ) |
Changes directory by moving one directory up from the QDir's current directory.
Returns true
if the new directory exists; otherwise returns false
. Note that the logical cdUp() operation is not performed if the new directory does not exist.
Returns path with directory separators normalized (that is, platform-native separators converted to "/") and redundant ones removed, and "."s and ".."s resolved (as far as possible).
Symbolic links are kept. This function does not return the canonical path, but rather the simplest version of the input. For example, "./local" becomes "local", "local/../bin" becomes "bin" and "/local/usr/../bin" becomes "/local/bin".
qsizetype QDir::count | ( | QT6_DECL_NEW_OVERLOAD | ) | const |
Returns the total number of directories and files in the directory.
Equivalent to entryList().count().
{uint}, not
{qsizetype}.
|
inlinestatic |
Returns the application's current directory.
The directory is constructed using the absolute path of the current directory, ensuring that its path() will be the same as its absolutePath().
|
static |
Returns the absolute path of the application's current directory.
The current directory is the last directory set with QDir::setCurrent() or, if that was never called, the directory at which this application was started at by the parent process.
QString QDir::dirName | ( | ) | const |
Returns the name of the directory; this is not the same as the path, e.g.
a directory with the name "mail", might have the path "/var/spool/mail". If the directory has no name (e.g. it is the root directory) an empty string is returned.
No check is made to ensure that a directory with this name actually exists; but see exists().
|
static |
Returns a list of the root directories on this system.
On Windows this returns a list of QFileInfo objects containing "C:/", "D:/", etc. This does not return drives with ejectable media that are empty. On other operating systems, it returns a list containing just one root directory (i.e. "/").
QFileInfoList QDir::entryInfoList | ( | const QStringList & | nameFilters, |
Filters | filters = NoFilter, | ||
SortFlags | sort = NoSort ) const |
Returns a list of QFileInfo objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting().
The name filter, file attribute filter, and sorting specification can be overridden using the nameFilters, filters, and sort arguments.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
QFileInfoList QDir::entryInfoList | ( | Filters | filters = NoFilter, |
SortFlags | sort = NoSort ) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a list of QFileInfo objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting().
The attribute filter and sorting specifications can be overridden using the filters and sort arguments.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
QStringList QDir::entryList | ( | const QStringList & | nameFilters, |
Filters | filters = NoFilter, | ||
SortFlags | sort = NoSort ) const |
Returns a list of the names of all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting().
The name filter, file attribute filter, and sorting specification can be overridden using the nameFilters, filters, and sort arguments.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
QStringList QDir::entryList | ( | Filters | filters = NoFilter, |
SortFlags | sort = NoSort ) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a list of the names of all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting().
The attribute filter and sorting specifications can be overridden using the filters and sort arguments.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
bool QDir::exists | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true
if the directory exists; otherwise returns false
.
(If a file with the same name is found this function will return false).
The overload of this function that accepts an argument is used to test for the presence of files and directories within a directory.
bool QDir::exists | ( | const QString & | name | ) | const |
Returns true
if the file called name exists; otherwise returns false.
Unless name contains an absolute file path, the file name is assumed to be relative to the directory itself, so this function is typically used to check for the presence of files within a directory.
Returns the path name of a file in the directory.
Does not check if the file actually exists in the directory; but see exists(). If the QDir is relative the returned path name will also be relative. Redundant multiple separators or "." and ".." directories in fileName are not removed (see cleanPath()).
QDir::Filters QDir::filter | ( | ) | const |
Returns the value set by setFilter()
Returns pathName using '/' as file separator. On Windows, for instance, fromNativeSeparators("\c{c:\\winnt\\system32}") returns "c:/winnt/system32".
The returned string may be the same as the argument on some operating systems, for example on Unix.
|
inlinestatic |
Returns the user's home directory.
The directory is constructed using the absolute path of the home directory, ensuring that its path() will be the same as its absolutePath().
See homePath() for details.
|
static |
Returns the absolute path of the user's home directory.
Under Windows this function will return the directory of the current user's profile. Typically, this is:
Use the toNativeSeparators() function to convert the separators to the ones that are appropriate for the underlying operating system.
If the directory of the current user's profile does not exist or cannot be retrieved, the following alternatives will be checked (in the given order) until an existing and available path is found:
\list 1
USERPROFILE
environment variable. HOMEDRIVE
and HOMEPATH
environment variables. HOME
environment variable. SystemDrive
environment variable)
{C:/} directory. \endlistUnder non-Windows operating systems the HOME
environment variable is used if it exists, otherwise the path returned by the rootPath().
|
inline |
Returns true
if the directory's path is absolute; otherwise returns false
.
See isAbsolutePath().
|
inlinestatic |
Returns true
if path is absolute; returns false
if it is relative.
bool QDir::isEmpty | ( | Filters | filters = Filters(AllEntries | NoDotAndDotDot) | ) | const |
Returns whether the directory is empty.
Equivalent to {count() == 0} with filters
{QDir::AllEntries | QDir::NoDotAndDotDot}, but faster as it just checks whether the directory contains at least one entry.
{QDir::NoDotAndDotDot} (as the default value does), no directory is empty.bool QDir::isReadable | ( | ) | const |
Returns true
if the directory is readable and we can open files by name; otherwise returns false
.
bool QDir::isRelative | ( | ) | const |
Returns true
if the directory path is relative; otherwise returns false.
(Under Unix a path is relative if it does not start with a "/").
|
static |
Returns true
if path is relative; returns false
if it is absolute.
bool QDir::isRoot | ( | ) | const |
Returns true
if the directory is the root directory; otherwise returns false
.
false
. If you want to test for this use canonicalPath(), e.g.
|
inlinestaticconstexprnoexcept |
Returns the native path list separator: ':' under Unix and ';' under Windows.
bool QDir::makeAbsolute | ( | ) |
Converts the directory path to an absolute path.
If it is already absolute nothing happens. Returns true
if the conversion succeeded; otherwise returns false
.
bool QDir::mkdir | ( | const QString & | dirName | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Creates a sub-directory called dirName with default permissions.
On POSIX systems the default is to grant all permissions allowed by umask
. On Windows, the new directory inherits its permissions from its parent directory.
bool QDir::mkdir | ( | const QString & | dirName, |
QFile::Permissions | permissions ) const |
Creates a sub-directory called dirName.
Returns true
on success; otherwise returns false
.
If the directory already exists when this function is called, it will return false
.
The permissions of the created directory are set to {permissions}.
On POSIX systems the permissions are influenced by the value of umask
.
On Windows the permissions are emulated using ACLs. These ACLs may be in non-canonical order when the group is granted less permissions than others. Files and directories with such permissions will generate warnings when the Security tab of the Properties dialog is opened. Granting the group all permissions granted to others avoids such warnings.
bool QDir::mkpath | ( | const QString & | dirPath | ) | const |
Creates the directory path dirPath.
The function will create all parent directories necessary to create the directory.
Returns true
if successful; otherwise returns false
.
If the path already exists when this function is called, it will return true.
QStringList QDir::nameFilters | ( | ) | const |
Returns the string list set by setNameFilters()
|
static |
Returns the file name at position pos in the list of file names.
Equivalent to entryList().at(index). pos must be a valid index position in the list (i.e., 0 <= pos < count()).
{int}, not
{qsizetype}.QString QDir::path | ( | ) | const |
Returns the path.
This may contain symbolic links, but never contains redundant ".", ".." or multiple separators.
The returned path can be either absolute or relative (see setPath()).
void QDir::refresh | ( | ) | const |
Returns the path to fileName relative to the directory.
bool QDir::remove | ( | const QString & | fileName | ) |
bool QDir::removeRecursively | ( | ) |
Returns true
if successful, otherwise false.
If a file or directory cannot be removed, removeRecursively() keeps going and attempts to delete as many files and sub-directories as possible, then returns false
.
If the directory was already removed, the method returns true
(expected result already reached).
Renames a file or directory from oldName to newName, and returns true if successful; otherwise returns false
.
On most file systems, rename() fails only if oldName does not exist, or if a file with the new name already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if newName points to an open file.
If oldName is a file (not a directory) that can't be renamed right away, Qt will try to copy oldName to newName and remove oldName.
bool QDir::rmdir | ( | const QString & | dirName | ) | const |
bool QDir::rmpath | ( | const QString & | dirPath | ) | const |
|
inlinestatic |
Returns the root directory.
The directory is constructed using the absolute path of the root directory, ensuring that its path() will be the same as its absolutePath().
See rootPath() for details.
|
static |
Returns the absolute path of the root directory.
For Unix operating systems this returns "/". For Windows file systems this normally returns "c:/".
|
static |
|
inlinestatic |
Returns the native directory separator: "/" under Unix and "\\" under Windows.
You do not need to use this function to build file paths. If you always use "/", Qt will translate your paths to conform to the underlying operating system. If you want to display paths to the user using their operating system's separator use toNativeSeparators().
|
static |
Sets the application's current working directory to path.
Returns true
if the directory was successfully changed; otherwise returns false
.
void QDir::setFilter | ( | Filters | filters | ) |
Sets the filter used by entryList() and entryInfoList() to filters.
The filter is used to specify the kind of files that should be returned by entryList() and entryInfoList(). See \l{QDir::Filter}.
void QDir::setNameFilters | ( | const QStringList & | nameFilters | ) |
Sets the name filters used by entryList() and entryInfoList() to the list of filters specified by nameFilters.
Each name filter is a wildcard (globbing) filter that understands {*} and
{?} wildcards. See \l{QRegularExpression::fromWildcard()}.
For example, the following code sets three name filters on a QDir to ensure that only files with extensions typically used for C++ source files are listed:
Sets the path of the directory to path.
The path is cleaned of redundant ".", ".." and of multiple separators. No check is made to see whether a directory with this path actually exists; but you can check for yourself using exists().
The path can be either absolute or relative. Absolute paths begin with the directory separator "/" (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory. An example of an absolute path is the string "/tmp/quartz", a relative path might look like "src/fatlib".
|
static |
Sets or replaces Qt's search paths for file names with the prefix prefix to searchPaths.
To specify a prefix for a file name, prepend the prefix followed by a single colon (e.g., "images:undo.png", "xmldocs:books.xml"). prefix can only contain letters or numbers (e.g., it cannot contain a colon, nor a slash).
Qt uses this search path to locate files with a known prefix. The search path entries are tested in order, starting with the first entry.
File name prefix must be at least 2 characters long to avoid conflicts with Windows drive letters.
Search paths may contain paths to \l{The Qt Resource System}.
void QDir::setSorting | ( | SortFlags | sort | ) |
Sets the sort order used by entryList() and entryInfoList().
The sort is specified by OR-ing values from the enum \l{QDir::SortFlag}.
QDir::SortFlags QDir::sorting | ( | ) | const |
Returns the value set by setSorting()
|
inlinestatic |
Returns the system's temporary directory.
The directory is constructed using the absolute canonical path of the temporary directory, ensuring that its path() will be the same as its absolutePath().
See tempPath() for details.
|
static |
Returns the absolute canonical path of the system's temporary directory.
On Unix/Linux systems this is the path in the TMPDIR
environment variable or {/tmp} if
TMPDIR
is not defined. On Windows this is usually the path in the TEMP
or TMP
environment variable. The path returned by this method doesn't end with a directory separator unless it is the root directory (of a drive).
Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
On Windows, toNativeSeparators("c:/winnt/system32") returns "c:\\winnt\\system32".
The returned string may be the same as the argument on some operating systems, for example on Unix.
|
friend |
|
friend |
|
friend |
|
protected |