Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qdir.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** $Id: qdir.h,v 1.2 2003/07/10 02:40:10 llornkcor Exp $
00003 **
00004 ** Definition of QDir class
00005 **
00006 ** Created : 950427
00007 **
00008 ** Copyright (C) 1992-2002 Trolltech AS.  All rights reserved.
00009 **
00010 ** This file is part of the tools module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech AS of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QDIR_H
00039 #define QDIR_H
00040 
00041 #ifndef QT_H
00042 #include "qglobal.h"
00043 #include "qstrlist.h"
00044 #include "qfileinfo.h"
00045 #endif // QT_H
00046 
00047 
00048 #ifndef QT_NO_DIR
00049 typedef QPtrList<QFileInfo> QFileInfoList;
00050 typedef QPtrListIterator<QFileInfo> QFileInfoListIterator;
00051 class QStringList;
00052 
00053 
00054 class Q_EXPORT QDir
00055 {
00056 public:
00057     enum FilterSpec { Dirs          = 0x001,
00058                       Files         = 0x002,
00059                       Drives        = 0x004,
00060                       NoSymLinks    = 0x008,
00061                       All           = 0x007,
00062                       TypeMask      = 0x00F,
00063 
00064                       Readable      = 0x010,
00065                       Writable      = 0x020,
00066                       Executable    = 0x040,
00067                       RWEMask       = 0x070,
00068 
00069                       Modified      = 0x080,
00070                       Hidden        = 0x100,
00071                       System        = 0x200,
00072                       AccessMask    = 0x3F0,
00073 
00074                       DefaultFilter = -1 };
00075 
00076     enum SortSpec   { Name          = 0x00,
00077                       Time          = 0x01,
00078                       Size          = 0x02,
00079                       Unsorted      = 0x03,
00080                       SortByMask    = 0x03,
00081 
00082                       DirsFirst     = 0x04,
00083                       Reversed      = 0x08,
00084                       IgnoreCase    = 0x10,
00085                       DefaultSort   = -1 };
00086 
00087     QDir();
00088     QDir( const QString &path, const QString &nameFilter = QString::null,
00089           int sortSpec = Name | IgnoreCase, int filterSpec = All );
00090     QDir( const QDir & );
00091 
00092     virtual ~QDir();
00093 
00094     QDir       &operator=( const QDir & );
00095     QDir       &operator=( const QString &path );
00096 
00097     virtual void setPath( const QString &path );
00098     virtual QString path()              const;
00099     virtual QString absPath()   const;
00100     virtual QString canonicalPath()     const;
00101 
00102     virtual QString dirName() const;
00103     virtual QString filePath( const QString &fileName,
00104                               bool acceptAbsPath = TRUE ) const;
00105     virtual QString absFilePath( const QString &fileName,
00106                                  bool acceptAbsPath = TRUE ) const;
00107 
00108     static QString convertSeparators( const QString &pathName );
00109 
00110     virtual bool cd( const QString &dirName, bool acceptAbsPath = TRUE );
00111     virtual bool cdUp();
00112 
00113     QString     nameFilter() const;
00114     virtual void setNameFilter( const QString &nameFilter );
00115     FilterSpec filter() const;
00116     virtual void setFilter( int filterSpec );
00117     SortSpec sorting() const;
00118     virtual void setSorting( int sortSpec );
00119 
00120     bool        matchAllDirs() const;
00121     virtual void setMatchAllDirs( bool );
00122 
00123     uint count() const;
00124     QString     operator[]( int ) const;
00125 
00126     virtual QStrList encodedEntryList( int filterSpec = DefaultFilter,
00127                                        int sortSpec   = DefaultSort  ) const;
00128     virtual QStrList encodedEntryList( const QString &nameFilter,
00129                                        int filterSpec = DefaultFilter,
00130                                        int sortSpec   = DefaultSort   ) const;
00131     virtual QStringList entryList( int filterSpec = DefaultFilter,
00132                                    int sortSpec   = DefaultSort  ) const;
00133     virtual QStringList entryList( const QString &nameFilter,
00134                                    int filterSpec = DefaultFilter,
00135                                    int sortSpec   = DefaultSort   ) const;
00136 
00137     virtual const QFileInfoList *entryInfoList( int filterSpec = DefaultFilter,
00138                                                 int sortSpec = DefaultSort ) const;
00139     virtual const QFileInfoList *entryInfoList( const QString &nameFilter,
00140                                                 int filterSpec = DefaultFilter,
00141                                                 int sortSpec = DefaultSort ) const;
00142 
00143     static const QFileInfoList *drives();
00144 
00145     virtual bool mkdir( const QString &dirName,
00146                         bool acceptAbsPath = TRUE ) const;
00147     virtual bool rmdir( const QString &dirName,
00148                         bool acceptAbsPath = TRUE ) const;
00149 
00150     virtual bool isReadable() const;
00151     virtual bool exists()   const;
00152     virtual bool isRoot()   const;
00153 
00154     virtual bool isRelative() const;
00155     virtual void convertToAbs();
00156 
00157     virtual bool operator==( const QDir & ) const;
00158     virtual bool operator!=( const QDir & ) const;
00159 
00160     virtual bool remove( const QString &fileName,
00161                          bool acceptAbsPath = TRUE );
00162     virtual bool rename( const QString &name, const QString &newName,
00163                          bool acceptAbsPaths = TRUE  );
00164     virtual bool exists( const QString &name,
00165                          bool acceptAbsPath = TRUE );
00166 
00167     static char separator();
00168 
00169     static bool setCurrent( const QString &path );
00170     static QDir current();
00171     static QDir home();
00172     static QDir root();
00173     static QString currentDirPath();
00174     static QString homeDirPath();
00175     static QString rootDirPath();
00176 
00177     static bool match( const QStringList &filters, const QString &fileName );
00178     static bool match( const QString &filter, const QString &fileName );
00179     static QString cleanDirPath( const QString &dirPath );
00180     static bool isRelativePath( const QString &path );
00181     void refresh() const;
00182 
00183 private:
00184 #ifdef Q_OS_MAC
00185     typedef struct FSSpec FSSpec;
00186     static FSSpec *make_spec(const QString &);
00187 #endif
00188     void init();
00189     virtual bool readDirEntries( const QString &nameFilter,
00190                                  int FilterSpec, int SortSpec  );
00191 
00192     static void slashify( QString & );
00193 
00194     QString     dPath;
00195     QStringList   *fList;
00196     QFileInfoList *fiList;
00197     QString     nameFilt;
00198     FilterSpec  filtS;
00199     SortSpec    sortS;
00200     uint        dirty   : 1;
00201     uint        allDirs : 1;
00202 };
00203 
00204 
00205 inline QString QDir::path() const
00206 {
00207     return dPath;
00208 }
00209 
00210 inline QString QDir::nameFilter() const
00211 {
00212     return nameFilt;
00213 }
00214 
00215 inline QDir::FilterSpec QDir::filter() const
00216 {
00217     return filtS;
00218 }
00219 
00220 inline QDir::SortSpec QDir::sorting() const
00221 {
00222     return sortS;
00223 }
00224 
00225 inline bool QDir::matchAllDirs() const
00226 {
00227     return allDirs;
00228 }
00229 
00230 inline bool QDir::operator!=( const QDir &d ) const
00231 {
00232     return !(*this == d);
00233 }
00234 
00235 
00236 struct QDirSortItem {
00237     QString filename_cache;
00238     QFileInfo* item;
00239 };
00240 
00241 #endif // QT_NO_DIR
00242 #endif // QDIR_H

Generated on Sat Nov 5 16:18:24 2005 for OPIE by  doxygen 1.4.2