Root/
Source at commit 1322 created 12 years 7 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | /****************************************************************************␊ |
2 | ** ␊ |
3 | **␊ |
4 | ** Definition of QDir class␊ |
5 | **␊ |
6 | ** Created : 950427␊ |
7 | **␊ |
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.␊ |
9 | **␊ |
10 | ** This file is part of the tools module of the Qt GUI Toolkit.␊ |
11 | **␊ |
12 | ** This file may be distributed under the terms of the Q Public License␊ |
13 | ** as defined by Trolltech AS of Norway and appearing in the file␊ |
14 | ** LICENSE.QPL included in the packaging of this file.␊ |
15 | **␊ |
16 | ** This file may be distributed and/or modified under the terms of the␊ |
17 | ** GNU General Public License version 2 as published by the Free Software␊ |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the␊ |
19 | ** packaging of this file.␊ |
20 | **␊ |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition␊ |
22 | ** licenses may use this file in accordance with the Qt Commercial License␊ |
23 | ** Agreement provided with the Software.␊ |
24 | **␊ |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE␊ |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.␊ |
27 | **␊ |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for␊ |
29 | ** information about Qt Commercial License Agreements.␊ |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.␊ |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.␊ |
32 | **␊ |
33 | ** Contact info@trolltech.com if any conditions of this licensing are␊ |
34 | ** not clear to you.␊ |
35 | **␊ |
36 | **********************************************************************/␊ |
37 | ␊ |
38 | #ifndef QDIR_H␊ |
39 | #define QDIR_H␊ |
40 | ␊ |
41 | #ifndef QT_H␊ |
42 | #include "qstrlist.h"␊ |
43 | #include "qfileinfo.h"␊ |
44 | #endif // QT_H␊ |
45 | ␊ |
46 | #ifndef QT_NO_DIR␊ |
47 | typedef QList<QFileInfo> QFileInfoList;␊ |
48 | typedef QListIterator<QFileInfo> QFileInfoListIterator;␊ |
49 | class QStringList;␊ |
50 | ␊ |
51 | ␊ |
52 | class Q_EXPORT QDir␊ |
53 | {␊ |
54 | public:␊ |
55 | enum FilterSpec { Dirs␉ = 0x001,␊ |
56 | ␉␉ Files␉ = 0x002,␊ |
57 | ␉␉ Drives␉ = 0x004,␊ |
58 | ␉␉ NoSymLinks = 0x008,␊ |
59 | ␉␉ All␉ = 0x007,␊ |
60 | ␉␉ TypeMask␉ = 0x00F,␊ |
61 | ␊ |
62 | ␉␉ Readable␉ = 0x010,␊ |
63 | ␉␉ Writable␉ = 0x020,␊ |
64 | ␉␉ Executable = 0x040,␊ |
65 | ␉␉ RWEMask␉ = 0x070,␊ |
66 | ␊ |
67 | ␉␉ Modified␉ = 0x080,␊ |
68 | ␉␉ Hidden␉ = 0x100,␊ |
69 | ␉␉ System␉ = 0x200,␊ |
70 | ␉␉ AccessMask = 0x3F0,␊ |
71 | ␊ |
72 | ␉␉ DefaultFilter = -1 };␊ |
73 | ␊ |
74 | enum SortSpec { Name␉ = 0x00,␊ |
75 | ␉␉ Time␉ = 0x01,␊ |
76 | ␉␉ Size␉ = 0x02,␊ |
77 | ␉␉ Unsorted␉ = 0x03,␊ |
78 | ␉␉ SortByMask = 0x03,␊ |
79 | ␊ |
80 | ␉␉ DirsFirst␉ = 0x04,␊ |
81 | ␉␉ Reversed␉ = 0x08,␊ |
82 | ␉␉ IgnoreCase = 0x10,␊ |
83 | ␉␉ DefaultSort = -1 };␊ |
84 | ␊ |
85 | QDir();␊ |
86 | QDir( const QString &path, const QString &nameFilter = QString::null,␊ |
87 | ␉ int sortSpec = Name | IgnoreCase, int filterSpec = All );␊ |
88 | QDir( const QDir & );␊ |
89 | ␊ |
90 | virtual ~QDir();␊ |
91 | ␊ |
92 | QDir &operator=( const QDir & );␊ |
93 | QDir &operator=( const QString &path );␊ |
94 | ␊ |
95 | virtual void setPath( const QString &path );␊ |
96 | virtual QString path()␉␉const;␊ |
97 | virtual QString absPath()␉const;␊ |
98 | virtual QString canonicalPath()␉const;␊ |
99 | ␊ |
100 | virtual QString dirName() const;␊ |
101 | virtual QString filePath( const QString &fileName,␊ |
102 | ␉␉␉ bool acceptAbsPath = TRUE ) const;␊ |
103 | virtual QString absFilePath( const QString &fileName,␊ |
104 | ␉␉␉␉ bool acceptAbsPath = TRUE ) const;␊ |
105 | ␊ |
106 | static QString convertSeparators( const QString &pathName );␊ |
107 | ␊ |
108 | virtual bool cd( const QString &dirName, bool acceptAbsPath = TRUE );␊ |
109 | virtual bool cdUp();␊ |
110 | ␊ |
111 | QString␉nameFilter() const;␊ |
112 | virtual void setNameFilter( const QString &nameFilter );␊ |
113 | FilterSpec filter() const;␊ |
114 | virtual void setFilter( int filterSpec );␊ |
115 | SortSpec sorting() const;␊ |
116 | virtual void setSorting( int sortSpec );␊ |
117 | ␊ |
118 | bool␉matchAllDirs() const;␊ |
119 | virtual void setMatchAllDirs( bool );␊ |
120 | ␊ |
121 | uint count() const;␊ |
122 | QString␉operator[]( int ) const;␊ |
123 | ␊ |
124 | virtual QStrList encodedEntryList( int filterSpec = DefaultFilter,␊ |
125 | ␉␉␉␉ int sortSpec = DefaultSort ) const;␊ |
126 | virtual QStrList encodedEntryList( const QString &nameFilter,␊ |
127 | ␉␉␉␉ int filterSpec = DefaultFilter,␊ |
128 | ␉␉␉␉ int sortSpec = DefaultSort ) const;␊ |
129 | virtual QStringList entryList( int filterSpec = DefaultFilter,␊ |
130 | ␉␉␉␉ int sortSpec = DefaultSort ) const;␊ |
131 | virtual QStringList entryList( const QString &nameFilter,␊ |
132 | ␉␉␉␉ int filterSpec = DefaultFilter,␊ |
133 | ␉␉␉␉ int sortSpec = DefaultSort ) const;␊ |
134 | ␊ |
135 | virtual const QFileInfoList *entryInfoList( int filterSpec = DefaultFilter,␊ |
136 | ␉␉␉␉␉␉int sortSpec = DefaultSort ) const;␊ |
137 | virtual const QFileInfoList *entryInfoList( const QString &nameFilter,␊ |
138 | ␉␉␉␉␉␉int filterSpec = DefaultFilter,␊ |
139 | ␉␉␉␉␉␉int sortSpec = DefaultSort ) const;␊ |
140 | ␊ |
141 | static const QFileInfoList *drives();␊ |
142 | ␊ |
143 | virtual bool mkdir( const QString &dirName,␊ |
144 | ␉␉␉bool acceptAbsPath = TRUE ) const;␊ |
145 | virtual bool rmdir( const QString &dirName,␊ |
146 | ␉␉␉bool acceptAbsPath = TRUE ) const;␊ |
147 | ␊ |
148 | virtual bool isReadable() const;␊ |
149 | virtual bool exists() const;␊ |
150 | virtual bool isRoot() const;␊ |
151 | ␊ |
152 | virtual bool isRelative() const;␊ |
153 | virtual void convertToAbs();␊ |
154 | ␊ |
155 | virtual bool operator==( const QDir & ) const;␊ |
156 | virtual bool operator!=( const QDir & ) const;␊ |
157 | ␊ |
158 | virtual bool remove( const QString &fileName,␊ |
159 | ␉␉␉ bool acceptAbsPath = TRUE );␊ |
160 | virtual bool rename( const QString &name, const QString &newName,␊ |
161 | ␉␉␉ bool acceptAbsPaths = TRUE );␊ |
162 | virtual bool exists( const QString &name,␊ |
163 | ␉␉␉ bool acceptAbsPath = TRUE );␊ |
164 | ␊ |
165 | static char separator();␊ |
166 | ␊ |
167 | static bool setCurrent( const QString &path );␊ |
168 | static QDir current();␊ |
169 | static QDir home();␊ |
170 | static QDir root();␊ |
171 | static QString currentDirPath();␊ |
172 | static QString homeDirPath();␊ |
173 | static QString rootDirPath();␊ |
174 | ␊ |
175 | static bool match( const QStringList &filters, const QString &fileName );␊ |
176 | static bool match( const QString &filter, const QString &fileName );␊ |
177 | static QString cleanDirPath( const QString &dirPath );␊ |
178 | static bool isRelativePath( const QString &path );␊ |
179 | ␊ |
180 | private:␊ |
181 | void init();␊ |
182 | virtual bool readDirEntries( const QString &nameFilter,␊ |
183 | ␉␉␉␉ int FilterSpec, int SortSpec );␊ |
184 | ␊ |
185 | static void slashify ( QString &);␊ |
186 | ␊ |
187 | QString␉dPath;␊ |
188 | QStringList *fList;␊ |
189 | QFileInfoList *fiList;␊ |
190 | QString␉nameFilt;␊ |
191 | FilterSpec␉filtS;␊ |
192 | SortSpec␉sortS;␊ |
193 | uint␉dirty␉: 1;␊ |
194 | uint␉allDirs : 1;␊ |
195 | };␊ |
196 | ␊ |
197 | ␊ |
198 | inline QString QDir::path() const␊ |
199 | {␊ |
200 | return dPath;␊ |
201 | }␊ |
202 | ␊ |
203 | inline QString QDir::nameFilter() const␊ |
204 | {␊ |
205 | return nameFilt;␊ |
206 | }␊ |
207 | ␊ |
208 | inline QDir::FilterSpec QDir::filter() const␊ |
209 | {␊ |
210 | return filtS;␊ |
211 | }␊ |
212 | ␊ |
213 | inline QDir::SortSpec QDir::sorting() const␊ |
214 | {␊ |
215 | return sortS;␊ |
216 | }␊ |
217 | ␊ |
218 | inline bool QDir::matchAllDirs() const␊ |
219 | {␊ |
220 | return allDirs;␊ |
221 | }␊ |
222 | ␊ |
223 | inline bool QDir::operator!=( const QDir &d ) const␊ |
224 | {␊ |
225 | return !(*this == d);␊ |
226 | }␊ |
227 | ␊ |
228 | ␊ |
229 | struct QDirSortItem {␊ |
230 | QString filename_cache;␊ |
231 | QFileInfo* item;␊ |
232 | };␊ |
233 | ␊ |
234 | #endif // QT_NO_DIR␊ |
235 | #endif // QDIR_H␊ |
236 |