Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qdir.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of QDir class 00005 ** 00006 ** Created : 950427 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. 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 ASA 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 template <class T> class QDeepCopy; 00053 00054 00055 class Q_EXPORT QDir 00056 { 00057 public: 00058 enum FilterSpec { Dirs = 0x001, 00059 Files = 0x002, 00060 Drives = 0x004, 00061 NoSymLinks = 0x008, 00062 All = 0x007, 00063 TypeMask = 0x00F, 00064 00065 Readable = 0x010, 00066 Writable = 0x020, 00067 Executable = 0x040, 00068 RWEMask = 0x070, 00069 00070 Modified = 0x080, 00071 Hidden = 0x100, 00072 System = 0x200, 00073 AccessMask = 0x3F0, 00074 00075 DefaultFilter = -1 00076 }; 00077 00078 enum SortSpec { Name = 0x00, 00079 Time = 0x01, 00080 Size = 0x02, 00081 Unsorted = 0x03, 00082 SortByMask = 0x03, 00083 00084 DirsFirst = 0x04, 00085 Reversed = 0x08, 00086 IgnoreCase = 0x10, 00087 LocaleAware = 0x20, 00088 DefaultSort = -1 00089 }; 00090 00091 QDir(); 00092 QDir(const QString &path, const QString &nameFilter = QString::null, 00093 int sortSpec = Name | IgnoreCase, int filterSpec = All); 00094 QDir(const QDir &); 00095 00096 virtual ~QDir(); 00097 00098 QDir &operator=(const QDir &); 00099 QDir &operator=(const QString &path); 00100 00101 virtual void setPath(const QString &path); 00102 virtual QString path() const; 00103 virtual QString absPath() const; 00104 virtual QString canonicalPath() const; 00105 00106 virtual QString dirName() const; 00107 virtual QString filePath(const QString &fileName, 00108 bool acceptAbsPath = TRUE) const; 00109 virtual QString absFilePath(const QString &fileName, 00110 bool acceptAbsPath = TRUE) const; 00111 00112 static QString convertSeparators(const QString &pathName); 00113 00114 virtual bool cd(const QString &dirName, bool acceptAbsPath = TRUE); 00115 virtual bool cdUp(); 00116 00117 QString nameFilter() const; 00118 virtual void setNameFilter(const QString &nameFilter); 00119 FilterSpec filter() const; 00120 virtual void setFilter(int filterSpec); 00121 SortSpec sorting() const; 00122 virtual void setSorting(int sortSpec); 00123 00124 bool matchAllDirs() const; 00125 virtual void setMatchAllDirs(bool); 00126 00127 uint count() const; 00128 QString operator[](int) const; 00129 00130 virtual QStrList encodedEntryList(int filterSpec = DefaultFilter, 00131 int sortSpec = DefaultSort) const; 00132 virtual QStrList encodedEntryList(const QString &nameFilter, 00133 int filterSpec = DefaultFilter, 00134 int sortSpec = DefaultSort) const; 00135 virtual QStringList entryList(int filterSpec = DefaultFilter, 00136 int sortSpec = DefaultSort) const; 00137 virtual QStringList entryList(const QString &nameFilter, 00138 int filterSpec = DefaultFilter, 00139 int sortSpec = DefaultSort) const; 00140 00141 virtual const QFileInfoList *entryInfoList(int filterSpec = DefaultFilter, 00142 int sortSpec = DefaultSort) const; 00143 virtual const QFileInfoList *entryInfoList(const QString &nameFilter, 00144 int filterSpec = DefaultFilter, 00145 int sortSpec = DefaultSort) const; 00146 00147 static const QFileInfoList *drives(); 00148 00149 virtual bool mkdir(const QString &dirName, 00150 bool acceptAbsPath = TRUE) const; 00151 virtual bool rmdir(const QString &dirName, 00152 bool acceptAbsPath = TRUE) const; 00153 00154 // ### AbanQ 00155 virtual bool mkpath(const QString &dirPath) const; 00156 virtual bool rmpath(const QString &dirPath) const; 00157 // ### AbanQ 00158 00159 virtual bool isReadable() const; 00160 virtual bool exists() const; 00161 virtual bool isRoot() const; 00162 00163 virtual bool isRelative() const; 00164 virtual void convertToAbs(); 00165 00166 virtual bool operator==(const QDir &) const; 00167 virtual bool operator!=(const QDir &) const; 00168 00169 virtual bool remove(const QString &fileName, 00170 bool acceptAbsPath = TRUE); 00171 virtual bool rename(const QString &name, const QString &newName, 00172 bool acceptAbsPaths = TRUE); 00173 virtual bool exists(const QString &name, 00174 bool acceptAbsPath = TRUE); 00175 00176 static char separator(); 00177 00178 static bool setCurrent(const QString &path); 00179 static QDir current(); 00180 static QDir home(); 00181 static QDir root(); 00182 static QString currentDirPath(); 00183 static QString homeDirPath(); 00184 static QString rootDirPath(); 00185 00186 static bool match(const QStringList &filters, const QString &fileName); 00187 static bool match(const QString &filter, const QString &fileName); 00188 static QString cleanDirPath(const QString &dirPath); 00189 static bool isRelativePath(const QString &path); 00190 void refresh() const; 00191 00192 private: 00193 #ifdef Q_OS_MAC 00194 typedef struct FSSpec FSSpec; 00195 static FSSpec *make_spec(const QString &); 00196 #endif 00197 void init(); 00198 virtual bool readDirEntries(const QString &nameFilter, 00199 int FilterSpec, int SortSpec); 00200 00201 static void slashify(QString &); 00202 00203 QString dPath; 00204 QStringList *fList; 00205 QFileInfoList *fiList; 00206 QString nameFilt; 00207 FilterSpec filtS; 00208 SortSpec sortS; 00209 uint dirty : 1; 00210 uint allDirs : 1; 00211 00212 void detach(); 00213 friend class QDeepCopy< QDir >; 00214 }; 00215 00216 00217 inline QString QDir::path() const 00218 { 00219 return dPath; 00220 } 00221 00222 inline QString QDir::nameFilter() const 00223 { 00224 return nameFilt; 00225 } 00226 00227 inline QDir::FilterSpec QDir::filter() const 00228 { 00229 return filtS; 00230 } 00231 00232 inline QDir::SortSpec QDir::sorting() const 00233 { 00234 return sortS; 00235 } 00236 00237 inline bool QDir::matchAllDirs() const 00238 { 00239 return allDirs; 00240 } 00241 00242 inline bool QDir::operator!=(const QDir &d) const 00243 { 00244 return !(*this == d); 00245 } 00246 00247 00248 struct QDirSortItem { 00249 QString filename_cache; 00250 QFileInfo *item; 00251 }; 00252 00253 #endif // QT_NO_DIR 00254 #endif // QDIR_H