source: trunk/src/corelib/io/qfileinfo.h@ 807

Last change on this file since 807 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 5.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtCore module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QFILEINFO_H
43#define QFILEINFO_H
44
45#include <QtCore/qfile.h>
46#include <QtCore/qlist.h>
47#include <QtCore/qscopedpointer.h>
48
49QT_BEGIN_HEADER
50
51QT_BEGIN_NAMESPACE
52
53QT_MODULE(Core)
54
55class QDir;
56class QDateTime;
57class QFileInfoPrivate;
58
59class Q_CORE_EXPORT QFileInfo
60{
61public:
62 QFileInfo();
63 QFileInfo(const QString &file);
64 QFileInfo(const QFile &file);
65 QFileInfo(const QDir &dir, const QString &file);
66 QFileInfo(const QFileInfo &fileinfo);
67 ~QFileInfo();
68
69 QFileInfo &operator=(const QFileInfo &fileinfo);
70 bool operator==(const QFileInfo &fileinfo); // 5.0 - remove me
71 bool operator==(const QFileInfo &fileinfo) const;
72 inline bool operator!=(const QFileInfo &fileinfo) { return !(operator==(fileinfo)); } // 5.0 - remove me
73 inline bool operator!=(const QFileInfo &fileinfo) const { return !(operator==(fileinfo)); }
74
75 void setFile(const QString &file);
76 void setFile(const QFile &file);
77 void setFile(const QDir &dir, const QString &file);
78 bool exists() const;
79 void refresh();
80
81 QString filePath() const;
82 QString absoluteFilePath() const;
83 QString canonicalFilePath() const;
84 QString fileName() const;
85 QString baseName() const;
86 QString completeBaseName() const;
87 QString suffix() const;
88 QString bundleName() const;
89 QString completeSuffix() const;
90
91 QString path() const;
92 QString absolutePath() const;
93 QString canonicalPath() const;
94 QDir dir() const;
95 QDir absoluteDir() const;
96
97 bool isReadable() const;
98 bool isWritable() const;
99 bool isExecutable() const;
100 bool isHidden() const;
101
102 bool isRelative() const;
103 inline bool isAbsolute() const { return !isRelative(); }
104 bool makeAbsolute();
105
106 bool isFile() const;
107 bool isDir() const;
108 bool isSymLink() const;
109 bool isRoot() const;
110 bool isBundle() const;
111
112 QString readLink() const;
113 inline QString symLinkTarget() const { return readLink(); }
114
115 QString owner() const;
116 uint ownerId() const;
117 QString group() const;
118 uint groupId() const;
119
120 bool permission(QFile::Permissions permissions) const;
121 QFile::Permissions permissions() const;
122
123 qint64 size() const;
124
125 QDateTime created() const;
126 QDateTime lastModified() const;
127 QDateTime lastRead() const;
128
129 void detach();
130
131 bool caching() const;
132 void setCaching(bool on);
133
134#ifdef QT3_SUPPORT
135 enum Permission {
136 ReadOwner = QFile::ReadOwner, WriteOwner = QFile::WriteOwner, ExeOwner = QFile::ExeOwner,
137 ReadUser = QFile::ReadUser, WriteUser = QFile::WriteUser, ExeUser = QFile::ExeUser,
138 ReadGroup = QFile::ReadGroup, WriteGroup = QFile::WriteGroup, ExeGroup = QFile::ExeGroup,
139 ReadOther = QFile::ReadOther, WriteOther = QFile::WriteOther, ExeOther = QFile::ExeOther
140 };
141 Q_DECLARE_FLAGS(PermissionSpec, Permission)
142
143 inline QT3_SUPPORT QString baseName(bool complete) {
144 if(complete)
145 return completeBaseName();
146 return baseName();
147 }
148 inline QT3_SUPPORT QString extension(bool complete = true) const {
149 if(complete)
150 return completeSuffix();
151 return suffix();
152 }
153 inline QT3_SUPPORT QString absFilePath() const { return absoluteFilePath(); }
154
155 inline QT3_SUPPORT QString dirPath(bool absPath = false) const {
156 if(absPath)
157 return absolutePath();
158 return path();
159 }
160 QT3_SUPPORT QDir dir(bool absPath) const;
161 inline QT3_SUPPORT bool convertToAbs() { return makeAbsolute(); }
162#if !defined(Q_NO_TYPESAFE_FLAGS)
163 inline QT3_SUPPORT bool permission(PermissionSpec permissions) const
164 { return permission(QFile::Permissions(static_cast<int>(permissions))); }
165#endif
166#endif
167
168protected:
169 QScopedPointer<QFileInfoPrivate> d_ptr;
170private:
171 Q_DECLARE_PRIVATE(QFileInfo)
172};
173Q_DECLARE_TYPEINFO(QFileInfo, Q_MOVABLE_TYPE);
174
175#ifdef QT3_SUPPORT
176Q_DECLARE_OPERATORS_FOR_FLAGS(QFileInfo::PermissionSpec)
177#endif
178
179typedef QList<QFileInfo> QFileInfoList;
180#ifdef QT3_SUPPORT
181typedef QList<QFileInfo>::Iterator QFileInfoListIterator;
182#endif
183
184QT_END_NAMESPACE
185
186QT_END_HEADER
187
188#endif // QFILEINFO_H
Note: See TracBrowser for help on using the repository browser.