Eneboo - Documentación para desarrolladores
Tipos públicos | Métodos públicos | Métodos públicos estáticos | Amigas
Referencia de la Clase QDir

The QDir class provides access to directory structures and their contents in a platform-independent way. Más...

#include <qdir.h>

Lista de todos los miembros.

Tipos públicos

enum  FilterSpec {
  Dirs = 0x001, Files = 0x002, Drives = 0x004, NoSymLinks = 0x008,
  All = 0x007, TypeMask = 0x00F, Readable = 0x010, Writable = 0x020,
  Executable = 0x040, RWEMask = 0x070, Modified = 0x080, Hidden = 0x100,
  System = 0x200, AccessMask = 0x3F0, DefaultFilter = -1, Dirs = 0x001,
  Files = 0x002, Drives = 0x004, NoSymLinks = 0x008, All = 0x007,
  TypeMask = 0x00F, Readable = 0x010, Writable = 0x020, Executable = 0x040,
  RWEMask = 0x070, Modified = 0x080, Hidden = 0x100, System = 0x200,
  AccessMask = 0x3F0, DefaultFilter = -1
}
enum  SortSpec {
  Name = 0x00, Time = 0x01, Size = 0x02, Unsorted = 0x03,
  SortByMask = 0x03, DirsFirst = 0x04, Reversed = 0x08, IgnoreCase = 0x10,
  LocaleAware = 0x20, DefaultSort = -1, Name = 0x00, Time = 0x01,
  Size = 0x02, Unsorted = 0x03, SortByMask = 0x03, DirsFirst = 0x04,
  Reversed = 0x08, IgnoreCase = 0x10, LocaleAware = 0x20, DefaultSort = -1
}
enum  FilterSpec {
  Dirs = 0x001, Files = 0x002, Drives = 0x004, NoSymLinks = 0x008,
  All = 0x007, TypeMask = 0x00F, Readable = 0x010, Writable = 0x020,
  Executable = 0x040, RWEMask = 0x070, Modified = 0x080, Hidden = 0x100,
  System = 0x200, AccessMask = 0x3F0, DefaultFilter = -1, Dirs = 0x001,
  Files = 0x002, Drives = 0x004, NoSymLinks = 0x008, All = 0x007,
  TypeMask = 0x00F, Readable = 0x010, Writable = 0x020, Executable = 0x040,
  RWEMask = 0x070, Modified = 0x080, Hidden = 0x100, System = 0x200,
  AccessMask = 0x3F0, DefaultFilter = -1
}
enum  SortSpec {
  Name = 0x00, Time = 0x01, Size = 0x02, Unsorted = 0x03,
  SortByMask = 0x03, DirsFirst = 0x04, Reversed = 0x08, IgnoreCase = 0x10,
  LocaleAware = 0x20, DefaultSort = -1, Name = 0x00, Time = 0x01,
  Size = 0x02, Unsorted = 0x03, SortByMask = 0x03, DirsFirst = 0x04,
  Reversed = 0x08, IgnoreCase = 0x10, LocaleAware = 0x20, DefaultSort = -1
}

Métodos públicos

 QDir ()
 QDir (const QString &path, const QString &nameFilter=QString::null, int sortSpec=Name|IgnoreCase, int filterSpec=All)
 QDir (const QDir &)
