1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtCore module of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
45 #include <QtCore/qfile.h>
46 #include <QtCore/qlist.h>
47 #include <QtCore/qscopedpointer.h>
57 class QFileInfoPrivate
;
59 class Q_CORE_EXPORT QFileInfo
63 QFileInfo(const QString
&file
);
64 QFileInfo(const QFile
&file
);
65 QFileInfo(const QDir
&dir
, const QString
&file
);
66 QFileInfo(const QFileInfo
&fileinfo
);
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
)); }
75 void setFile(const QString
&file
);
76 void setFile(const QFile
&file
);
77 void setFile(const QDir
&dir
, const QString
&file
);
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;
92 QString
absolutePath() const;
93 QString
canonicalPath() const;
95 QDir
absoluteDir() const;
97 bool isReadable() const;
98 bool isWritable() const;
99 bool isExecutable() const;
100 bool isHidden() const;
102 bool isRelative() const;
103 inline bool isAbsolute() const { return !isRelative(); }
108 bool isSymLink() const;
110 bool isBundle() const;
112 QString
readLink() const;
113 inline QString
symLinkTarget() const { return readLink(); }
115 QString
owner() const;
116 uint
ownerId() const;
117 QString
group() const;
118 uint
groupId() const;
120 bool permission(QFile::Permissions permissions
) const;
121 QFile::Permissions
permissions() const;
125 QDateTime
created() const;
126 QDateTime
lastModified() const;
127 QDateTime
lastRead() const;
131 bool caching() const;
132 void setCaching(bool on
);
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
141 Q_DECLARE_FLAGS(PermissionSpec
, Permission
)
143 inline QT3_SUPPORT QString
baseName(bool complete
) {
145 return completeBaseName();
148 inline QT3_SUPPORT QString
extension(bool complete
= true) const {
150 return completeSuffix();
153 inline QT3_SUPPORT QString
absFilePath() const { return absoluteFilePath(); }
155 inline QT3_SUPPORT QString
dirPath(bool absPath
= false) const {
157 return absolutePath();
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
))); }
169 QScopedPointer
<QFileInfoPrivate
> d_ptr
;
171 Q_DECLARE_PRIVATE(QFileInfo
)
173 Q_DECLARE_TYPEINFO(QFileInfo
, Q_MOVABLE_TYPE
);
176 Q_DECLARE_OPERATORS_FOR_FLAGS(QFileInfo::PermissionSpec
)
179 typedef QList
<QFileInfo
> QFileInfoList
;
181 typedef QList
<QFileInfo
>::Iterator QFileInfoListIterator
;
188 #endif // QFILEINFO_H