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

« back to all changes in this revision

Viewing changes to src/corelib/io/qfileinfo.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 QFILEINFO_H
 
30
#define QFILEINFO_H
 
31
 
 
32
#include "QtCore/qfile.h"
 
33
#include "QtCore/qlist.h"
 
34
 
 
35
class QDir;
 
36
class QDateTime;
 
37
class QFileInfoPrivate;
 
38
 
 
39
class Q_CORE_EXPORT QFileInfo
 
40
{
 
41
public:
 
42
    QFileInfo();
 
43
    QFileInfo(const QString &file);
 
44
    QFileInfo(const QFile &file);
 
45
#ifndef QT_NO_DIR
 
46
    QFileInfo(const QDir &dir, const QString &file);
 
47
#endif
 
48
    QFileInfo(const QFileInfo &fileinfo);
 
49
    ~QFileInfo();
 
50
 
 
51
    QFileInfo &operator=(const QFileInfo &fileinfo);
 
52
    bool operator==(const QFileInfo &fileinfo);
 
53
    inline bool operator!=(const QFileInfo &fileinfo) { return !(operator==(fileinfo)); }
 
54
 
 
55
    void setFile(const QString &file);
 
56
    void setFile(const QFile &file);
 
57
#ifndef QT_NO_DIR
 
58
    void setFile(const QDir &dir, const QString &file);
 
59
#endif
 
60
    bool exists() const;
 
61
    void refresh();
 
62
 
 
63
    QString filePath() const;
 
64
    QString absoluteFilePath() const;
 
65
    QString canonicalFilePath() const;
 
66
    QString fileName() const;
 
67
    QString baseName() const;
 
68
    QString completeBaseName() const;
 
69
    QString suffix() const;
 
70
    QString completeSuffix() const;
 
71
 
 
72
    QString path() const;
 
73
    QString absolutePath() const;
 
74
    QString canonicalPath() const;
 
75
#ifndef QT_NO_DIR
 
76
    QDir dir() const;
 
77
    QDir absoluteDir() const;
 
78
#endif
 
79
 
 
80
    bool isReadable() const;
 
81
    bool isWritable() const;
 
82
    bool isExecutable() const;
 
83
    bool isHidden() const;
 
84
 
 
85
    bool isRelative() const;
 
86
    inline bool isAbsolute() const { return !isRelative(); }
 
87
    bool makeAbsolute();
 
88
 
 
89
    bool isFile() const;
 
90
    bool isDir() const;
 
91
    bool isSymLink() const;
 
92
    bool isRoot() const;
 
93
 
 
94
    QString readLink() const;
 
95
 
 
96
    QString owner() const;
 
97
    uint ownerId() const;
 
98
    QString group() const;
 
99
    uint groupId() const;
 
100
 
 
101
    bool permission(QFile::Permissions permissions) const;
 
102
    QFile::Permissions permissions() const;
 
103
 
 
104
    qint64 size() const;
 
105
 
 
106
    QDateTime created() const;
 
107
    QDateTime lastModified() const;
 
108
    QDateTime lastRead() const;
 
109
 
 
110
    void detach();
 
111
 
 
112
    bool caching() const;
 
113
    void setCaching(bool on);
 
114
 
 
115
#ifdef QT3_SUPPORT
 
116
    enum Permission {
 
117
        ReadOwner = QFile::ReadOwner, WriteOwner = QFile::WriteOwner, ExeOwner = QFile::ExeOwner,
 
118
        ReadUser  = QFile::ReadUser,  WriteUser  = QFile::WriteUser,  ExeUser  = QFile::ExeUser,
 
119
        ReadGroup = QFile::ReadGroup, WriteGroup = QFile::WriteGroup, ExeGroup = QFile::ExeGroup,
 
120
        ReadOther = QFile::ReadOther, WriteOther = QFile::WriteOther, ExeOther = QFile::ExeOther
 
121
    };
 
122
    Q_DECLARE_FLAGS(PermissionSpec, Permission)
 
123
 
 
124
    inline QT3_SUPPORT QString baseName(bool complete) {
 
125
        if(complete)
 
126
            return completeBaseName();
 
127
        return baseName();
 
128
    }
 
129
    inline QT3_SUPPORT QString extension(bool complete = true) const {
 
130
        if(complete)
 
131
            return completeSuffix();
 
132
        return suffix();
 
133
    }
 
134
    inline QT3_SUPPORT QString absFilePath() const { return absoluteFilePath(); }
 
135
 
 
136
    inline QT3_SUPPORT QString dirPath(bool absPath = false) const {
 
137
        if(absPath)
 
138
            return absolutePath();
 
139
        return path();
 
140
    }
 
141
    QT3_SUPPORT QDir dir(bool absPath) const;
 
142
    inline QT3_SUPPORT bool convertToAbs() { return makeAbsolute(); }
 
143
#if !defined(Q_NO_TYPESAFE_FLAGS)
 
144
    inline QT3_SUPPORT bool permission(PermissionSpec permissions) const
 
145
    { return permission(QFile::Permissions((int)permissions)); }
 
146
#endif
 
147
#endif
 
148
 
 
149
protected:
 
150
    QFileInfoPrivate *d_ptr;
 
151
private:
 
152
    Q_DECLARE_PRIVATE(QFileInfo)
 
153
};
 
154
Q_DECLARE_TYPEINFO(QFileInfo, Q_MOVABLE_TYPE);
 
155
 
 
156
#ifdef QT3_SUPPORT
 
157
Q_DECLARE_OPERATORS_FOR_FLAGS(QFileInfo::PermissionSpec)
 
158
#endif
 
159
 
 
160
typedef QList<QFileInfo> QFileInfoList;
 
161
#ifdef QT3_SUPPORT
 
162
typedef QList<QFileInfo>::Iterator QFileInfoListIterator;
 
163
#endif
 
164
 
 
165
#endif // QFILEINFO_H