📄 qdir.3qt
字号:
.PPSee also entryInfoList(), setNameFilter(), setSorting() and setFilter()..SH "QStringList QDir::entryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns a list of the names of all files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter()..PPThe filter and sorting specifications can be overridden using the \fIfilterSpec\fR and \fIsortSpec\fR arguments..PPReturns an empty list if the directory is unreadable or does not exist..PPSee also entryInfoList(), setNameFilter(), setSorting() and setFilter()..SH "bool QDir::exists ( const QString & name, bool acceptAbsPath = TRUE )\fC [virtual]\fR"Checks for existence of the file \fIname\fR..PPIf \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..PPReturns TRUE if the file exists; otherwise returns FALSE..PPSee also QFileInfo::exists() and QFile::exists()..SH "bool QDir::exists () const\fC [virtual]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns TRUE if the \fIdirectory\fR exists. (If a file with the same name is found this function will return FALSE)..PPSee also QFileInfo::exists() and QFile::exists()..SH "QString QDir::filePath ( const QString & fileName, bool acceptAbsPath = TRUE ) const\fC [virtual]\fR"Returns the path name of a file in the directory. Does \fInot\fR check if the file actually exists in the directory. If the QDir 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())..PPIf \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..PPSee also absFilePath(), isRelative() and canonicalPath()..SH "FilterSpec QDir::filter () const"Returns the value set by setFilter().SH "QDir QDir::home ()\fC [static]\fR"Returns the home directory..PPUnder Windows NT/2000 the function forms the path by concatenating the \fCHOMEDRIVE\fR and \fCHOMEPATH\fR environment variables..PPUnder Windows 9x and non-Windows operating systems the \fCHOME\fR environment variable is used..PPIf the environment variables aren't set, rootDirPath() is used instead..PPSee also homeDirPath()..SH "QString QDir::homeDirPath ()\fC [static]\fR"Returns the absolute path of the user's home directory,.PPSee also home()..SH "bool QDir::isReadable () const\fC [virtual]\fR"Returns TRUE if the directory is readable AND we can open files by name. This function will return FALSE if only one of these is present. \fBWarning:\fR A FALSE value from this function is not a guarantee that files in the directory are not accessible..PPSee also QFileInfo::isReadable()..PPExamples:.)l dirview/dirview.cpp and fileiconview/qfileiconview.cpp..SH "bool QDir::isRelative () const\fC [virtual]\fR"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 "/")..PPSee also convertToAbs()..SH "bool QDir::isRelativePath ( const QString & path )\fC [static]\fR"Returns TRUE if \fIpath\fR is relative; returns FALSE if it is absolute..PPSee also isRelative()..SH "bool QDir::isRoot () const\fC [virtual]\fR"Returns TRUE if the directory is the root directory, otherwise FALSE..PPNote: If the directory is a symbolic link to the root directory this function returns FALSE. If you want to test for this you can use canonicalPath():.PPExample:.PP.nf.br QDir d( "/tmp/root_link" );.br d = d.canonicalPath();.br if ( d.isRoot() ).br qWarning( "It IS a root link!" );.br.fi.PPSee also root() and rootDirPath()..SH "bool QDir::match ( const QString & filter, const QString & fileName )\fC [static]\fR"Returns TRUE if the \fIfileName\fR matches the wildcard (glob) pattern \fIfilter\fR. The \fIfilter\fR may also contain multiple patterns separated by spaces or semicolons..PP(See QRegExp wildcard matching.).PPSee also QRegExp::match()..SH "bool QDir::match ( const QStringList & filters, const QString & fileName )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns TRUE if the \fIfileName\fR matches any the wildcard (glob) patterns in the list of \fIfilters\fR..PP(See QRegExp wildcard matching.).PPSee also QRegExp::match()..SH "bool QDir::matchAllDirs () const"Returns the value set by setMatchAllDirs().PPSee also setMatchAllDirs()..SH "bool QDir::mkdir ( const QString & dirName, bool acceptAbsPath = TRUE ) const\fC [virtual]\fR"Creates a directory..PPIf \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..PPReturns TRUE if successful, otherwise FALSE..PPSee also rmdir()..SH "QString QDir::nameFilter () const"Returns the string set by setNameFilter().SH "bool QDir::operator!= ( const QDir & d ) const\fC [virtual]\fR"Returns TRUE if directory \fId\fR and this directory have different paths or different sort or filter settings; otherwise returns FALSE..PPExample:.PP.nf.br // The current directory is "/usr/local".br QDir d1( "/usr/local/bin" );.br QDir d2( "bin" );.br if ( d1 != d2 ) qDebug( "They differ\\n" ); // This is printed.br.fi.SH "QDir & QDir::operator= ( const QDir & d )"Makes a copy of QDir \fId\fR and assigns it to this QDir..SH "QDir & QDir::operator= ( const QString & path )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the directory path to be the given \fIpath\fR..SH "bool QDir::operator== ( const QDir & d ) const\fC [virtual]\fR"Returns TRUE if directory \fId\fR and this directory have the same path and their sort and filter settings are the same; otherwise returns FALSE..PPExample:.PP.nf.br // The current directory is "/usr/local".br QDir d1( "/usr/local/bin" );.br QDir d2( "bin" );.br d2.convertToAbs();.br if ( d1 == d2 ) qDebug( "They're the same\\n" ); // This is printed.br.fi.SH "QString QDir::operator[] ( int index ) const"Returns the file name at position \fIindex\fR in the list of file names. Equivalent to entryList().at(index)..PPReturns a null string if the \fIindex\fR is out of range or if the entryList() function failed..PPSee also count() and entryList()..SH "QString QDir::path () const\fC [virtual]\fR"Returns the path, this may contain symbolic links, but never contains redundant ".", ".." or multiple separators..PPThe returned path can be either absolute or relative (see setPath())..PPSee also setPath(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath() and convertSeparators()..SH "bool QDir::remove ( const QString & fileName, bool acceptAbsPath = TRUE )\fC [virtual]\fR"Removes a file..PPIf \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..PPReturns TRUE if the file is removed successfully; otherwise returns FALSE..SH "bool QDir::rename ( const QString & oldName, const QString & newName, bool acceptAbsPaths = TRUE )\fC [virtual]\fR"Renames a file or directory..PPIf \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..PPReturns TRUE if successful; otherwise returns FALSE..PPOn 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 newName points to an open file..PPExample: fileiconview/qfileiconview.cpp..SH "bool QDir::rmdir ( const QString & dirName, bool acceptAbsPath = TRUE ) const\fC [virtual]\fR"Removes a directory..PPIf \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..PPThe directory must be empty for rmdir() to succeed..PPReturns TRUE if successful, otherwise FALSE..PPSee also mkdir()..SH "QDir QDir::root ()\fC [static]\fR"Returns the root directory..PPSee also rootDirPath() and drives()..SH "QString QDir::rootDirPath ()\fC [static]\fR"Returns the absolute path for the root directory..PPFor UNIX operating systems this returns "/". For Windows file systems this returns "c:/"..PPSee also root() and drives()..SH "char QDir::separator ()\fC [static]\fR"Returns the native directory separator; "/" under UNIX and "\" under MS-DOS, Windows NT and OS/2..PPYou 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..SH "bool QDir::setCurrent ( const QString & path )\fC [static]\fR"Sets the application's current working directory to \fIpath\fR. Returns TRUE if the directory was successfully changed; otherwise returns FALSE..SH "void QDir::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 QDir::FilterSpec..PPSee also filter() and setNameFilter()..SH "void QDir::setMatchAllDirs ( bool enable )\fC [virtual]\fR"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..PPSee also matchAllDirs()..SH "void QDir::setNameFilter ( const QString & nameFilter )\fC [virtual]\fR"Sets the name filter used by entryList() and entryInfoList() to \fInameFilter\fR..PPThe \fInameFilter\fR is a wildcard (globbing) filter that understands "*" and "?" wildcards. (See QRegExp wildcard matching.) You may specify several filter entries all separated by a single space " " or by a semi-colon ";"..PPFor example, if you want entryList() and entryInfoList() to list all files ending with ".cpp" and all files ending with ".h", you would use either dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h")..PPSee also nameFilter() and setFilter()..SH "void QDir::setPath ( const QString & path )\fC [virtual]\fR"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..PPThe path can be either absolute or relative. Absolute paths begin with the directory separator "/" or a drive specification (except under Unix). 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"..PPSee also path(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath(), isRelative() and convertToAbs()..SH "void QDir::setSorting ( int sortSpec )\fC [virtual]\fR"Sets the sort order used by entryList() and entryInfoList()..PPThe \fIsortSpec\fR is specified by OR-ing values from the enum QDir::SortSpec..PPSee also sorting() and SortSpec..SH "SortSpec QDir::sorting () const"Returns the value set by setSorting().PPSee also setSorting() and SortSpec..SH "SEE ALSO".BR http://doc.trolltech.com/qdir.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qdir.3qt) and the Qtversion (3.0.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -