|
1 /**************************************************************************** |
|
2 ** |
|
3 ** |
|
4 ** Definition of QFileInfo class |
|
5 ** |
|
6 ** Created : 950628 |
|
7 ** |
|
8 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
|
9 ** |
|
10 ** This file is part of the tools module of the Qt GUI Toolkit. |
|
11 ** |
|
12 ** This file may be distributed under the terms of the Q Public License |
|
13 ** as defined by Trolltech AS of Norway and appearing in the file |
|
14 ** LICENSE.QPL included in the packaging of this file. |
|
15 ** |
|
16 ** This file may be distributed and/or modified under the terms of the |
|
17 ** GNU General Public License version 2 as published by the Free Software |
|
18 ** Foundation and appearing in the file LICENSE.GPL included in the |
|
19 ** packaging of this file. |
|
20 ** |
|
21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
|
22 ** licenses may use this file in accordance with the Qt Commercial License |
|
23 ** Agreement provided with the Software. |
|
24 ** |
|
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
|
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|
27 ** |
|
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
|
29 ** information about Qt Commercial License Agreements. |
|
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
|
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
|
32 ** |
|
33 ** Contact info@trolltech.com if any conditions of this licensing are |
|
34 ** not clear to you. |
|
35 ** |
|
36 **********************************************************************/ |
|
37 |
|
38 #ifndef QFILEINFO_H |
|
39 #define QFILEINFO_H |
|
40 |
|
41 #ifndef QT_H |
|
42 #include "qfile.h" |
|
43 #include "qdatetime.h" |
|
44 #endif // QT_H |
|
45 |
|
46 |
|
47 class QDir; |
|
48 struct QFileInfoCache; |
|
49 |
|
50 |
|
51 class Q_EXPORT QFileInfo // file information class |
|
52 { |
|
53 public: |
|
54 enum PermissionSpec { |
|
55 ReadUser = 0400, WriteUser = 0200, ExeUser = 0100, |
|
56 ReadGroup = 0040, WriteGroup = 0020, ExeGroup = 0010, |
|
57 ReadOther = 0004, WriteOther = 0002, ExeOther = 0001 }; |
|
58 |
|
59 QFileInfo(); |
|
60 QFileInfo( const QString &file ); |
|
61 QFileInfo( const QFile & ); |
|
62 #ifndef QT_NO_DIR |
|
63 QFileInfo( const QDir &, const QString &fileName ); |
|
64 #endif |
|
65 QFileInfo( const QFileInfo & ); |
|
66 ~QFileInfo(); |
|
67 |
|
68 QFileInfo &operator=( const QFileInfo & ); |
|
69 |
|
70 void setFile( const QString &file ); |
|
71 void setFile( const QFile & ); |
|
72 #ifndef QT_NO_DIR |
|
73 void setFile( const QDir &, const QString &fileName ); |
|
74 #endif |
|
75 bool exists() const; |
|
76 void refresh() const; |
|
77 bool caching() const; |
|
78 void setCaching( bool ); |
|
79 |
|
80 QString filePath() const; |
|
81 QString fileName() const; |
|
82 #ifndef QT_NO_DIR //### |
|
83 QString absFilePath() const; |
|
84 #endif |
|
85 QString baseName() const; |
|
86 QString extension( bool complete = TRUE ) const; |
|
87 |
|
88 #ifndef QT_NO_DIR //### |
|
89 QString dirPath( bool absPath = FALSE ) const; |
|
90 #endif |
|
91 #ifndef QT_NO_DIR |
|
92 QDir dir( bool absPath = FALSE ) const; |
|
93 #endif |
|
94 bool isReadable() const; |
|
95 bool isWritable() const; |
|
96 bool isExecutable() const; |
|
97 |
|
98 #ifndef QT_NO_DIR //### |
|
99 bool isRelative() const; |
|
100 bool convertToAbs(); |
|
101 #endif |
|
102 |
|
103 bool isFile() const; |
|
104 bool isDir() const; |
|
105 bool isSymLink() const; |
|
106 |
|
107 QString readLink() const; |
|
108 |
|
109 QString owner() const; |
|
110 uint ownerId() const; |
|
111 QString group() const; |
|
112 uint groupId() const; |
|
113 |
|
114 bool permission( int permissionSpec ) const; |
|
115 |
|
116 uint size() const; |
|
117 |
|
118 QDateTime lastModified() const; |
|
119 QDateTime lastRead() const; |
|
120 |
|
121 private: |
|
122 void doStat() const; |
|
123 static void slashify( QString & ); |
|
124 static void makeAbs( QString & ); |
|
125 |
|
126 QString fn; |
|
127 QFileInfoCache *fic; |
|
128 bool cache; |
|
129 }; |
|
130 |
|
131 |
|
132 inline bool QFileInfo::caching() const |
|
133 { |
|
134 return cache; |
|
135 } |
|
136 |
|
137 |
|
138 #endif // QFILEINFO_H |