A TQDir 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). If you always use "/" as a directory separator, TQt will translate your paths to conform to the underlying operating system. 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". You can use the function isRelative() to check if a TQDir is using a relative or an absolute file path. Call convertToAbs() to convert a relative TQDir to an absolute one. For a simplified path use cleanDirPath(). To obtain a path which has no symbolic links or redundant ".." elements use canonicalPath(). The path can be set with setPath(), and changed with cd() and cdUp().
TQDir provides several static functions, for example, setCurrent() to set the application's working directory and currentDirPath() to retrieve the application's working directory. Access to some common paths is provided with the static functions, current(), home() and root() which return TQDir objects or currentDirPath(), homeDirPath() and rootDirPath() which return the path as a string. If you want to know about your application's path use QApplication::applicationDirPath().
The number of entries in a directory is returned by count(). Obtain a string list of the names of all the files and directories in a directory with entryList(). If you prefer a list of TQFileInfo pointers use entryInfoList(). Both these functions can apply a name filter, an attributes filter (e.g. read-only, files not directories, etc.), and a sort order. The filters and sort may be set with calls to setNameFilter(), setFilter() and setSorting(). They may also be specified in the entryList() and entryInfoList()'s arguments.
Create a new directory with mkdir(), rename a directory with rename() and remove an existing directory with rmdir(). Remove a file with remove(). You can interrogate a directory with exists(), isReadable() and isRoot().
.PP
To get a path with a filename use filePath(), and to get a directory name use dirName(); neither of these functions checks for the existence of the file or directory.
.PP
The list of root directories is provided by drives(); on Unix systems this returns a list containing one root directory, "/"; on Windows the list will usually contain "C:/", and possibly "D:/", etc.
It is easiest to work with "/" separators in TQt code. If you need to present a path to the user or need a path in a form suitable for a function in the underlying operating system use convertSeparators().
This enum describes the filtering options available to TQDir, e.g. for entryList() and entryInfoList(). The filter value is specified by OR-ing together values from the following list:
If you do not set any of Readable, Writable or Executable, TQDir will set all three of them. This makes the default easy to write and at the same time useful.
.)l \fCReadable|Writable\fR means list all files for which the
application has read access, write access or both. \fCDirs|Drives\fR means list drives, directories, all files that the application can read, write or execute, and also symlinks to such files/directories.
This enum describes the sort options available to TQDir, e.g. for entryList() and entryInfoList(). The sort value is specified by OR-ing together values from the following list:
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.
.SH "TQDir::TQDir ( const TQString & path, const TQString & nameFilter = TQString::null, int sortSpec = Name | IgnoreCase, int filterSpec = All )"
Constructs a TQDir with path \fIpath\fR, that filters its entries by name using \fInameFilter\fR and by attributes using \fIfilterSpec\fR. It also sorts the names using \fIsortSpec\fR.
The default \fInameFilter\fR is an empty string, which excludes nothing; the default \fIfilterSpec\fR is All, which also means exclude nothing. The default \fIsortSpec\fR is \fCName|IgnoreCase\fR, i.e. sort by name case-insensitively.
If \fIpath\fR is "" or TQString::null, TQDir uses "." (the current directory). If \fInameFilter\fR is "" or TQString::null, TQDir uses the name filter "*" (all files).
Returns the absolute path name of a file in the directory. Does \fInot\fR check if the file actually exists in the directory. Redundant multiple separators or "." and ".." directories in \fIfileName\fR will not be removed (see cleanDirPath()).
.PP
If \fIacceptAbsPath\fR is TRUE a \fIfileName\fR starting with a separator "/" will be returned without change. If \fIacceptAbsPath\fR is FALSE an absolute path will be prepended to the fileName and the resultant string returned.
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.
.PP
See also setPath(), canonicalPath(), exists(), cleanDirPath(), dirName(), and absFilePath().
On systems that do not have symbolic links this function will always return the same string that absPath() returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath() returns TQString::null.
If \fIacceptAbsPath\fR is TRUE a path starting with separator "/" will cause the function to change to the absolute directory. If \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed and the function will descend into \fIdirName\fR.
.PP
Returns TRUE if the new directory exists and is readable; otherwise returns FALSE. Note that the logical cd() operation is not performed if the new directory does not exist.
.PP
Calling cd( ".." ) is equivalent to calling cdUp().
.PP
See also cdUp(), isReadable(), exists(), and path().
Returns TRUE if the new directory exists and is readable; otherwise returns FALSE. Note that the logical cdUp() operation is not performed if the new directory does not exist.
.PP
See also cd(), isReadable(), exists(), and path().
Removes all multiple directory separators "/" and resolves any"
."s or ".."s found in the path, \fIfilePath\fR.
.PP
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".
Returns the name of the directory; this is \fInot\fR 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) TQString::null is returned.
Returns a list of the root directories on this system. On Windows this returns a number of TQFileInfo objects containing "C:/", "D:/" etc. On other operating systems, it returns a list containing just one root directory (e.g. "/").
This function is included to easy porting from TQt 1.x to TQt 2.0, it is the same as entryList(), but encodes the filenames as 8-bit strings using TQFile::encodedName().
This function is included to easy porting from TQt 1.x to TQt 2.0, it is the same as entryList(), but encodes the filenames as 8-bit strings using TQFile::encodedName().
Returns a list of TQFileInfo objects for all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().
The returned pointer is a const pointer to a TQFileInfoList. The list is owned by the TQDir object and will be reused on the next call to entryInfoList() for the same TQDir instance. If you want to keep the entries of the list after a subsequent call to this function you must copy them.
Returns a list of TQFileInfo objects for all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().
The returned pointer is a const pointer to a TQFileInfoList. The list is owned by the TQDir object and will be reused on the next call to entryInfoList() for the same TQDir instance. If you want to keep the entries of the list after a subsequent call to this function you must copy them.
Returns a list of the names of all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().
.PP
The filter and sorting specifications can be overridden using the \fInameFilter\fR, \fIfilterSpec\fR and \fIsortSpec\fR arguments.
.PP
Returns an empty list if the directory is unreadable or does not exist.
.PP
See also entryInfoList(), setNameFilter(), setSorting(), and setFilter().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns a list of the names of all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().
.PP
The filter and sorting specifications can be overridden using the \fIfilterSpec\fR and \fIsortSpec\fR arguments.
.PP
Returns an empty list if the directory is unreadable or does not exist.
.PP
See also entryInfoList(), setNameFilter(), setSorting(), and setFilter().
If \fIacceptAbsPath\fR is TRUE a path starting with separator "/" will check the file with the absolute path. If \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIname\fR will be removed and the resultant file name will be checked.
.PP
Returns TRUE if the file exists; otherwise returns FALSE.
Returns the path name of a file in the directory. Does \fInot\fR check if the file actually exists in the directory. If the TQDir is relative the returned path name will also be relative. Redundant multiple separators or "." and ".." directories in \fIfileName\fR will not be removed (see cleanDirPath()).
If \fIacceptAbsPath\fR is TRUE a \fIfileName\fR starting with a separator "/" will be returned without change. If \fIacceptAbsPath\fR is FALSE an absolute path will be prepended to the fileName and the resultant string returned.
.PP
See also absFilePath(), isRelative(), and canonicalPath().
Under Windows the \fCHOME\fR environment variable is used. If this does not exist the \fCUSERPROFILE\fR environment variable is used. If that does not exist the path is formed by concatenating the \fCHOMEDRIVE\fR and \fCHOMEPATH\fR environment variables. If they don't exist the rootDirPath() is used (this uses the \fCSystemDrive\fR environment variable). If none of these exist "C:\" is used.
.PP
Under non-Windows operating systems the \fCHOME\fR environment variable is used if it exists, otherwise rootDirPath() is used.
Returns TRUE if the directory path is relative to the current directory and returns FALSE if the path is absolute (e.g. under UNIX a path is relative if it does not start with a "/").
Returns TRUE if the \fIfileName\fR matches the wildcard (glob) pattern \fIfilter\fR; otherwise returns FALSE. The \fIfilter\fR may contain multiple patterns separated by spaces or semicolons.
If \fIacceptAbsPath\fR is TRUE a path starting with a separator ('/') will create the absolute directory; if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed.
.PP
Returns TRUE if successful; otherwise returns FALSE.
If \fIacceptAbsPath\fR is TRUE a path starting with separator "/" will remove the file with the absolute path. If \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIfileName\fR will be removed and the resultant file name will be removed.
.PP
Returns TRUE if the file is removed successfully; otherwise returns FALSE.
If \fIacceptAbsPaths\fR is TRUE a path starting with a separator ('/') will rename the file with the absolute path; if \fIacceptAbsPaths\fR is FALSE any number of separators at the beginning of the names will be removed.
.PP
Returns TRUE if successful; otherwise returns FALSE.
.PP
On most file systems, rename() fails only if \fIoldName\fR does not exist or if \fInewName\fR and \fIoldName\fR are not on the same partition. On Windows, rename() will fail if \fInewName\fR already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if \fInewName\fR points to an open file.
If \fIacceptAbsPath\fR is TRUE a path starting with a separator ('/') will remove the absolute directory; if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed.
.PP
The directory must be empty for rmdir() to succeed.
.PP
Returns TRUE if successful; otherwise returns FALSE.
You do not need to use this function to build file paths. If you always use "/", TQt will translate your paths to conform to the underlying operating system.
.SH "void TQDir::setFilter ( int filterSpec )\fC [virtual]\fR"
Sets the filter used by entryList() and entryInfoList() to \fIfilterSpec\fR. The filter is used to specify the kind of files that should be returned by entryList() and entryInfoList(). See TQDir::FilterSpec.
If \fIenable\fR is TRUE then all directories are included (e.g. in entryList()), and the nameFilter() is only applied to the files. If \fIenable\fR is FALSE then the nameFilter() is applied to both directories and files.
The \fInameFilter\fR is a wildcard (globbing) filter that understands" *" and "?" wildcards. (See TQRegExp wildcard matching.) You may specify several filter entries all separated by a single space " " or by a semi-colon" ;".
For example, if you want entryList() and entryInfoList() to list all files ending with either ".cpp" or ".h", you would use either dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h").
Sets the path of the directory to \fIpath\fR. The path is cleaned of redundant ".", ".." and of multiple separators. No check is made to ensure that a directory with this path exists.
.PP
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".
.PP
See also path(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath(), isRelative(), and convertToAbs().