~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/corelib/io/qdir.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the core module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QDIR_H
 
30
#define QDIR_H
 
31
 
 
32
#include "QtCore/qstring.h"
 
33
#include "QtCore/qfileinfo.h"
 
34
#include "QtCore/qstringlist.h"
 
35
 
 
36
class QDirPrivate;
 
37
 
 
38
class Q_CORE_EXPORT QDir
 
39
{
 
40
protected:
 
41
    QDirPrivate *d_ptr;
 
42
private:
 
43
    Q_DECLARE_PRIVATE(QDir)
 
44
public:
 
45
    enum Filter { Dirs        = 0x001,
 
46
                  Files       = 0x002,
 
47
                  Drives      = 0x004,
 
48
                  NoSymLinks  = 0x008,
 
49
                  TypeMask    = 0x00f,
 
50
#ifdef QT3_SUPPORT
 
51
                  All         = TypeMask,
 
52
#endif
 
53
 
 
54
                  Readable    = 0x010,
 
55
                  Writable    = 0x020,
 
56
                  Executable  = 0x040,
 
57
                  PermissionMask    = 0x070,
 
58
#ifdef QT3_SUPPORT
 
59
                  RWEMask     = 0x070,
 
60
#endif
 
61
 
 
62
                  Modified    = 0x080,
 
63
                  Hidden      = 0x100,
 
64
                  System      = 0x200,
 
65
                  AccessMask  = 0x3F0,
 
66
 
 
67
                  AllDirs       = 0x400,
 
68
                  CaseSensitive = 0x800,
 
69
 
 
70
                  NoFilter = -1
 
71
#ifdef QT3_SUPPORT
 
72
                  ,DefaultFilter = NoFilter
 
73
#endif
 
74
    };
 
75
    Q_DECLARE_FLAGS(Filters, Filter)
 
76
#ifdef QT3_SUPPORT
 
77
    typedef Filters FilterSpec;
 
78
#endif
 
79
 
 
80
    enum SortFlag { Name        = 0x00,
 
81
                    Time        = 0x01,
 
82
                    Size        = 0x02,
 
83
                    Unsorted    = 0x03,
 
84
                    SortByMask  = 0x03,
 
85
 
 
86
                    DirsFirst   = 0x04,
 
87
                    Reversed    = 0x08,
 
88
                    IgnoreCase  = 0x10,
 
89
                    DirsLast    = 0x20,
 
90
                    NoSort = -1
 
91
#ifdef QT3_SUPPORT
 
92
                  ,DefaultSort = NoSort
 
93
#endif
 
94
    };
 
95
    Q_DECLARE_FLAGS(SortFlags, SortFlag)
 
96
 
 
97
    QDir(const QDir &);
 
98
    QDir(const QString &path = QString());
 
99
    QDir(const QString &path, const QString &nameFilter,
 
100
         SortFlags sort = SortFlags(Name | IgnoreCase), Filters filter = TypeMask);
 
101
    ~QDir();
 
102
 
 
103
    QDir &operator=(const QDir &);
 
104
    QDir &operator=(const QString &path);
 
105
 
 
106
    void setPath(const QString &path);
 
107
    QString path() const;
 
108
    QString absolutePath() const;
 
109
    QString canonicalPath() const;
 
110
 
 
111
    static void addResourceSearchPath(const QString &path);
 
112
 
 
113
    QString dirName() const;
 
114
    QString filePath(const QString &fileName) const;
 
115
    QString absoluteFilePath(const QString &fileName) const;
 
116
    QString relativeFilePath(const QString &fileName) const;
 
117
 
 
118
    static QString convertSeparators(const QString &pathName);
 
119
 
 
120
    bool cd(const QString &dirName);
 
121
    bool cdUp();
 
122
 
 
123
    QStringList nameFilters() const;
 
124
    void setNameFilters(const QStringList &nameFilters);
 
125
 
 
126
    Filters filter() const;
 
127
    void setFilter(Filters filter);
 
128
    SortFlags sorting() const;
 
129
    void setSorting(SortFlags sort);
 
130
 
 
131
    uint count() const;
 
132
    QString operator[](int) const;
 
133
 
 
134
    static QStringList nameFiltersFromString(const QString &nameFilter);
 
135
 
 
136
    QStringList entryList(Filters filters = NoFilter, SortFlags sort = NoSort) const;
 
137
    QStringList entryList(const QStringList &nameFilters, Filters filters = NoFilter,
 
138
                          SortFlags sort = NoSort) const;
 
139
 
 
140
    QFileInfoList entryInfoList(Filters filters = NoFilter, SortFlags sort = NoSort) const;
 
141
    QFileInfoList entryInfoList(const QStringList &nameFilters, Filters filters = NoFilter,
 
142
                                SortFlags sort = NoSort) const;
 
143
 
 
144
    bool mkdir(const QString &dirName) const;
 
145
    bool rmdir(const QString &dirName) const;
 
146
    bool mkpath(const QString &dirPath) const;
 
147
    bool rmpath(const QString &dirPath) const;
 
148
 
 
149
    bool isReadable() const;
 
150
    bool exists() const;
 
151
    bool isRoot() const;
 
152
 
 
153
    static bool isRelativePath(const QString &path);
 
154
    inline static bool isAbsolutePath(const QString &path) { return !isRelativePath(path); }
 
155
    bool isRelative() const;
 
156
    inline bool isAbsolute() const { return !isRelative(); }
 
157
    bool makeAbsolute();
 
158
 
 
159
    bool operator==(const QDir &dir) const;
 
160
    inline bool operator!=(const QDir &dir) const {  return !operator==(dir); }
 
161
 
 
162
    bool remove(const QString &fileName);
 
163
    bool rename(const QString &oldName, const QString &newName);
 
164
    bool exists(const QString &name) const;
 
165
 
 
166
    static QFileInfoList drives();
 
167
 
 
168
    static QChar separator();
 
169
 
 
170
    static bool setCurrent(const QString &path);
 
171
    static inline QDir current() { return QDir(currentPath()); }
 
172
    static QString currentPath();
 
173
 
 
174
    static inline QDir home() { return QDir(homePath()); }
 
175
    static QString homePath();
 
176
    static inline QDir root() { return QDir(rootPath()); }
 
177
    static QString rootPath();
 
178
    static inline QDir temp() { return QDir(tempPath()); }
 
179
    static QString tempPath();
 
180
 
 
181
#ifndef QT_NO_REGEXP
 
182
    static bool match(const QStringList &filters, const QString &fileName);
 
183
    static bool match(const QString &filter, const QString &fileName);
 
184
#endif
 
185
    static QString cleanPath(const QString &path);
 
186
    void refresh() const;
 
187
 
 
188
#ifdef QT3_SUPPORT
 
189
    typedef SortFlags SortSpec;
 
190
    inline QT3_SUPPORT QString absPath() const { return absolutePath(); }
 
191
    inline QT3_SUPPORT QString absFilePath(const QString &fileName, bool acceptAbsPath = true) const
 
192
       { Q_UNUSED(acceptAbsPath); return absoluteFilePath(fileName); }
 
193
    inline QT3_SUPPORT bool matchAllDirs() const
 
194
        { return filter() & AllDirs; }
 
195
    inline QT3_SUPPORT void setMatchAllDirs(bool on)
 
196
    {
 
197
        if(on)
 
198
            setFilter(filter() | AllDirs);
 
199
        else
 
200
            setFilter(filter() & ~(int)AllDirs);
 
201
    }
 
202
    inline QT3_SUPPORT QStringList entryList(const QString &nameFilter, Filters filters = NoFilter,
 
203
                                           SortFlags sort = NoSort) const
 
204
    { return entryList(nameFiltersFromString(nameFilter), filters, sort); }
 
205
    inline QT3_SUPPORT QFileInfoList entryInfoList(const QString &nameFilter,
 
206
                                                 Filters filters = NoFilter,
 
207
                                                 SortFlags sort = NoSort) const
 
208
    { return entryInfoList(nameFiltersFromString(nameFilter), filters, sort); }
 
209
 
 
210
    QT3_SUPPORT QString nameFilter() const;
 
211
    QT3_SUPPORT void setNameFilter(const QString &nameFilter);
 
212
 
 
213
    inline QT3_SUPPORT bool mkdir(const QString &dirName, bool acceptAbsPath) const
 
214
        { Q_UNUSED(acceptAbsPath); return mkdir(dirName); }
 
215
    inline QT3_SUPPORT bool rmdir(const QString &dirName, bool acceptAbsPath) const
 
216
        { Q_UNUSED(acceptAbsPath); return rmdir(dirName); }
 
217
 
 
218
    inline QT3_SUPPORT void convertToAbs() { makeAbsolute(); }
 
219
    inline QT3_SUPPORT static QString currentDirPath() { return currentPath(); }
 
220
    inline QT3_SUPPORT static QString homeDirPath() { return homePath(); }
 
221
    inline QT3_SUPPORT static QString rootDirPath() { return rootPath(); }
 
222
    inline QT3_SUPPORT static QString cleanDirPath(const QString &name) { return cleanPath(name); }
 
223
#endif
 
224
};
 
225
 
 
226
Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::Filters)
 
227
Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::SortFlags)
 
228
 
 
229
#endif // QDIR_H