⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdir.cpp

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
      QFileInfo fi( d, "c++" );      if ( fi.exists() ) {	  if ( fi.isDir() )	      qWarning( "Cannot cd into \"%s\".", (char*)d.absFilePath("c++") );	  else	      qWarning( "Cannot create directory \"%s\"\n"		       "A file named \"c++\" already exists in \"%s\"",		       (const char *)d.absFilePath("c++"),		       (const char *)d.path() );	  return;      } else {	  qWarning( "Creating directory \"%s\"",		   (const char *) d.absFilePath("c++") );	  if ( !d.mkdir( "c++" ) ) {	      qWarning("Could not create directory \"%s\"",		      (const char *)d.absFilePath("c++") );	      return;	  }      }  }  \endcode  Calling cd( ".." ) is equivalent to calling cdUp().  \sa cdUp(), isReadable(), exists(), path()*/bool QDir::cd( const QString &dirName, bool acceptAbsPath ){    if ( dirName.isEmpty() || dirName==QString::fromLatin1(".") )	return TRUE;    QString old = dPath;    if ( acceptAbsPath && !isRelativePath(dirName) ) {	dPath = cleanDirPath( dirName );    } else {	if ( !isRoot() )	    dPath += '/';	dPath += dirName;	if ( dirName.find('/') >= 0		|| old == QString::fromLatin1(".")		|| dirName == QString::fromLatin1("..") )	    dPath = cleanDirPath( dPath );    }    if ( !exists() ) {	dPath = old;			// regret	return FALSE;    }    dirty = TRUE;    return TRUE;}/*!  Changes directory by moving one directory up the path followed to arrive  at the current directory.  Returns TRUE if the new directory exists and is readable. Note that the  logical cdUp() operation is not performed if the new directory does not  exist.  \sa cd(), isReadable(), exists(), path()*/bool QDir::cdUp(){    return cd( QString::fromLatin1("..") );}/*!  \fn QString QDir::nameFilter() const  Returns the string set by setNameFilter()*//*!  Sets the name filter used by entryList() and entryInfoList().  The name filter is a wildcarding filter that understands "*" and "?"  wildcards, You may specify several filter entries separated by a " " or a ";". If  you want entryList() and entryInfoList() to list all files ending with  ".cpp" and all files ending with ".h", you simply call  dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h")  \sa nameFilter(), setFilter()*/void QDir::setNameFilter( const QString &nameFilter ){    nameFilt = nameFilter;    if ( nameFilt.isEmpty() )	nameFilt = QString::fromLatin1("*");    dirty = TRUE;}/*!  \fn QDir::FilterSpec QDir::filter() const  Returns the value set by setFilter()*//*! \enum QDir::FilterSpec  This enum describes how QDir is to select what entries in a  directory to return.  The filter value is specified by or-ing  together values from the following list: <ul>  <li> \c Dirs - List directories only  <li> \c Files - List files only  <li> \c  Drives - List disk drives (does nothing under unix)  <li> \c  NoSymLinks - Do not list symbolic links (where they exist)  <li> \c  Readable - List files for which the application has read access.  <li> \c  Writable - List files for which the application has write access.  <li> \c  Executable - List files for which the application has execute access  <li> \c  Modified - Only list files that have been modified (does nothing  under unix)  <li> \c  Hidden - List hidden files (on unix, files starting with a .)  <li> \c  System - List system files (does nothing under unix)  </ul>  If you do not set any of \c Readable, \c Writable or \c Executable,  QDir will set all three of them.  This makes the default easy to  write and at the same time useful.  Examples: \c Readable|Writable means list all files for which the  application has read access, write access or both.  \c Dirs|Drives  means list drives, directories, all files that the application can  read, write or execute, and also symlinks to such files/directories.*//*!  Sets the filter used by entryList() and entryInfoList(). The filter is used  to specify the kind of files that should be returned by entryList() and  entryInfoList().  \sa filter(), setNameFilter()*/void QDir::setFilter( int filterSpec ){    if ( filtS == (FilterSpec) filterSpec )	return;    filtS = (FilterSpec) filterSpec;    dirty = TRUE;}/*!  \fn QDir::SortSpec QDir::sorting() const  Returns the value set by setSorting()  \sa setSorting()*//*! \enum QDir::SortSpec  This enum describes how QDir is to sort entries in a directory when  it returns a list of them.  The sort value is specified by or-ing  together values from the following list: <ul>  <li> \c Name - sort by name  <li> \c Time - sort by time (modification time)  <li> \c Size - sort by file size  <li> \c Unsorted - do not sort  <li> \c DirsFirst - put all directories first in the list  <li> \c Reversed - reverse the sort order  <li> \c IgnoreCase - sort case-insensitively  </ul>  You can only specify one of the first four.  If you specify both \c  DirsFirst and \c Reversed, directories are still put first but the  list is otherwise reversed.*/// ### Unsorted+DirsFirst ? Unsorted+Reversed?/*!  Sets the sorting order used by entryList() and entryInfoList().  The \e sortSpec is specified by or-ing values from the enum  SortSpec. The different values are:  One of these:  <dl compact>  <dt>Name<dd> Sort by name (alphabetical order).  <dt>Time<dd> Sort by time (most recent first).  <dt>Size<dd> Sort by size (largest first).  <dt>Unsorted<dd> Use the operating system order (UNIX does NOT sort  alphabetically).  ORed with zero or more of these:  <dt>DirsFirst<dd> Always put directory names first.  <dt>Reversed<dd> Reverse sort order.  <dt>IgnoreCase<dd> Ignore case when sorting by name.  </dl>*/void QDir::setSorting( int sortSpec ){    if ( sortS == (SortSpec) sortSpec )	return;    sortS = (SortSpec) sortSpec;    dirty = TRUE;}/*!  \fn bool QDir::matchAllDirs() const  Returns the value set by setMatchAllDirs()  \sa setMatchAllDirs()*//*!  If \e enable is TRUE, all directories will be listed (even if they do not  match the filter or the name filter), otherwise only matched directories  will be listed.  \bug Currently, directories that do not match the filter will not be  included (the name filter will be ignored as expected).  \sa matchAllDirs()*/void QDir::setMatchAllDirs( bool enable ){    if ( (bool)allDirs == enable )	return;    allDirs = enable;    dirty = TRUE;}/*!  Returns the number of files that was found.  Equivalent to entryList().count().  \sa operator[](), entryList()*/uint QDir::count() const{    return entryList().count();}/*!  Returns the file name at position \e index in the list of found file  names.  Equivalent to entryList().at(index).  Returns null if the \e index is out of range or if the entryList()  function failed.  \sa count(), entryList()*/QString QDir::operator[]( int index ) const{    entryList();    return fList && index >= 0 && index < (int)fList->count() ?	(*fList)[index] : QString::null;}/*!  This function is included to easy porting from Qt 1.x to Qt 2.0,  it is the same as entryList(), but encodes the filenames as 8-bit  strings using QFile::encodedName().  It is more efficient to use entryList().*/QStrList QDir::encodedEntryList( int filterSpec, int sortSpec ) const{    QStrList r;    QStringList l = entryList(filterSpec,sortSpec);    for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {	r.append( QFile::encodeName(*it) );    }    return r;}/*!  This function is included to easy porting from Qt 1.x to Qt 2.0,  it is the same as entryList(), but encodes the filenames as 8-bit  strings using QFile::encodedName().  It is more efficient to use entryList().*/QStrList QDir::encodedEntryList( const QString &nameFilter,			   int filterSpec,			   int sortSpec ) const{    QStrList r;    QStringList l = entryList(nameFilter,filterSpec,sortSpec);    for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {	r.append( QFile::encodeName(*it) );    }    return r;}/*!  Returns a list of the names of all files and directories in the directory  indicated by the setSorting(), setFilter() and setNameFilter()  specifications.  The the filter and sorting specifications can be overridden using the  \e filterSpec and \e sortSpec arguments.  Returns an empty list if the directory is unreadable or does not exist.  \sa entryInfoList(), setNameFilter(), setSorting(), setFilter(),	encodedEntryList()*/QStringList QDir::entryList( int filterSpec, int sortSpec ) const{    if ( !dirty && filterSpec == (int)DefaultFilter &&		   sortSpec   == (int)DefaultSort )	return *fList;    return entryList( nameFilt, filterSpec, sortSpec );}/*!  Returns a list of the names of all files and directories in the directory  indicated by the setSorting(), setFilter() and setNameFilter()  specifications.  The the filter and sorting specifications can be overridden using the  \e nameFilter, \e filterSpec and \e sortSpec arguments.  Returns and empty list if the directory is unreadable or does not exist.  \sa entryInfoList(), setNameFilter(), setSorting(), setFilter(),	encodedEntryList()*/QStringList QDir::entryList( const QString &nameFilter,				 int filterSpec, int sortSpec ) const{    if ( filterSpec == (int)DefaultFilter )	filterSpec = filtS;    if ( sortSpec == (int)DefaultSort )	sortSpec = sortS;    QDir *that = (QDir*)this;			// mutable function    if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) )	return *that->fList;    else	return QStringList();}/*!  Returns a list of QFileInfo objects for all files and directories in  the directory pointed to using the setSorting(), setFilter() and  setNameFilter() specifications.  The the filter and sorting specifications can be overridden using the  \e filterSpec and \e sortSpec arguments.  Returns 0 if the directory is unreadable or does not exist.  The returned pointer is a const pointer to a QFileInfoList. The list is  owned by the QDir object and will be reused on the next call to  entryInfoList() for the same QDir instance. If you want to keep the  entries of the list after a subsequent call to this function you will  need to copy them.  \sa entryList(), setNameFilter(), setSorting(), setFilter()*/const QFileInfoList *QDir::entryInfoList( int filterSpec, int sortSpec ) const{    if ( !dirty && filterSpec == (int)DefaultFilter &&		   sortSpec   == (int)DefaultSort )	return fiList;    return entryInfoList( nameFilt, filterSpec, sortSpec );}/*!  Returns a list of QFileInfo objects for all files and directories in  the directory pointed to using the setSorting(), setFilter() and  setNameFilter() specifications.  The the filter and sorting specifications can be overridden using the  \e nameFilter, \e filterSpec and \e sortSpec arguments.  Returns 0 if the directory is unreadable or does not exist.  The returned pointer is a const pointer to a QFileInfoList. The list is  owned by the QDir object and will be reused on the next call to  entryInfoList() for the same QDir instance. If you want to keep the  entries of the list after a subsequent call to this function you will  need to copy them.  \sa entryList(), setNameFilter(), setSorting(), setFilter()*/const QFileInfoList *QDir::entryInfoList( const QString &nameFilter,					  int filterSpec, int sortSpec ) const{    if ( filterSpec == (int)DefaultFilter )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -