Blame qtools/qdir.cpp

Packit Service 50c9f2
/****************************************************************************
Packit Service 50c9f2
** 
Packit Service 50c9f2
**
Packit Service 50c9f2
** Implementation of QDir class
Packit Service 50c9f2
**
Packit Service 50c9f2
** Created : 950427
Packit Service 50c9f2
**
Packit Service 50c9f2
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
Packit Service 50c9f2
**
Packit Service 50c9f2
** This file is part of the tools module of the Qt GUI Toolkit.
Packit Service 50c9f2
**
Packit Service 50c9f2
** This file may be distributed under the terms of the Q Public License
Packit Service 50c9f2
** as defined by Trolltech AS of Norway and appearing in the file
Packit Service 50c9f2
** LICENSE.QPL included in the packaging of this file.
Packit Service 50c9f2
**
Packit Service 50c9f2
** This file may be distributed and/or modified under the terms of the
Packit Service 50c9f2
** GNU General Public License version 2 as published by the Free Software
Packit Service 50c9f2
** Foundation and appearing in the file LICENSE.GPL included in the
Packit Service 50c9f2
** packaging of this file.
Packit Service 50c9f2
**
Packit Service 50c9f2
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
Packit Service 50c9f2
** licenses may use this file in accordance with the Qt Commercial License
Packit Service 50c9f2
** Agreement provided with the Software.
Packit Service 50c9f2
**
Packit Service 50c9f2
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
Packit Service 50c9f2
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit Service 50c9f2
**
Packit Service 50c9f2
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
Packit Service 50c9f2
**   information about Qt Commercial License Agreements.
Packit Service 50c9f2
** See http://www.trolltech.com/qpl/ for QPL licensing information.
Packit Service 50c9f2
** See http://www.trolltech.com/gpl/ for GPL licensing information.
Packit Service 50c9f2
**
Packit Service 50c9f2
** Contact info@trolltech.com if any conditions of this licensing are
Packit Service 50c9f2
** not clear to you.
Packit Service 50c9f2
**
Packit Service 50c9f2
**********************************************************************/
Packit Service 50c9f2
Packit Service 50c9f2
#include "qglobal.h"
Packit Service 50c9f2
Packit Service 50c9f2
#include "qdir.h"
Packit Service 50c9f2
Packit Service 50c9f2
#ifndef QT_NO_DIR
Packit Service 50c9f2
#include "qfileinfo.h"
Packit Service 50c9f2
#include "qfiledefs_p.h"
Packit Service 50c9f2
#include "qregexp.h"
Packit Service 50c9f2
#include "qstringlist.h"
Packit Service 50c9f2
#include <stdlib.h>
Packit Service 50c9f2
#include <ctype.h>
Packit Service 50c9f2
Packit Service 50c9f2
// NOT REVISED
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  \class QDir qdir.h
Packit Service 50c9f2
  \brief Traverses directory structures and contents in a
Packit Service 50c9f2
	    platform-independent way.
Packit Service 50c9f2
Packit Service 50c9f2
  \ingroup io
Packit Service 50c9f2
Packit Service 50c9f2
  A QDir can point to a file using either a relative or an absolute file
Packit Service 50c9f2
  path. Absolute file paths begin with the directory separator ('/') or a
Packit Service 50c9f2
  drive specification (not applicable to UNIX).	 Relative file names begin
Packit Service 50c9f2
  with a directory name or a file name and specify a path relative to the
Packit Service 50c9f2
  current directory.
Packit Service 50c9f2
Packit Service 50c9f2
  An example of an absolute path is the string "/tmp/quartz", a relative
Packit Service 50c9f2
  path might look like "src/fatlib". You can use the function isRelative()
Packit Service 50c9f2
  to check if a QDir is using a relative or an absolute file path. You can
Packit Service 50c9f2
  call the function convertToAbs() to convert a relative QDir to an
Packit Service 50c9f2
  absolute one.
Packit Service 50c9f2
Packit Service 50c9f2
  The directory "example" under the current directory is checked for existence
Packit Service 50c9f2
  in the example below:
Packit Service 50c9f2
Packit Service 50c9f2
  \code
Packit Service 50c9f2
    QDir d( "example" );			// "./example"
Packit Service 50c9f2
    if ( !d.exists() )
Packit Service 50c9f2
	qWarning( "Cannot find the example directory" );
Packit Service 50c9f2
  \endcode
Packit Service 50c9f2
Packit Service 50c9f2
  If you always use '/' as a directory separator, Qt will translate your
Packit Service 50c9f2
  paths to conform to the underlying operating system.
Packit Service 50c9f2
Packit Service 50c9f2
  cd() and cdUp() can be used to navigate the directory tree. Note that the
Packit Service 50c9f2
  logical cd and cdUp operations are not performed if the new directory does
Packit Service 50c9f2
  not exist.
Packit Service 50c9f2
Packit Service 50c9f2
  Example:
Packit Service 50c9f2
  \code
Packit Service 50c9f2
    QDir d = QDir::root();			// "/"
Packit Service 50c9f2
    if ( !d.cd("tmp") ) {			// "/tmp"
Packit Service 50c9f2
	qWarning( "Cannot find the \"/tmp\" directory" );
Packit Service 50c9f2
    } else {
Packit Service 50c9f2
	QFile f( d.filePath("ex1.txt") );	// "/tmp/ex1.txt"
Packit Service 50c9f2
	if ( !f.open(IO_ReadWrite) )
Packit Service 50c9f2
	    qWarning( "Cannot create the file %s", f.name() );
Packit Service 50c9f2
    }
Packit Service 50c9f2
  \endcode
Packit Service 50c9f2
Packit Service 50c9f2
  To read the contents of a directory you can use the entryList() and
Packit Service 50c9f2
  entryInfoList() functions.
Packit Service 50c9f2
Packit Service 50c9f2
  Example:
Packit Service 50c9f2
  \code
Packit Service 50c9f2
    #include <stdio.h>
Packit Service 50c9f2
    #include <qdir.h>
Packit Service 50c9f2
Packit Service 50c9f2
    //
Packit Service 50c9f2
    // This program scans the current directory and lists all files
Packit Service 50c9f2
    // that are not symbolic links, sorted by size with the smallest files
Packit Service 50c9f2
    // first.
Packit Service 50c9f2
    //
Packit Service 50c9f2
Packit Service 50c9f2
    int main( int argc, char **argv )
Packit Service 50c9f2
    {
Packit Service 50c9f2
	QDir d;
Packit Service 50c9f2
	d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
Packit Service 50c9f2
	d.setSorting( QDir::Size | QDir::Reversed );
Packit Service 50c9f2
Packit Service 50c9f2
	const QFileInfoList *list = d.entryInfoList();
Packit Service 50c9f2
	QFileInfoListIterator it( *list );	// create list iterator
Packit Service 50c9f2
	QFileInfo *fi;				// pointer for traversing
Packit Service 50c9f2
Packit Service 50c9f2
	printf( "     BYTES FILENAME\n" );	// print header
Packit Service 50c9f2
	while ( (fi=it.current()) ) {		// for each file...
Packit Service 50c9f2
	    printf( "%10li %s\n", fi->size(), fi->fileName().data() );
Packit Service 50c9f2
	    ++it;				// goto next list element
Packit Service 50c9f2
	}
Packit Service 50c9f2
    }
Packit Service 50c9f2
  \endcode
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Constructs a QDir pointing to the current directory.
Packit Service 50c9f2
  \sa currentDirPath()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QDir::QDir()
Packit Service 50c9f2
{
Packit Service 50c9f2
    dPath = QString::fromLatin1(".");
Packit Service 50c9f2
    init();
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Constructs a QDir.
Packit Service 50c9f2
Packit Service 50c9f2
  \arg \e path is the directory.
Packit Service 50c9f2
  \arg \e nameFilter is the file name filter.
Packit Service 50c9f2
  \arg \e sortSpec is the sort specification, which describes how to
Packit Service 50c9f2
  sort the files in the directory.
Packit Service 50c9f2
  \arg \e filterSpec is the filter specification, which describes how
Packit Service 50c9f2
  to filter the files in the directory.
Packit Service 50c9f2
Packit Service 50c9f2
  Most of these arguments (except \e path) have optional values.
Packit Service 50c9f2
Packit Service 50c9f2
  Example:
Packit Service 50c9f2
  \code
Packit Service 50c9f2
    // lists all files in /tmp
Packit Service 50c9f2
Packit Service 50c9f2
    QDir d( "/tmp" );
Packit Service 50c9f2
    for ( int i=0; i
Packit Service 50c9f2
	printf( "%s\n", d[i] );
Packit Service 50c9f2
  \endcode
Packit Service 50c9f2
Packit Service 50c9f2
  If \e path is "" or null, the directory is set to "." (the current
Packit Service 50c9f2
  directory).  If \e nameFilter is "" or null, it is set to "*" (all
Packit Service 50c9f2
  files).
Packit Service 50c9f2
Packit Service 50c9f2
  No check is made to ensure that the directory exists.
Packit Service 50c9f2
Packit Service 50c9f2
  \sa exists(), setPath(), setNameFilter(), setFilter(), setSorting()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QDir::QDir( const QString &path, const QString &nameFilter,
Packit Service 50c9f2
	    int sortSpec, int filterSpec )
Packit Service 50c9f2
{
Packit Service 50c9f2
    init();
Packit Service 50c9f2
    dPath = cleanDirPath( path );
Packit Service 50c9f2
    if ( dPath.isEmpty() )
Packit Service 50c9f2
	dPath = QString::fromLatin1(".");
Packit Service 50c9f2
    nameFilt = nameFilter;
Packit Service 50c9f2
    if ( nameFilt.isEmpty() )
Packit Service 50c9f2
	nameFilt = QString::fromLatin1("*");
Packit Service 50c9f2
    filtS = (FilterSpec)filterSpec;
Packit Service 50c9f2
    sortS = (SortSpec)sortSpec;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Constructs a QDir that is a copy of the given directory.
Packit Service 50c9f2
  \sa operator=()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QDir::QDir( const QDir &d )
Packit Service 50c9f2
{
Packit Service 50c9f2
    dPath = d.dPath;
Packit Service 50c9f2
    fList = 0;
Packit Service 50c9f2
    fiList = 0;
Packit Service 50c9f2
    nameFilt = d.nameFilt;
Packit Service 50c9f2
    dirty = TRUE;
Packit Service 50c9f2
    allDirs = d.allDirs;
Packit Service 50c9f2
    filtS = d.filtS;
Packit Service 50c9f2
    sortS = d.sortS;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
void QDir::init()
Packit Service 50c9f2
{
Packit Service 50c9f2
    fList = 0;
Packit Service 50c9f2
    fiList = 0;
Packit Service 50c9f2
    nameFilt = QString::fromLatin1("*");
Packit Service 50c9f2
    dirty = TRUE;
Packit Service 50c9f2
    allDirs = FALSE;
Packit Service 50c9f2
    filtS = All;
Packit Service 50c9f2
    sortS = SortSpec(Name | IgnoreCase);
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Destructs the QDir and cleans up.
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QDir::~QDir()
Packit Service 50c9f2
{
Packit Service 50c9f2
    if ( fList )
Packit Service 50c9f2
       delete fList;
Packit Service 50c9f2
    if ( fiList )
Packit Service 50c9f2
       delete fiList;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Sets the path of the directory. The path is cleaned of redundant ".", ".."
Packit Service 50c9f2
  and multiple separators. No check is made to ensure that a directory
Packit Service 50c9f2
  with this path exists.
Packit Service 50c9f2
Packit Service 50c9f2
  The path can be either absolute or relative. Absolute paths begin with the
Packit Service 50c9f2
  directory separator ('/') or a drive specification (not
Packit Service 50c9f2
  applicable to UNIX).
Packit Service 50c9f2
  Relative file names begin with a directory name or a file name and specify
Packit Service 50c9f2
  a path relative to the current directory. An example of
Packit Service 50c9f2
  an absolute path is the string "/tmp/quartz", a relative path might look like
Packit Service 50c9f2
  "src/fatlib". You can use the function isRelative() to check if a QDir
Packit Service 50c9f2
  is using a relative or an absolute file path. You can call the function
Packit Service 50c9f2
  convertToAbs() to convert a relative QDir to an absolute one.
Packit Service 50c9f2
Packit Service 50c9f2
  \sa path(), absPath(), exists(), cleanDirPath(), dirName(),
Packit Service 50c9f2
      absFilePath(), isRelative(), convertToAbs()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
void QDir::setPath( const QString &path )
Packit Service 50c9f2
{
Packit Service 50c9f2
    dPath = cleanDirPath( path );
Packit Service 50c9f2
    if ( dPath.isEmpty() )
Packit Service 50c9f2
	dPath = QString::fromLatin1(".");
Packit Service 50c9f2
    dirty = TRUE;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  \fn  QString QDir::path() const
Packit Service 50c9f2
  Returns the path, this may contain symbolic links, but never contains
Packit Service 50c9f2
  redundant ".", ".." or multiple separators.
Packit Service 50c9f2
Packit Service 50c9f2
  The returned path can be either absolute or relative (see setPath()).
Packit Service 50c9f2
Packit Service 50c9f2
  \sa setPath(), absPath(), exists(), cleanDirPath(), dirName(),
Packit Service 50c9f2
  absFilePath(), convertSeparators()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Returns the absolute (a path that starts with '/') path, which may
Packit Service 50c9f2
  contain symbolic links, but never contains redundant ".", ".." or
Packit Service 50c9f2
  multiple separators.
Packit Service 50c9f2
Packit Service 50c9f2
  \sa setPath(), canonicalPath(), exists(),  cleanDirPath(), dirName(),
Packit Service 50c9f2
  absFilePath()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QString QDir::absPath() const
Packit Service 50c9f2
{
Packit Service 50c9f2
    if ( QDir::isRelativePath(dPath) ) {
Packit Service 50c9f2
	QString tmp = currentDirPath();
Packit Service 50c9f2
	if ( tmp.right(1) != QString::fromLatin1("/") )
Packit Service 50c9f2
	    tmp += '/';
Packit Service 50c9f2
	tmp += dPath;
Packit Service 50c9f2
	return cleanDirPath( tmp );
Packit Service 50c9f2
    } else {
Packit Service 50c9f2
	return cleanDirPath( dPath );
Packit Service 50c9f2
    }
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Returns the name of the directory, this is NOT the same as the path, e.g.
Packit Service 50c9f2
  a directory with the name "mail", might have the path "/var/spool/mail".
Packit Service 50c9f2
  If the directory has no name (e.g. the root directory) a null string is
Packit Service 50c9f2
  returned.
Packit Service 50c9f2
Packit Service 50c9f2
  No check is made to ensure that a directory with this name actually exists.
Packit Service 50c9f2
Packit Service 50c9f2
  \sa path(), absPath(), absFilePath(), exists(), QString::isNull()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QString QDir::dirName() const
Packit Service 50c9f2
{
Packit Service 50c9f2
    int pos = dPath.findRev( '/' );
Packit Service 50c9f2
    if ( pos == -1  )
Packit Service 50c9f2
	return dPath;
Packit Service 50c9f2
    return dPath.right( dPath.length() - pos - 1 );
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Returns the path name of a file in the directory. Does NOT check if
Packit Service 50c9f2
  the file actually exists in the directory. If the QDir is relative
Packit Service 50c9f2
  the returned path name will also be relative. Redundant multiple separators
Packit Service 50c9f2
  or "." and ".." directories in \e fileName will not be removed (see
Packit Service 50c9f2
  cleanDirPath()).
Packit Service 50c9f2
Packit Service 50c9f2
  If \e acceptAbsPath is TRUE a \e fileName starting with a separator
Packit Service 50c9f2
  ('/') will be returned without change.
Packit Service 50c9f2
  If \e acceptAbsPath is FALSE an absolute path will be appended to
Packit Service 50c9f2
  the directory path.
Packit Service 50c9f2
Packit Service 50c9f2
  \sa absFilePath(), isRelative(), canonicalPath()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QString QDir::filePath( const QString &fileName,
Packit Service 50c9f2
			bool acceptAbsPath ) const
Packit Service 50c9f2
{
Packit Service 50c9f2
    if ( acceptAbsPath && !isRelativePath(fileName) )
Packit Service 50c9f2
	return QString(fileName);
Packit Service 50c9f2
Packit Service 50c9f2
    QString tmp = dPath;
Packit Service 50c9f2
    if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName &&
Packit Service 50c9f2
			   fileName[0] != '/') )
Packit Service 50c9f2
	tmp += '/';
Packit Service 50c9f2
    tmp += fileName;
Packit Service 50c9f2
    return tmp;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Returns the absolute path name of a file in the directory. Does NOT check if
Packit Service 50c9f2
  the file actually exists in the directory. Redundant multiple separators
Packit Service 50c9f2
  or "." and ".." directories in \e fileName will NOT be removed (see
Packit Service 50c9f2
  cleanDirPath()).
Packit Service 50c9f2
Packit Service 50c9f2
  If \e acceptAbsPath is TRUE a \e fileName starting with a separator
Packit Service 50c9f2
  ('/') will be returned without change.
Packit Service 50c9f2
  if \e acceptAbsPath is FALSE an absolute path will be appended to
Packit Service 50c9f2
  the directory path.
Packit Service 50c9f2
Packit Service 50c9f2
  \sa filePath()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QString QDir::absFilePath( const QString &fileName,
Packit Service 50c9f2
			   bool acceptAbsPath ) const
Packit Service 50c9f2
{
Packit Service 50c9f2
    if ( acceptAbsPath && !isRelativePath( fileName ) )
Packit Service 50c9f2
	return fileName;
Packit Service 50c9f2
Packit Service 50c9f2
    QString tmp = absPath();
Packit Service 50c9f2
    if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName &&
Packit Service 50c9f2
			   fileName[0] != '/') )
Packit Service 50c9f2
	tmp += '/';
Packit Service 50c9f2
    tmp += fileName;
Packit Service 50c9f2
    return tmp;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Converts the '/' separators in \a pathName to system native
Packit Service 50c9f2
  separators.  Returns the translated string.
Packit Service 50c9f2
Packit Service 50c9f2
  On Windows, convertSeparators("c:/winnt/system32") returns
Packit Service 50c9f2
  "c:\winnt\system32".
Packit Service 50c9f2
Packit Service 50c9f2
  No conversion is done on UNIX.
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
QString QDir::convertSeparators( const QString &pathName )
Packit Service 50c9f2
{
Packit Service 50c9f2
    QString n( pathName );
Packit Service 50c9f2
#if defined(_OS_FATFS_) || defined(_OS_OS2EMX_)
Packit Service 50c9f2
    for ( int i=0; i<(int)n.length(); i++ ) {
Packit Service 50c9f2
	if ( n[i] == '/' )
Packit Service 50c9f2
	    n[i] = '\\';
Packit Service 50c9f2
    }
Packit Service 50c9f2
#endif
Packit Service 50c9f2
    return n;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Changes directory by descending into the given directory. Returns
Packit Service 50c9f2
  TRUE if the new directory exists and is readable. Note that the logical
Packit Service 50c9f2
  cd operation is NOT performed if the new directory does not exist.
Packit Service 50c9f2
Packit Service 50c9f2
  If \e acceptAbsPath is TRUE a path starting with a separator ('/')
Packit Service 50c9f2
  will cd to the absolute directory, if \e acceptAbsPath is FALSE
Packit Service 50c9f2
  any number of separators at the beginning of \e dirName will be removed.
Packit Service 50c9f2
Packit Service 50c9f2
  Example:
Packit Service 50c9f2
  \code
Packit Service 50c9f2
  QDir d = QDir::home();  // now points to home directory
Packit Service 50c9f2
  if ( !d.cd("c++") ) {	  // now points to "c++" under home directory if OK
Packit Service 50c9f2
      QFileInfo fi( d, "c++" );
Packit Service 50c9f2
      if ( fi.exists() ) {
Packit Service 50c9f2
	  if ( fi.isDir() )
Packit Service 50c9f2
	      qWarning( "Cannot cd into \"%s\".", (char*)d.absFilePath("c++") );
Packit Service 50c9f2
	  else
Packit Service 50c9f2
	      qWarning( "Cannot create directory \"%s\"\n"
Packit Service 50c9f2
		       "A file named \"c++\" already exists in \"%s\"",
Packit Service 50c9f2
		       (const char *)d.absFilePath("c++"),
Packit Service 50c9f2
		       (const char *)d.path() );
Packit Service 50c9f2
	  return;
Packit Service 50c9f2
      } else {
Packit Service 50c9f2
	  qWarning( "Creating directory \"%s\"",
Packit Service 50c9f2
		   (const char *) d.absFilePath("c++") );
Packit Service 50c9f2
	  if ( !d.mkdir( "c++" ) ) {
Packit Service 50c9f2
	      qWarning("Could not create directory \"%s\"",
Packit Service 50c9f2
		      (const char *)d.absFilePath("c++") );
Packit Service 50c9f2
	      return;
Packit Service 50c9f2
	  }
Packit Service 50c9f2
      }
Packit Service 50c9f2
  }
Packit Service 50c9f2
  \endcode
Packit Service 50c9f2
Packit Service 50c9f2
  Calling cd( ".." ) is equivalent to calling cdUp().
Packit Service 50c9f2
Packit Service 50c9f2
  \sa cdUp(), isReadable(), exists(), path()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
bool QDir::cd( const QString &dirName, bool acceptAbsPath )
Packit Service 50c9f2
{
Packit Service 50c9f2
    if ( dirName.isEmpty() || dirName==QString::fromLatin1(".") )
Packit Service 50c9f2
	return TRUE;
Packit Service 50c9f2
    QString old = dPath;
Packit Service 50c9f2
    if ( acceptAbsPath && !isRelativePath(dirName) ) {
Packit Service 50c9f2
	dPath = cleanDirPath( dirName );
Packit Service 50c9f2
    } else {
Packit Service 50c9f2
	if ( !isRoot() )
Packit Service 50c9f2
	    dPath += '/';
Packit Service 50c9f2
	dPath += dirName;
Packit Service 50c9f2
	if ( dirName.find('/') >= 0
Packit Service 50c9f2
		|| old == QString::fromLatin1(".")
Packit Service 50c9f2
		|| dirName == QString::fromLatin1("..") )
Packit Service 50c9f2
	    dPath = cleanDirPath( dPath );
Packit Service 50c9f2
    }
Packit Service 50c9f2
    if ( !exists() ) {
Packit Service 50c9f2
	dPath = old;			// regret
Packit Service 50c9f2
	return FALSE;
Packit Service 50c9f2
    }
Packit Service 50c9f2
    dirty = TRUE;
Packit Service 50c9f2
    return TRUE;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Changes directory by moving one directory up the path followed to arrive
Packit Service 50c9f2
  at the current directory.
Packit Service 50c9f2
Packit Service 50c9f2
  Returns TRUE if the new directory exists and is readable. Note that the
Packit Service 50c9f2
  logical cdUp() operation is not performed if the new directory does not
Packit Service 50c9f2
  exist.
Packit Service 50c9f2
Packit Service 50c9f2
  \sa cd(), isReadable(), exists(), path()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
bool QDir::cdUp()
Packit Service 50c9f2
{
Packit Service 50c9f2
    return cd( QString::fromLatin1("..") );
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  \fn QString QDir::nameFilter() const
Packit Service 50c9f2
  Returns the string set by setNameFilter()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  Sets the name filter used by entryList() and entryInfoList().
Packit Service 50c9f2
Packit Service 50c9f2
  The name filter is a wildcarding filter that understands "*" and "?"
Packit Service 50c9f2
  wildcards, You may specify several filter entries separated by a " " or a ";". If
Packit Service 50c9f2
  you want entryList() and entryInfoList() to list all files ending with
Packit Service 50c9f2
  ".cpp" and all files ending with ".h", you simply call
Packit Service 50c9f2
  dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h")
Packit Service 50c9f2
Packit Service 50c9f2
  \sa nameFilter(), setFilter()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
void QDir::setNameFilter( const QString &nameFilter )
Packit Service 50c9f2
{
Packit Service 50c9f2
    nameFilt = nameFilter;
Packit Service 50c9f2
    if ( nameFilt.isEmpty() )
Packit Service 50c9f2
	nameFilt = QString::fromLatin1("*");
Packit Service 50c9f2
    dirty = TRUE;
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
/*!
Packit Service 50c9f2
  \fn QDir::FilterSpec QDir::filter() const
Packit Service 50c9f2
  Returns the value set by setFilter()
Packit Service 50c9f2
*/
Packit Service 50c9f2
Packit Service 50c9f2
/*! \enum QDir::FilterSpec
Packit Service 50c9f2
Packit Service 50c9f2
  This enum describes how QDir is to select what entries in a
Packit Service 50c9f2
  directory to return.  The filter value is specified by or-ing
Packit Service 50c9f2
  together values from the following list: 
    Packit Service 50c9f2
    Packit Service 50c9f2
      
  • \c Dirs - List directories only
  • Packit Service 50c9f2
      
  • \c Files - List files only
  • Packit Service 50c9f2
    Packit Service 50c9f2
      
  • \c Drives - List disk drives (does nothing under unix)
  • Packit Service 50c9f2
      
  • \c NoSymLinks - Do not list symbolic links (where they exist)
  • Packit Service 50c9f2
      
  • \c Readable - List files for which the application has read access.
  • Packit Service 50c9f2
      
  • \c Writable - List files for which the application has write access.
  • Packit Service 50c9f2
      
  • \c Executable - List files for which the application has execute access
  • Packit Service 50c9f2
      
  • \c Modified - Only list files that have been modified (does nothing
  • Packit Service 50c9f2
      under unix)
    Packit Service 50c9f2
      
  • \c Hidden - List hidden files (on unix, files starting with a .)
  • Packit Service 50c9f2
      
  • \c System - List system files (does nothing under unix)
  • Packit Service 50c9f2
      
    Packit Service 50c9f2
    Packit Service 50c9f2
      If you do not set any of \c Readable, \c Writable or \c Executable,
    Packit Service 50c9f2
      QDir will set all three of them.  This makes the default easy to
    Packit Service 50c9f2
      write and at the same time useful.
    Packit Service 50c9f2
    Packit Service 50c9f2
      Examples: \c Readable|Writable means list all files for which the
    Packit Service 50c9f2
      application has read access, write access or both.  \c Dirs|Drives
    Packit Service 50c9f2
      means list drives, directories, all files that the application can
    Packit Service 50c9f2
      read, write or execute, and also symlinks to such files/directories.
    Packit Service 50c9f2
    */
    Packit Service 50c9f2
    Packit Service 50c9f2
    Packit Service 50c9f2
    /*!
    Packit Service 50c9f2
      Sets the filter used by entryList() and entryInfoList(). The filter is used
    Packit Service 50c9f2
      to specify the kind of files that should be returned by entryList() and
    Packit Service 50c9f2
      entryInfoList().
    Packit Service 50c9f2
    Packit Service 50c9f2
      \sa filter(), setNameFilter()
    Packit Service 50c9f2
    */
    Packit Service 50c9f2
    Packit Service 50c9f2
    void QDir::setFilter( int filterSpec )
    Packit Service 50c9f2
    {
    Packit Service 50c9f2
        if ( filtS == (FilterSpec) filterSpec )
    Packit Service 50c9f2
    	return;
    Packit Service 50c9f2
        filtS = (FilterSpec) filterSpec;
    Packit Service 50c9f2
        dirty = TRUE;
    Packit Service 50c9f2
    }
    Packit Service 50c9f2
    Packit Service 50c9f2
    /*!
    Packit Service 50c9f2
      \fn QDir::SortSpec QDir::sorting() const
    Packit Service 50c9f2
    Packit Service 50c9f2
      Returns the value set by setSorting()
    Packit Service 50c9f2
    Packit Service 50c9f2
      \sa setSorting()
    Packit Service 50c9f2
    */
    Packit Service 50c9f2
    Packit Service 50c9f2
    /*! \enum QDir::SortSpec
    Packit Service 50c9f2
    Packit Service 50c9f2
      This enum describes how QDir is to sort entries in a directory when
    Packit Service 50c9f2
      it returns a list of them.  The sort value is specified by or-ing
    Packit Service 50c9f2
      together values from the following list: 
      Packit Service 50c9f2
      Packit Service 50c9f2
        
    • \c Name - sort by name
    • Packit Service 50c9f2
        
    • \c Time - sort by time (modification time)
    • Packit Service 50c9f2
        
    • \c Size - sort by file size
    • Packit Service 50c9f2
        
    • \c Unsorted - do not sort
    • Packit Service 50c9f2
      Packit Service 50c9f2
        
    • \c DirsFirst - put all directories first in the list
    • Packit Service 50c9f2
        
    • \c Reversed - reverse the sort order
    • Packit Service 50c9f2
        
    • \c IgnoreCase - sort case-insensitively
    • Packit Service 50c9f2
      Packit Service 50c9f2
        
      Packit Service 50c9f2
      Packit Service 50c9f2
        You can only specify one of the first four.  If you specify both \c
      Packit Service 50c9f2
        DirsFirst and \c Reversed, directories are still put first but the
      Packit Service 50c9f2
        list is otherwise reversed.
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      // ### Unsorted+DirsFirst ? Unsorted+Reversed?
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Sets the sorting order used by entryList() and entryInfoList().
      Packit Service 50c9f2
      Packit Service 50c9f2
        The \e sortSpec is specified by or-ing values from the enum
      Packit Service 50c9f2
        SortSpec. The different values are:
      Packit Service 50c9f2
      Packit Service 50c9f2
        One of these:
      Packit Service 50c9f2
        
      Packit Service 50c9f2
        
      Name
      Sort by name (alphabetical order).
      Packit Service 50c9f2
        
      Time
      Sort by time (most recent first).
      Packit Service 50c9f2
        
      Size
      Sort by size (largest first).
      Packit Service 50c9f2
        
      Unsorted
      Use the operating system order (UNIX does NOT sort
      Packit Service 50c9f2
        alphabetically).
      Packit Service 50c9f2
      Packit Service 50c9f2
        ORed with zero or more of these:
      Packit Service 50c9f2
      Packit Service 50c9f2
        
      DirsFirst
      Always put directory names first.
      Packit Service 50c9f2
        
      Reversed
      Reverse sort order.
      Packit Service 50c9f2
        
      IgnoreCase
      Ignore case when sorting by name.
      Packit Service 50c9f2
        
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      void QDir::setSorting( int sortSpec )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( sortS == (SortSpec) sortSpec )
      Packit Service 50c9f2
      	return;
      Packit Service 50c9f2
          sortS = (SortSpec) sortSpec;
      Packit Service 50c9f2
          dirty = TRUE;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        \fn bool QDir::matchAllDirs() const
      Packit Service 50c9f2
        Returns the value set by setMatchAllDirs()
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa setMatchAllDirs()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        If \e enable is TRUE, all directories will be listed (even if they do not
      Packit Service 50c9f2
        match the filter or the name filter), otherwise only matched directories
      Packit Service 50c9f2
        will be listed.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \bug Currently, directories that do not match the filter will not be
      Packit Service 50c9f2
        included (the name filter will be ignored as expected).
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa matchAllDirs()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      void QDir::setMatchAllDirs( bool enable )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( (bool)allDirs == enable )
      Packit Service 50c9f2
      	return;
      Packit Service 50c9f2
          allDirs = enable;
      Packit Service 50c9f2
          dirty = TRUE;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns the number of files that was found.
      Packit Service 50c9f2
        Equivalent to entryList().count().
      Packit Service 50c9f2
        \sa operator[](), entryList()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      uint QDir::count() const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          return entryList().count();
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns the file name at position \e index in the list of found file
      Packit Service 50c9f2
        names.
      Packit Service 50c9f2
        Equivalent to entryList().at(index).
      Packit Service 50c9f2
      Packit Service 50c9f2
        Returns null if the \e index is out of range or if the entryList()
      Packit Service 50c9f2
        function failed.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa count(), entryList()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QString QDir::operator[]( int index ) const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          entryList();
      Packit Service 50c9f2
          return fList && index >= 0 && index < (int)fList->count() ?
      Packit Service 50c9f2
      	(*fList)[index] : QString::null;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        This function is included to easy porting from Qt 1.x to Qt 2.0,
      Packit Service 50c9f2
        it is the same as entryList(), but encodes the filenames as 8-bit
      Packit Service 50c9f2
        strings using QFile::encodedName().
      Packit Service 50c9f2
      Packit Service 50c9f2
        It is more efficient to use entryList().
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      QStrList QDir::encodedEntryList( int filterSpec, int sortSpec ) const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          QStrList r;
      Packit Service 50c9f2
          QStringList l = entryList(filterSpec,sortSpec);
      Packit Service 50c9f2
          for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
      Packit Service 50c9f2
      	r.append( QFile::encodeName(*it) );
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
          return r;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        This function is included to easy porting from Qt 1.x to Qt 2.0,
      Packit Service 50c9f2
        it is the same as entryList(), but encodes the filenames as 8-bit
      Packit Service 50c9f2
        strings using QFile::encodedName().
      Packit Service 50c9f2
      Packit Service 50c9f2
        It is more efficient to use entryList().
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      QStrList QDir::encodedEntryList( const QString &nameFilter,
      Packit Service 50c9f2
      			   int filterSpec,
      Packit Service 50c9f2
      			   int sortSpec ) const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          QStrList r;
      Packit Service 50c9f2
          QStringList l = entryList(nameFilter,filterSpec,sortSpec);
      Packit Service 50c9f2
          for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
      Packit Service 50c9f2
      	r.append( QFile::encodeName(*it) );
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
          return r;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns a list of the names of all files and directories in the directory
      Packit Service 50c9f2
        indicated by the setSorting(), setFilter() and setNameFilter()
      Packit Service 50c9f2
        specifications.
      Packit Service 50c9f2
      Packit Service 50c9f2
        The the filter and sorting specifications can be overridden using the
      Packit Service 50c9f2
        \e filterSpec and \e sortSpec arguments.
      Packit Service 50c9f2
      Packit Service 50c9f2
        Returns an empty list if the directory is unreadable or does not exist.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa entryInfoList(), setNameFilter(), setSorting(), setFilter(),
      Packit Service 50c9f2
      	encodedEntryList()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QStringList QDir::entryList( int filterSpec, int sortSpec ) const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( !dirty && filterSpec == (int)DefaultFilter &&
      Packit Service 50c9f2
      		   sortSpec   == (int)DefaultSort )
      Packit Service 50c9f2
      	return *fList;
      Packit Service 50c9f2
          return entryList( nameFilt, filterSpec, sortSpec );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns a list of the names of all files and directories in the directory
      Packit Service 50c9f2
        indicated by the setSorting(), setFilter() and setNameFilter()
      Packit Service 50c9f2
        specifications.
      Packit Service 50c9f2
      Packit Service 50c9f2
        The the filter and sorting specifications can be overridden using the
      Packit Service 50c9f2
        \e nameFilter, \e filterSpec and \e sortSpec arguments.
      Packit Service 50c9f2
      Packit Service 50c9f2
        Returns and empty list if the directory is unreadable or does not exist.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa entryInfoList(), setNameFilter(), setSorting(), setFilter(),
      Packit Service 50c9f2
      	encodedEntryList()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QStringList QDir::entryList( const QString &nameFilter,
      Packit Service 50c9f2
      				 int filterSpec, int sortSpec ) const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( filterSpec == (int)DefaultFilter )
      Packit Service 50c9f2
      	filterSpec = filtS;
      Packit Service 50c9f2
          if ( sortSpec == (int)DefaultSort )
      Packit Service 50c9f2
      	sortSpec = sortS;
      Packit Service 50c9f2
          QDir *that = (QDir*)this;			// mutable function
      Packit Service 50c9f2
          if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) )
      Packit Service 50c9f2
      	return *that->fList;
      Packit Service 50c9f2
          else
      Packit Service 50c9f2
      	return QStringList();
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns a list of QFileInfo objects for all files and directories in
      Packit Service 50c9f2
        the directory pointed to using the setSorting(), setFilter() and
      Packit Service 50c9f2
        setNameFilter() specifications.
      Packit Service 50c9f2
      Packit Service 50c9f2
        The the filter and sorting specifications can be overridden using the
      Packit Service 50c9f2
        \e filterSpec and \e sortSpec arguments.
      Packit Service 50c9f2
      Packit Service 50c9f2
        Returns 0 if the directory is unreadable or does not exist.
      Packit Service 50c9f2
      Packit Service 50c9f2
        The returned pointer is a const pointer to a QFileInfoList. The list is
      Packit Service 50c9f2
        owned by the QDir object and will be reused on the next call to
      Packit Service 50c9f2
        entryInfoList() for the same QDir instance. If you want to keep the
      Packit Service 50c9f2
        entries of the list after a subsequent call to this function you will
      Packit Service 50c9f2
        need to copy them.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa entryList(), setNameFilter(), setSorting(), setFilter()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      const QFileInfoList *QDir::entryInfoList( int filterSpec, int sortSpec ) const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( !dirty && filterSpec == (int)DefaultFilter &&
      Packit Service 50c9f2
      		   sortSpec   == (int)DefaultSort )
      Packit Service 50c9f2
      	return fiList;
      Packit Service 50c9f2
          return entryInfoList( nameFilt, filterSpec, sortSpec );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns a list of QFileInfo objects for all files and directories in
      Packit Service 50c9f2
        the directory pointed to using the setSorting(), setFilter() and
      Packit Service 50c9f2
        setNameFilter() specifications.
      Packit Service 50c9f2
      Packit Service 50c9f2
        The the filter and sorting specifications can be overridden using the
      Packit Service 50c9f2
        \e nameFilter, \e filterSpec and \e sortSpec arguments.
      Packit Service 50c9f2
      Packit Service 50c9f2
        Returns 0 if the directory is unreadable or does not exist.
      Packit Service 50c9f2
      Packit Service 50c9f2
        The returned pointer is a const pointer to a QFileInfoList. The list is
      Packit Service 50c9f2
        owned by the QDir object and will be reused on the next call to
      Packit Service 50c9f2
        entryInfoList() for the same QDir instance. If you want to keep the
      Packit Service 50c9f2
        entries of the list after a subsequent call to this function you will
      Packit Service 50c9f2
        need to copy them.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa entryList(), setNameFilter(), setSorting(), setFilter()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      const QFileInfoList *QDir::entryInfoList( const QString &nameFilter,
      Packit Service 50c9f2
      					  int filterSpec, int sortSpec ) const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( filterSpec == (int)DefaultFilter )
      Packit Service 50c9f2
      	filterSpec = filtS;
      Packit Service 50c9f2
          if ( sortSpec == (int)DefaultSort )
      Packit Service 50c9f2
      	sortSpec = sortS;
      Packit Service 50c9f2
          QDir *that = (QDir*)this;			// mutable function
      Packit Service 50c9f2
          if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) )
      Packit Service 50c9f2
      	return that->fiList;
      Packit Service 50c9f2
          else
      Packit Service 50c9f2
      	return 0;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns TRUE if the directory exists. (If a file with the same
      Packit Service 50c9f2
        name is found this function will of course return FALSE).
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa QFileInfo::exists(), QFile::exists()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      bool QDir::exists() const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          QFileInfo fi( dPath );
      Packit Service 50c9f2
          return fi.exists() && fi.isDir();
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns TRUE if the directory path is relative to the current directory,
      Packit Service 50c9f2
        FALSE if the path is absolute (e.g. under UNIX a path is relative if it
      Packit Service 50c9f2
        does not start with a '/').
      Packit Service 50c9f2
      Packit Service 50c9f2
        According to Einstein this function should always return TRUE.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa convertToAbs()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      bool QDir::isRelative() const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          return isRelativePath( dPath );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Converts the directory path to an absolute path. If it is already
      Packit Service 50c9f2
        absolute nothing is done.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa isRelative()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      void QDir::convertToAbs()
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          dPath = absPath();
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Makes a copy of d and assigns it to this QDir.
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QDir &QDir::operator=( const QDir &d )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          dPath    = d.dPath;
      Packit Service 50c9f2
          delete fList;
      Packit Service 50c9f2
          fList    = 0;
      Packit Service 50c9f2
          delete fiList;
      Packit Service 50c9f2
          fiList   = 0;
      Packit Service 50c9f2
          nameFilt = d.nameFilt;
      Packit Service 50c9f2
          dirty    = TRUE;
      Packit Service 50c9f2
          allDirs  = d.allDirs;
      Packit Service 50c9f2
          filtS    = d.filtS;
      Packit Service 50c9f2
          sortS    = d.sortS;
      Packit Service 50c9f2
          return *this;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Sets the directory path to be the given path.
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QDir &QDir::operator=( const QString &path )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          dPath = cleanDirPath( path );
      Packit Service 50c9f2
          dirty = TRUE;
      Packit Service 50c9f2
          return *this;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        \fn bool QDir::operator!=( const QDir &d ) const
      Packit Service 50c9f2
        Returns TRUE if the \e d and this dir have different path or
      Packit Service 50c9f2
        different sort/filter settings, otherwise FALSE.
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns TRUE if the \e d and this dir have the same path and all sort
      Packit Service 50c9f2
        and filter settings are equal, otherwise FALSE.
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      bool QDir::operator==( const QDir &d ) const
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          return dPath    == d.dPath &&
      Packit Service 50c9f2
      	   nameFilt == d.nameFilt &&
      Packit Service 50c9f2
      	   allDirs  == d.allDirs &&
      Packit Service 50c9f2
      	   filtS    == d.filtS &&
      Packit Service 50c9f2
      	   sortS    == d.sortS;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Removes a file.
      Packit Service 50c9f2
      Packit Service 50c9f2
        If \e acceptAbsPath is TRUE a path starting with a separator ('/')
      Packit Service 50c9f2
        will remove the file with the absolute path, if \e acceptAbsPath is FALSE
      Packit Service 50c9f2
        any number of separators at the beginning of \e fileName will be removed.
      Packit Service 50c9f2
      Packit Service 50c9f2
        Returns TRUE if successful, otherwise FALSE.
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      bool QDir::remove( const QString &fileName, bool acceptAbsPath )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( fileName.isEmpty() ) {
      Packit Service 50c9f2
      #if defined(CHECK_NULL)
      Packit Service 50c9f2
      	qWarning( "QDir::remove: Empty or null file name" );
      Packit Service 50c9f2
      #endif
      Packit Service 50c9f2
      	return FALSE;
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
          QString p = filePath( fileName, acceptAbsPath );
      Packit Service 50c9f2
          return QFile::remove( p );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Checks for existence of a file.
      Packit Service 50c9f2
      Packit Service 50c9f2
        If \e acceptAbsPaths is TRUE a path starting with a separator ('/')
      Packit Service 50c9f2
        will check the file with the absolute path, if \e acceptAbsPath is FALSE
      Packit Service 50c9f2
        any number of separators at the beginning of \e name will be removed.
      Packit Service 50c9f2
      Packit Service 50c9f2
        Returns TRUE if the file exists, otherwise FALSE.
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa QFileInfo::exists(), QFile::exists()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      bool QDir::exists( const QString &name, bool acceptAbsPath )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( name.isEmpty() ) {
      Packit Service 50c9f2
      #if defined(CHECK_NULL)
      Packit Service 50c9f2
      	qWarning( "QDir::exists: Empty or null file name" );
      Packit Service 50c9f2
      #endif
      Packit Service 50c9f2
      	return FALSE;
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
          QString tmp = filePath( name, acceptAbsPath );
      Packit Service 50c9f2
          return QFile::exists( tmp );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns the native directory separator; '/' under UNIX and '\' under
      Packit Service 50c9f2
        MS-DOS, Windows NT and OS/2.
      Packit Service 50c9f2
      Packit Service 50c9f2
        You do not need to use this function to build file paths. If you always
      Packit Service 50c9f2
        use '/', Qt will translate your paths to conform to the underlying
      Packit Service 50c9f2
        operating system.
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      char QDir::separator()
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
      #if defined(_OS_UNIX_)
      Packit Service 50c9f2
          return '/';
      Packit Service 50c9f2
      #elif defined (_OS_FATFS_)
      Packit Service 50c9f2
          return '\\';
      Packit Service 50c9f2
      #elif defined (_OS_MAC_)
      Packit Service 50c9f2
          return ':';
      Packit Service 50c9f2
      #else
      Packit Service 50c9f2
          return '/';
      Packit Service 50c9f2
      #endif
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns the current directory.
      Packit Service 50c9f2
        \sa currentDirPath(), QDir::QDir()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QDir QDir::current()
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          return QDir( currentDirPath() );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns the home directory.
      Packit Service 50c9f2
        \sa homeDirPath()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QDir QDir::home()
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          return QDir( homeDirPath() );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns the root directory.
      Packit Service 50c9f2
        \sa rootDirPath() drives()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QDir QDir::root()
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          return QDir( rootDirPath() );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        \fn QString QDir::homeDirPath()
      Packit Service 50c9f2
      Packit Service 50c9f2
        Returns the absolute path for the user's home directory,
      Packit Service 50c9f2
        \sa home()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QStringList qt_makeFilterList( const QString &filter )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( filter.isEmpty() )
      Packit Service 50c9f2
      	return QStringList();
      Packit Service 50c9f2
      Packit Service 50c9f2
          QChar sep( ';' );
      Packit Service 50c9f2
          int i = filter.find( sep, 0 );
      Packit Service 50c9f2
          if ( i == -1 && filter.find( ' ', 0 ) != -1 )
      Packit Service 50c9f2
      	sep = QChar( ' ' );
      Packit Service 50c9f2
      Packit Service 50c9f2
          QStringList lst = QStringList::split( sep, filter );
      Packit Service 50c9f2
          QStringList lst2;
      Packit Service 50c9f2
          QStringList::Iterator it = lst.begin();
      Packit Service 50c9f2
      Packit Service 50c9f2
          for ( ; it != lst.end(); ++it ) {
      Packit Service 50c9f2
      	QString s = *it;
      Packit Service 50c9f2
      	lst2 << s.stripWhiteSpace();
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
          return lst2;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns TRUE if the \e fileName matches one of the wildcards in the list \e filters.
      Packit Service 50c9f2
        \sa QRegExp
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      bool QDir::match( const QStringList &filters, const QString &fileName )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          QStringList::ConstIterator sit = filters.begin();
      Packit Service 50c9f2
          bool matched = FALSE;
      Packit Service 50c9f2
          for ( ; sit != filters.end(); ++sit ) {
      Packit Service 50c9f2
      	QRegExp regexp( (*sit).data(), FALSE, TRUE );
      Packit Service 50c9f2
      	if ( regexp.match( fileName.data() ) != -1 ) {
      Packit Service 50c9f2
      	    matched = TRUE;
      Packit Service 50c9f2
      	    break;
      Packit Service 50c9f2
      	}
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
      Packit Service 50c9f2
          return matched;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Returns TRUE if the \e fileName matches the wildcard \e filter.
      Packit Service 50c9f2
        \a Filter may also contain multiple wildcards separated by spaces or
      Packit Service 50c9f2
        semicolons.
      Packit Service 50c9f2
        \sa QRegExp
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      bool QDir::match( const QString &filter, const QString &fileName )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          QStringList lst = qt_makeFilterList( filter );
      Packit Service 50c9f2
          return match( lst, fileName );
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      Packit Service 50c9f2
      /*!
      Packit Service 50c9f2
        Removes all multiple directory separators ('/') and resolves
      Packit Service 50c9f2
        any "." or ".." found in the path.
      Packit Service 50c9f2
      Packit Service 50c9f2
        Symbolic links are kept.  This function does not return the
      Packit Service 50c9f2
        canonical path, but rather the most simplified version of the input.
      Packit Service 50c9f2
        "../stuff" becomes "stuff", "stuff/../nonsense" becomes "nonsense"
      Packit Service 50c9f2
        and "\\stuff\\more\\..\\nonsense" becomes "\\stuff\\nonsense".
      Packit Service 50c9f2
      Packit Service 50c9f2
        \sa absPath() canonicalPath()
      Packit Service 50c9f2
      */
      Packit Service 50c9f2
      Packit Service 50c9f2
      QString QDir::cleanDirPath( const QString &filePath )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          QString name = filePath;
      Packit Service 50c9f2
          QString newPath;
      Packit Service 50c9f2
      Packit Service 50c9f2
          if ( name.isEmpty() )
      Packit Service 50c9f2
      	return name;
      Packit Service 50c9f2
      Packit Service 50c9f2
          slashify( name );
      Packit Service 50c9f2
      Packit Service 50c9f2
          bool addedSeparator;
      Packit Service 50c9f2
          if ( isRelativePath(name) ) {
      Packit Service 50c9f2
      	addedSeparator = TRUE;
      Packit Service 50c9f2
      	name.insert( 0, '/' );
      Packit Service 50c9f2
          } else {
      Packit Service 50c9f2
      	addedSeparator = FALSE;
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
      Packit Service 50c9f2
          int ePos, pos, upLevel;
      Packit Service 50c9f2
      Packit Service 50c9f2
          pos = ePos = name.length();
      Packit Service 50c9f2
          upLevel = 0;
      Packit Service 50c9f2
          int len;
      Packit Service 50c9f2
      Packit Service 50c9f2
          while ( pos && (pos = name.findRev('/',--pos)) != -1 ) {
      Packit Service 50c9f2
      	len = ePos - pos - 1;
      Packit Service 50c9f2
      	if ( len == 2 && name.at(pos + 1) == '.'
      Packit Service 50c9f2
      		      && name.at(pos + 2) == '.' ) {
      Packit Service 50c9f2
      	    upLevel++;
      Packit Service 50c9f2
      	} else {
      Packit Service 50c9f2
      	    if ( len != 0 && (len != 1 || name.at(pos + 1) != '.') ) {
      Packit Service 50c9f2
      		if ( !upLevel )
      Packit Service 50c9f2
      		    newPath = QString::fromLatin1("/")
      Packit Service 50c9f2
      			+ name.mid(pos + 1, len) + newPath;
      Packit Service 50c9f2
      		else
      Packit Service 50c9f2
      		    upLevel--;
      Packit Service 50c9f2
      	    }
      Packit Service 50c9f2
      	}
      Packit Service 50c9f2
      	ePos = pos;
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
          if ( addedSeparator ) {
      Packit Service 50c9f2
      	while ( upLevel-- )
      Packit Service 50c9f2
      	    newPath.insert( 0, QString::fromLatin1("/..") );
      Packit Service 50c9f2
      	if ( !newPath.isEmpty() )
      Packit Service 50c9f2
      	    newPath.remove( 0, 1 );
      Packit Service 50c9f2
      	else
      Packit Service 50c9f2
      	    newPath = QString::fromLatin1(".");
      Packit Service 50c9f2
          } else {
      Packit Service 50c9f2
      	if ( newPath.isEmpty() )
      Packit Service 50c9f2
      	    newPath = QString::fromLatin1("/");
      Packit Service 50c9f2
      #if defined(_OS_FATFS_) || defined(_OS_OS2EMX_)
      Packit Service 50c9f2
      	if ( name[0] == '/' ) {
      Packit Service 50c9f2
      	    if ( name[1] == '/' )		// "\\machine\x\ ..."
      Packit Service 50c9f2
      		newPath.insert( 0, '/' );
      Packit Service 50c9f2
      	} else {
      Packit Service 50c9f2
      	    newPath = name.left(2) + newPath;
      Packit Service 50c9f2
      	}
      Packit Service 50c9f2
      #endif
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
          return newPath;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      int qt_cmp_si_sortSpec;
      Packit Service 50c9f2
      Packit Service 50c9f2
      #if defined(Q_C_CALLBACKS)
      Packit Service 50c9f2
      extern "C" {
      Packit Service 50c9f2
      #endif
      Packit Service 50c9f2
      Packit Service 50c9f2
      int qt_cmp_si( const void *n1, const void *n2 )
      Packit Service 50c9f2
      {
      Packit Service 50c9f2
          if ( !n1 || !n2 )
      Packit Service 50c9f2
      	return 0;
      Packit Service 50c9f2
      Packit Service 50c9f2
          QDirSortItem* f1 = (QDirSortItem*)n1;
      Packit Service 50c9f2
          QDirSortItem* f2 = (QDirSortItem*)n2;
      Packit Service 50c9f2
      Packit Service 50c9f2
          if ( qt_cmp_si_sortSpec & QDir::DirsFirst )
      Packit Service 50c9f2
      	if ( f1->item->isDir() != f2->item->isDir() )
      Packit Service 50c9f2
      	    return f1->item->isDir() ? -1 : 1;
      Packit Service 50c9f2
      Packit Service 50c9f2
          int r = 0;
      Packit Service 50c9f2
          int sortBy = qt_cmp_si_sortSpec & QDir::SortByMask;
      Packit Service 50c9f2
      Packit Service 50c9f2
          switch ( sortBy ) {
      Packit Service 50c9f2
            case QDir::Time:
      Packit Service 50c9f2
      	r = f1->item->lastModified().secsTo(f2->item->lastModified());
      Packit Service 50c9f2
      	break;
      Packit Service 50c9f2
            case QDir::Size:
      Packit Service 50c9f2
      	r = f2->item->size() - f1->item->size();
      Packit Service 50c9f2
      	break;
      Packit Service 50c9f2
            default:
      Packit Service 50c9f2
      	;
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
      Packit Service 50c9f2
          if ( r == 0 && sortBy != QDir::Unsorted ) {
      Packit Service 50c9f2
      	// Still not sorted - sort by name
      Packit Service 50c9f2
      	bool ic = qt_cmp_si_sortSpec & QDir::IgnoreCase;
      Packit Service 50c9f2
      Packit Service 50c9f2
      	if ( f1->filename_cache.isNull() )
      Packit Service 50c9f2
      	    f1->filename_cache = ic ? f1->item->fileName().lower()
      Packit Service 50c9f2
      				    : f1->item->fileName();
      Packit Service 50c9f2
      	if ( f2->filename_cache.isNull() )
      Packit Service 50c9f2
      	    f2->filename_cache = ic ? f2->item->fileName().lower()
      Packit Service 50c9f2
      				    : f2->item->fileName();
      Packit Service 50c9f2
      Packit Service 50c9f2
      	r = f1->filename_cache.compare(f2->filename_cache);
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
      Packit Service 50c9f2
          if ( r == 0 ) {
      Packit Service 50c9f2
      	// Enforce an order - the order the items appear in the array
      Packit Service 50c9f2
      	r = (int)((char*)n1 - (char*)n2);
      Packit Service 50c9f2
          }
      Packit Service 50c9f2
      Packit Service 50c9f2
          if ( qt_cmp_si_sortSpec & QDir::Reversed )
      Packit Service 50c9f2
      	return -r;
      Packit Service 50c9f2
          else
      Packit Service 50c9f2
      	return r;
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      Packit Service 50c9f2
      #if defined(Q_C_CALLBACKS)
      Packit Service 50c9f2
      }
      Packit Service 50c9f2
      #endif
      Packit Service 50c9f2
      Packit Service 50c9f2
      #endif // QT_NO_DIR