virtual ~QDir ()
QDiroperator= (const QDir &)
QDiroperator= (const QString &path)
virtual void setPath (const QString &path)
virtual QString path () const
virtual QString absPath () const
virtual QString canonicalPath () const
virtual QString dirName () const
virtual QString filePath (const QString &fileName, bool acceptAbsPath=TRUE) const
virtual QString absFilePath (const QString &fileName, bool acceptAbsPath=TRUE) const
virtual bool cd (const QString &dirName, bool acceptAbsPath=TRUE)
virtual bool cdUp ()
QString nameFilter () const
virtual void setNameFilter (const QString &nameFilter)
FilterSpec filter () const
virtual void setFilter (int filterSpec)
SortSpec sorting () const
virtual void setSorting (int sortSpec)
bool matchAllDirs () const
virtual void setMatchAllDirs (bool)
uint count () const
QString operator[] (int) const
virtual QStrList encodedEntryList (int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual QStrList encodedEntryList (const QString &nameFilter, int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual QStringList entryList (int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual QStringList entryList (const QString &nameFilter, int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual const QFileInfoListentryInfoList (int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual const QFileInfoListentryInfoList (const QString &nameFilter, int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual bool mkdir (const QString &dirName, bool acceptAbsPath=TRUE) const
virtual bool rmdir (const QString &dirName, bool acceptAbsPath=TRUE) const
virtual bool mkpath (const QString &dirPath) const
virtual bool rmpath (const QString &dirPath) const
virtual bool isReadable () const
virtual bool exists () const
virtual bool isRoot () const
virtual bool isRelative () const
virtual void convertToAbs ()
virtual bool operator== (const QDir &) const
virtual bool operator!= (const QDir &) const
virtual bool remove (const QString &fileName, bool acceptAbsPath=TRUE)
virtual bool rename (const QString &name, const QString &newName, bool acceptAbsPaths=TRUE)
virtual bool exists (const QString &name, bool acceptAbsPath=TRUE)
void refresh () const
 QDir ()
 QDir (const QString &path, const QString &nameFilter=QString::null, int sortSpec=Name|IgnoreCase, int filterSpec=All)
 QDir (const QDir &)
virtual ~QDir ()
QDiroperator= (const QDir &)
QDiroperator= (const QString &path)
virtual void setPath (const QString &path)
virtual QString path () const
virtual QString absPath () const
virtual QString canonicalPath () const
virtual QString dirName () const
virtual QString filePath (const QString &fileName, bool acceptAbsPath=TRUE) const
virtual QString absFilePath (const QString &fileName, bool acceptAbsPath=TRUE) const
virtual bool cd (const QString &dirName, bool acceptAbsPath=TRUE)
virtual bool cdUp ()
QString nameFilter () const
virtual void setNameFilter (const QString &nameFilter)
FilterSpec filter () const
virtual void setFilter (int filterSpec)
SortSpec sorting () const
virtual void setSorting (int sortSpec)
bool matchAllDirs () const
virtual void setMatchAllDirs (bool)
uint count () const
QString operator[] (int) const
virtual QStrList encodedEntryList (int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual QStrList encodedEntryList (const QString &nameFilter, int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual QStringList entryList (int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual QStringList entryList (const QString &nameFilter, int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual const QFileInfoListentryInfoList (int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual const QFileInfoListentryInfoList (const QString &nameFilter, int filterSpec=DefaultFilter, int sortSpec=DefaultSort) const
virtual bool mkdir (const QString &dirName, bool acceptAbsPath=TRUE) const
virtual bool rmdir (const QString &dirName, bool acceptAbsPath=TRUE) const
virtual bool mkpath (const QString &dirPath) const
virtual bool rmpath (const QString &dirPath) const
virtual bool isReadable () const
virtual bool exists () const
virtual bool isRoot () const
virtual bool isRelative () const
virtual void convertToAbs ()
virtual bool operator== (const QDir &) const
virtual bool operator!= (const QDir &) const
virtual bool remove (const QString &fileName, bool acceptAbsPath=TRUE)
virtual bool rename (const QString &name, const QString &newName, bool acceptAbsPaths=TRUE)
virtual bool exists (const QString &name, bool acceptAbsPath=TRUE)
void refresh () const

Métodos públicos estáticos

static QString convertSeparators (const QString &pathName)
static const QFileInfoListdrives ()
static char separator ()
static bool setCurrent (const QString &path)
static QDir current ()
static QDir home ()
static QDir root ()
static QString currentDirPath ()
static QString homeDirPath ()
static QString rootDirPath ()
static bool match (const QStringList &filters, const QString &fileName)
static bool match (const QString &filter, const QString &fileName)
static QString cleanDirPath (const QString &dirPath)
static bool isRelativePath (const QString &path)
static QString convertSeparators (const QString &pathName)
static const QFileInfoListdrives ()
static char separator ()
static bool setCurrent (const QString &path)
static QDir current ()
static QDir home ()
static QDir root ()
static QString currentDirPath ()
static QString homeDirPath ()
static QString rootDirPath ()
static bool match (const QStringList &filters, const QString &fileName)
static bool match (const QString &filter, const QString &fileName)
static QString cleanDirPath (const QString &dirPath)
static bool isRelativePath (const QString &path)

Amigas

class QDeepCopy< QDir >

Descripción detallada

The QDir class provides access to directory structures and their contents in a platform-independent way.

A QDir is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file 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). If you always use "/" as a directory separator, Qt 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.

The "current" path refers to the application's working directory. A QDir's own path is set and retrieved with setPath() and path().

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 QDir is using a relative or an absolute file path. Call convertToAbs() to convert a relative QDir 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().

QDir 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 QDir 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 QFileInfo 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().

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.

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 Qt 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().

Examples:

See if a directory exists.

    QDir d( "example" );                        // "./example"
    if ( !d.exists() )
        qWarning( "Cannot find the example directory" );

Traversing directories and reading a file.

    QDir d = QDir::root();                      // "/"
    if ( !d.cd("tmp") ) {                       // "/tmp"
        qWarning( "Cannot find the \"/tmp\" directory" );
    } else {
        QFile f( d.filePath("ex1.txt") );       // "/tmp/ex1.txt"
        if ( !f.open(IO_ReadWrite) )
            qWarning( "Cannot create the file %s", f.name() );
    }

A program that lists all the files in the current directory (excluding symbolic links), sorted by size, smallest first:

    #include <stdio.h>
    #include <qdir.h>

    int main( int argc, char **argv )
    {
        QDir d;
        d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
        d.setSorting( QDir::Size | QDir::Reversed );

        const QFileInfoList *list = d.entryInfoList();
        QFileInfoListIterator it( *list );
        QFileInfo *fi;

        printf( "     Bytes Filename\n" );
        while ( (fi = it.current()) != 0 ) {
            printf( "%10li %s\n", fi->size(), fi->fileName().latin1() );
            ++it;
        }
        return 0;
    }
Ver también:
QApplication::applicationDirPath()

Documentación de las enumeraciones miembro de la clase

This enum describes the filtering options available to QDir, e.g. for entryList() and entryInfoList(). The filter value is specified by OR-ing together values from the following list:

Dirs List directories only. Files List files only. Drives List disk drives (ignored under Unix). NoSymLinks Do not list symbolic links (ignored by operating systems that don't support symbolic links). All List directories, files, drives and symlinks (this does not list broken symlinks unless you specify System). TypeMask A mask for the the Dirs, Files, Drives and NoSymLinks flags. Readable List files for which the application has read access. Writable List files for which the application has write access. Executable List files for which the application has execute access. Executables needs to be combined with Dirs or Files. RWEMask A mask for the Readable, Writable and Executable flags. Modified Only list files that have been modified (ignored under Unix). Hidden List hidden files (on Unix, files starting with a .). System List system files (on Unix, FIFOs, sockets and device files) AccessMask A mask for the Readable, Writable, Executable Modified, Hidden and System flags DefaultFilter Internal flag.

If you do not set any of Readable, Writable or Executable, QDir will set all three of them. This makes the default easy to write and at the same time useful.

Examples: Readable|Writable means list all files for which the application has read access, write access or both. Dirs|Drives means list drives, directories, all files that the application can read, write or execute, and also symlinks to such files/directories.

Valores de enumeraciones:
Dirs 
Files 
Drives 
NoSymLinks 
All 
TypeMask 
Readable 
Writable 
Executable 
RWEMask 
Modified 
Hidden 
System 
AccessMask 
DefaultFilter 
Dirs 
Files 
Drives 
NoSymLinks 
All 
TypeMask 
Readable 
Writable 
Executable 
RWEMask 
Modified 
Hidden 
System 
AccessMask 
DefaultFilter 
Valores de enumeraciones:
Dirs 
Files 
Drives 
NoSymLinks 
All 
TypeMask 
Readable 
Writable 
Executable 
RWEMask 
Modified 
Hidden 
System 
AccessMask 
DefaultFilter 
Dirs 
Files 
Drives 
NoSymLinks 
All 
TypeMask 
Readable 
Writable 
Executable 
RWEMask 
Modified 
Hidden 
System 
AccessMask 
DefaultFilter 
Valores de enumeraciones:
Name 
Time 
Size 
Unsorted 
SortByMask 
DirsFirst 
Reversed 
IgnoreCase 
LocaleAware 
DefaultSort 
Name 
Time 
Size 
Unsorted 
SortByMask 
DirsFirst 
Reversed 
IgnoreCase 
LocaleAware 
DefaultSort 

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:

Name Sort by name. Time Sort by time (modification time). Size Sort by file size. Unsorted Do not sort. SortByMask A mask for Name, Time and Size.

DirsFirst Put the directories first, then the files. Reversed Reverse the sort order. IgnoreCase Sort case-insensitively. LocaleAware Sort names using locale aware compares DefaultSort Internal flag.

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.

Valores de enumeraciones:
Name 
Time 
Size 
Unsorted 
SortByMask 
DirsFirst 
Reversed 
IgnoreCase 
LocaleAware 
DefaultSort 
Name 
Time 
Size 
Unsorted 
SortByMask 
DirsFirst 
Reversed 
IgnoreCase 
LocaleAware 
DefaultSort 

Documentación del constructor y destructor

QDir::QDir ( )

Constructs a QDir pointing to the current directory (".").

Ver también:
currentDirPath()
QDir::QDir ( const QString path,
const QString nameFilter = QString::null,
int  sortSpec = Name | IgnoreCase,
int  filterSpec = All 
)

Constructs a QDir with path path, that filters its entries by name using nameFilter and by attributes using filterSpec. It also sorts the names using sortSpec.

The default nameFilter is an empty string, which excludes nothing; the default filterSpec is All, which also means exclude nothing. The default sortSpec is Name|IgnoreCase, i.e. sort by name case-insensitively.

Example that lists all the files in "/tmp":

    QDir d( "/tmp" );
    for ( int i = 0; i < d.count(); i++ )
        printf( "%s\n", d[i] );

If path is "" or QString::null, QDir uses "." (the current directory). If nameFilter is "" or QString::null, QDir uses the name filter "*" (all files).

Note that path need not exist.

Ver también:
exists(), setPath(), setNameFilter(), setFilter(), setSorting()
QDir::QDir ( const QDir d)

Constructs a QDir that is a copy of the directory d.

Ver también:
operator=()
QDir::~QDir ( ) [virtual]

Destroys the QDir frees up its resources.

QDir::QDir ( )
QDir::QDir ( const QString path,
const QString nameFilter = QString::null,
int  sortSpec = Name|IgnoreCase,
int  filterSpec = All 
)
QDir::QDir ( const QDir )
virtual QDir::~QDir ( ) [virtual]

Documentación de las funciones miembro

QString QDir::absFilePath ( const QString fileName,
bool  acceptAbsPath = TRUE 
) const [virtual]

Returns the absolute path name of a file in the directory. Does not check if the file actually exists in the directory. Redundant multiple separators or "." and ".." directories in fileName will not be removed (see cleanDirPath()).

If acceptAbsPath is TRUE a fileName starting with a separator "/" will be returned without change. If acceptAbsPath is FALSE an absolute path will be prepended to the fileName and the resultant string returned.

Ver también:
filePath()
virtual QString QDir::absFilePath ( const QString fileName,
bool  acceptAbsPath = TRUE 
) const [virtual]
QString QDir::absPath ( ) const [virtual]

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.

Ver también:
setPath(), canonicalPath(), exists(), cleanDirPath(), dirName(), absFilePath()
virtual QString QDir::absPath ( ) const [virtual]
QString QDir::canonicalPath ( ) const [virtual]
virtual QString QDir::canonicalPath ( ) const [virtual]
virtual bool QDir::cd ( const QString dirName,
bool  acceptAbsPath = TRUE 
) [virtual]
bool QDir::cd ( const QString dirName,
bool  acceptAbsPath = TRUE 
) [virtual]

Changes the QDir's directory to dirName.

If acceptAbsPath is TRUE a path starting with separator "/" will cause the function to change to the absolute directory. If acceptAbsPath is FALSE any number of separators at the beginning of dirName will be removed and the function will descend into dirName.

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.

Calling cd( ".." ) is equivalent to calling cdUp().

Ver también:
cdUp(), isReadable(), exists(), path()
virtual bool QDir::cdUp ( ) [virtual]
bool QDir::cdUp ( ) [virtual]

Changes directory by moving one directory up from the QDir's current directory.

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.

Ver también:
cd(), isReadable(), exists(), path()
QString QDir::cleanDirPath ( const QString filePath) [static]

Removes all multiple directory separators "/" and resolves any "."s or ".."s found in the path, filePath.

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".

Ver también:
absPath() canonicalPath()
static QString QDir::cleanDirPath ( const QString dirPath) [static]
static QString QDir::convertSeparators ( const QString pathName) [static]
QString QDir::convertSeparators ( const QString pathName) [static]

Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.

On Windows, convertSeparators("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.

void QDir::convertToAbs ( ) [virtual]

Converts the directory path to an absolute path. If it is already absolute nothing is done.

Ver también:
isRelative()
virtual void QDir::convertToAbs ( ) [virtual]
uint QDir::count ( ) const
uint QDir::count ( ) const

Returns the total number of directories and files that were found.

Equivalent to entryList().count().

Ver también:
operator[](), entryList()
QDir QDir::current ( ) [static]

Returns the application's current directory.

Use path() to access a QDir object's path.

Ver también:
currentDirPath(), QDir::QDir()
static QDir QDir::current ( ) [static]
QString QDir::currentDirPath ( ) [static]
static QString QDir::currentDirPath ( ) [static]
QString QDir::dirName ( ) const [virtual]

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) QString::null is returned.

No check is made to ensure that a directory with this name actually exists.

Ver también:
path(), absPath(), absFilePath(), exists(), QString::isNull()
virtual QString QDir::dirName ( ) const [virtual]
static const QFileInfoList* QDir::drives ( ) [static]
const QFileInfoList * QDir::drives ( ) [static]
virtual QStrList QDir::encodedEntryList ( int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]
virtual QStrList QDir::encodedEntryList ( const QString nameFilter,
int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]
QStrList QDir::encodedEntryList ( int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]

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 = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. 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().

virtual const QFileInfoList* QDir::entryInfoList ( int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]
virtual const QFileInfoList* QDir::entryInfoList ( const QString nameFilter,
int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]
const QFileInfoList * QDir::entryInfoList ( int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns a list of QFileInfo objects for all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().

The filter and sorting specifications can be overridden using the filterSpec and 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 must copy them.

Note: QFileInfoList is really a QPtrList<QFileInfo>.

Ver también:
entryList(), setNameFilter(), setSorting(), setFilter()
const QFileInfoList * QDir::entryInfoList ( const QString nameFilter,
int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]

Returns a list of QFileInfo objects for all the files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter().

The filter and sorting specifications can be overridden using the nameFilter, filterSpec and 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 must copy them.

Note: QFileInfoList is really a QPtrList<QFileInfo>.

Ver también:
entryList(), setNameFilter(), setSorting(), setFilter()
virtual QStringList QDir::entryList ( int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]
virtual QStringList QDir::entryList ( const QString nameFilter,
int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]
QStringList QDir::entryList ( int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. 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().

The filter and sorting specifications can be overridden using the filterSpec and sortSpec arguments.

Returns an empty list if the directory is unreadable or does not exist.

Ver también:
entryInfoList(), setNameFilter(), setSorting(), setFilter()
QStringList QDir::entryList ( const QString nameFilter,
int  filterSpec = DefaultFilter,
int  sortSpec = DefaultSort 
) const [virtual]

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().

The filter and sorting specifications can be overridden using the nameFilter, filterSpec and sortSpec arguments.

Returns an empty list if the directory is unreadable or does not exist.

Ver también:
entryInfoList(), setNameFilter(), setSorting(), setFilter()
bool QDir::exists ( ) const [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns TRUE if the directory exists; otherwise returns FALSE. (If a file with the same name is found this function will return FALSE).

Ver también:
QFileInfo::exists(), QFile::exists()
bool QDir::exists ( const QString name,
bool  acceptAbsPath = TRUE 
) [virtual]

Checks for the existence of the file name.

If acceptAbsPath is TRUE a path starting with separator "/" will check the file with the absolute path. If acceptAbsPath is FALSE any number of separators at the beginning of name will be removed and the resultant file name will be checked.

Returns TRUE if the file exists; otherwise returns FALSE.

Ver también:
QFileInfo::exists(), QFile::exists()
virtual bool QDir::exists ( ) const [virtual]
virtual bool QDir::exists ( const QString name,
bool  acceptAbsPath = TRUE 
) [virtual]
virtual QString QDir::filePath ( const QString fileName,
bool  acceptAbsPath = TRUE 
) const [virtual]
QString QDir::filePath ( const QString fileName,
bool  acceptAbsPath = TRUE 
) const [virtual]

Returns the path name of a file in the directory. Does not 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 fileName will not be removed (see cleanDirPath()).

If acceptAbsPath is TRUE a fileName starting with a separator "/" will be returned without change. If acceptAbsPath is FALSE an absolute path will be prepended to the fileName and the resultant string returned.

Ver también:
absFilePath(), isRelative(), canonicalPath()
FilterSpec QDir::filter ( ) const
QDir::FilterSpec QDir::filter ( ) const [inline]

Returns the value set by setFilter()

QDir QDir::home ( ) [static]

Returns the home directory.

Under Windows the HOME environment variable is used. If this does not exist the USERPROFILE environment variable is used. If that does not exist the path is formed by concatenating the HOMEDRIVE and HOMEPATH environment variables. If they don't exist the rootDirPath() is used (this uses the SystemDrive environment variable). If none of these exist "C:\" is used.

Under non-Windows operating systems the HOME environment variable is used if it exists, otherwise rootDirPath() is used.

Ver también:
homeDirPath()
static QDir QDir::home ( ) [static]
QString QDir::homeDirPath ( ) [static]

Returns the absolute path of the user's home directory.

Ver también:
home()
static QString QDir::homeDirPath ( ) [static]
bool QDir::isReadable ( ) const [virtual]
virtual bool QDir::isReadable ( ) const [virtual]
bool QDir::isRelative ( ) const [virtual]

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 "/").

Ver también:
convertToAbs()
virtual bool QDir::isRelative ( ) const [virtual]
static bool QDir::isRelativePath ( const QString path) [static]
bool QDir::isRelativePath ( const QString path) [static]
bool QDir::isRoot ( ) const [virtual]
virtual bool QDir::isRoot ( ) const [virtual]
bool QDir::match ( const QString filter,
const QString fileName 
) [static]

Returns TRUE if the fileName matches the wildcard (glob) pattern filter; otherwise returns FALSE. The filter may contain multiple patterns separated by spaces or semicolons.

(See QRegExp wildcard matching.)

Ver también:
QRegExp::match()
bool QDir::match ( const QStringList filters,
const QString fileName 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns TRUE if the fileName matches any of the wildcard (glob) patterns in the list of filters; otherwise returns FALSE.

(See QRegExp wildcard matching.)

Ver también:
QRegExp::match()
static bool QDir::match ( const QStringList filters,
const QString fileName 
) [static]
static bool QDir::match ( const QString filter,
const QString fileName 
) [static]
bool QDir::matchAllDirs ( ) const [inline]

Returns the value set by setMatchAllDirs()

Ver también:
setMatchAllDirs()
bool QDir::matchAllDirs ( ) const
virtual bool QDir::mkdir ( const QString dirName,
bool  acceptAbsPath = TRUE 
) const [virtual]
bool QDir::mkdir ( const QString dirName,
bool  acceptAbsPath = TRUE 
) const [virtual]
bool QDir::mkpath ( const QString dirPath) const [virtual]
virtual bool QDir::mkpath ( const QString dirPath) const [virtual]
QString QDir::nameFilter ( ) const [inline]

Returns the string set by setNameFilter()

QString QDir::nameFilter ( ) const
bool QDir::operator!= ( const QDir d) const [inline, virtual]

Returns TRUE if directory d and this directory have different paths or different sort or filter settings; otherwise returns FALSE.

Example:

    // The current directory is "/usr/local"
    QDir d1( "/usr/local/bin" );
    QDir d2( "bin" );
    if ( d1 != d2 )
        qDebug( "They differ" );
virtual bool QDir::operator!= ( const QDir ) const [virtual]
QDir & QDir::operator= ( const QDir d)

Makes a copy of QDir d and assigns it to this QDir.

QDir & QDir::operator= ( const QString path)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Sets the directory path to be the given path.

QDir& QDir::operator= ( const QDir )
QDir& QDir::operator= ( const QString path)
bool QDir::operator== ( const QDir d) const [virtual]

Returns TRUE if directory d and this directory have the same path and their sort and filter settings are the same; otherwise returns FALSE.

Example:

    // The current directory is "/usr/local"
    QDir d1( "/usr/local/bin" );
    QDir d2( "bin" );
    d2.convertToAbs();
    if ( d1 == d2 )
        qDebug( "They're the same" );
virtual bool QDir::operator== ( const QDir ) const [virtual]
QString QDir::operator[] ( int  ) const
QString QDir::operator[] ( int  index) const

Returns the file name at position index in the list of file names. Equivalent to entryList().at(index).

Returns a QString::null if the index is out of range or if the entryList() function failed.

Ver también:
count(), entryList()
QString QDir::path ( ) const [inline, virtual]

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()).

Ver también:
setPath(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath(), convertSeparators()
virtual QString QDir::path ( ) const [virtual]
void QDir::refresh ( ) const

Refreshes the directory information.

void QDir::refresh ( ) const
virtual bool QDir::remove ( const QString fileName,
bool  acceptAbsPath = TRUE 
) [virtual]
bool QDir::remove ( const QString fileName,
bool  acceptAbsPath = TRUE 
) [virtual]

Removes the file, fileName.

If acceptAbsPath is TRUE a path starting with separator "/" will remove the file with the absolute path. If acceptAbsPath is FALSE any number of separators at the beginning of fileName will be removed and the resultant file name will be removed.

Returns TRUE if the file is removed successfully; otherwise returns FALSE.

bool QDir::rename ( const QString name,
const QString newName,
bool  acceptAbsPaths = TRUE 
) [virtual]
virtual bool QDir::rename ( const QString name,
const QString newName,
bool  acceptAbsPaths = TRUE 
) [virtual]
virtual bool QDir::rmdir ( const QString dirName,
bool  acceptAbsPath = TRUE 
) const [virtual]
bool QDir::rmdir ( const QString dirName,
bool  acceptAbsPath = TRUE 
) const [virtual]
virtual bool QDir::rmpath ( const QString dirPath) const [virtual]
bool QDir::rmpath ( const QString dirPath) const [virtual]
static QDir QDir::root ( ) [static]
QDir QDir::root ( ) [static]

Returns the root directory.

Ver también:
rootDirPath() drives()
QString QDir::rootDirPath ( ) [static]
static QString QDir::rootDirPath ( ) [static]
char QDir::separator ( ) [static]

Returns the native directory separator; "/" under UNIX (including Mac OS X) 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.

static char QDir::separator ( ) [static]
static bool QDir::setCurrent ( const QString path) [static]
bool QDir::setCurrent ( const QString path) [static]
virtual void QDir::setFilter ( int  filterSpec) [virtual]
void QDir::setFilter ( int  filterSpec) [virtual]

Sets the filter used by entryList() and entryInfoList() to filterSpec. The filter is used to specify the kind of files that should be returned by entryList() and entryInfoList(). See {QDir::FilterSpec}.

Ver también:
filter(), setNameFilter()
void QDir::setMatchAllDirs ( bool  enable) [virtual]

If enable is TRUE then all directories are included (e.g. in entryList()), and the nameFilter() is only applied to the files. If enable is FALSE then the nameFilter() is applied to both directories and files.

Ver también:
matchAllDirs()
virtual void QDir::setMatchAllDirs ( bool  ) [virtual]
virtual void QDir::setNameFilter ( const QString nameFilter) [virtual]
void QDir::setNameFilter ( const QString nameFilter) [virtual]

Sets the name filter used by entryList() and entryInfoList() to nameFilter.

The nameFilter 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 ";".

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").

Ver también:
nameFilter(), setFilter()
virtual void QDir::setPath ( const QString path) [virtual]
void QDir::setPath ( const QString path) [virtual]

Sets the path of the directory to path. The path is cleaned of redundant ".", ".." and of multiple separators. No check is made to ensure that a directory with this path 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".

Ver también:
path(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath(), isRelative(), convertToAbs()
virtual void QDir::setSorting ( int  sortSpec) [virtual]
void QDir::setSorting ( int  sortSpec) [virtual]

Sets the sort order used by entryList() and entryInfoList().

The sortSpec is specified by OR-ing values from the enum {QDir::SortSpec}.

Ver también:
sorting() SortSpec
QDir::SortSpec QDir::sorting ( ) const [inline]

Returns the value set by setSorting()

Ver también:
setSorting() SortSpec
SortSpec QDir::sorting ( ) const

Documentación de las funciones relacionadas y clases amigas

QDeepCopy< QDir > [friend]

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'