|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtCore module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
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 |
|
49 QT_BEGIN_HEADER |
|
50 |
|
51 QT_BEGIN_NAMESPACE |
|
52 |
|
53 QT_MODULE(Core) |
|
54 |
|
55 class QDir; |
|
56 class QDateTime; |
|
57 class QFileInfoPrivate; |
|
58 |
|
59 class Q_CORE_EXPORT QFileInfo |
|
60 { |
|
61 public: |
|
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 |
|
168 protected: |
|
169 QScopedPointer<QFileInfoPrivate> d_ptr; |
|
170 private: |
|
171 Q_DECLARE_PRIVATE(QFileInfo) |
|
172 }; |
|
173 Q_DECLARE_TYPEINFO(QFileInfo, Q_MOVABLE_TYPE); |
|
174 |
|
175 #ifdef QT3_SUPPORT |
|
176 Q_DECLARE_OPERATORS_FOR_FLAGS(QFileInfo::PermissionSpec) |
|
177 #endif |
|
178 |
|
179 typedef QList<QFileInfo> QFileInfoList; |
|
180 #ifdef QT3_SUPPORT |
|
181 typedef QList<QFileInfo>::Iterator QFileInfoListIterator; |
|
182 #endif |
|
183 |
|
184 QT_END_NAMESPACE |
|
185 |
|
186 QT_END_HEADER |
|
187 |
|
188 #endif // QFILEINFO_H |