00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef QFILEINFO_H
00039 #define QFILEINFO_H
00040
00041 #ifndef QT_H
00042 #include "qfile.h"
00043 #include "qdatetime.h"
00044 #endif // QT_H
00045
00046
00047 class QDir;
00048 struct QFileInfoCache;
00049
00050
00051 class Q_EXPORT QFileInfo
00052 {
00053 public:
00054 enum PermissionSpec {
00055 ReadUser = 0400, WriteUser = 0200, ExeUser = 0100,
00056 ReadGroup = 0040, WriteGroup = 0020, ExeGroup = 0010,
00057 ReadOther = 0004, WriteOther = 0002, ExeOther = 0001 };
00058
00059 QFileInfo();
00060 QFileInfo( const QString &file );
00061 QFileInfo( const QFile & );
00062 #ifndef QT_NO_DIR
00063 QFileInfo( const QDir &, const QString &fileName );
00064 #endif
00065 QFileInfo( const QFileInfo & );
00066 ~QFileInfo();
00067
00068 QFileInfo &operator=( const QFileInfo & );
00069
00070 void setFile( const QString &file );
00071 void setFile( const QFile & );
00072 #ifndef QT_NO_DIR
00073 void setFile( const QDir &, const QString &fileName );
00074 #endif
00075 bool exists() const;
00076 void refresh() const;
00077 bool caching() const;
00078 void setCaching( bool );
00079
00080 QString filePath() const;
00081 QString fileName() const;
00082 #ifndef QT_NO_DIR //###
00083 QString absFilePath() const;
00084 #endif
00085 QString baseName( bool complete = FALSE ) const;
00086 QString extension( bool complete = TRUE ) const;
00087
00088 #ifndef QT_NO_DIR //###
00089 QString dirPath( bool absPath = FALSE ) const;
00090 #endif
00091 #ifndef QT_NO_DIR
00092 QDir dir( bool absPath = FALSE ) const;
00093 #endif
00094 bool isReadable() const;
00095 bool isWritable() const;
00096 bool isExecutable() const;
00097 bool isHidden() const;
00098
00099 #ifndef QT_NO_DIR //###
00100 bool isRelative() const;
00101 bool convertToAbs();
00102 #endif
00103
00104 bool isFile() const;
00105 bool isDir() const;
00106 bool isSymLink() const;
00107
00108 QString readLink() const;
00109
00110 QString owner() const;
00111 uint ownerId() const;
00112 QString group() const;
00113 uint groupId() const;
00114
00115 bool permission( int permissionSpec ) const;
00116
00117 #if (QT_VERSION-0 >= 0x040000)
00118 #error "QFileInfo::size() should return QIODevice::Offset instead of uint"
00119 #elif defined(QT_ABI_QT4)
00120 QIODevice::Offset size() const;
00121 #else
00122 uint size() const;
00123 #endif
00124
00125 QDateTime created() const;
00126 QDateTime lastModified() const;
00127 QDateTime lastRead() const;
00128
00129 private:
00130 void doStat() const;
00131 static void slashify( QString & );
00132 static void makeAbs( QString & );
00133
00134 QString fn;
00135 QFileInfoCache *fic;
00136 bool cache;
00137 #if defined(Q_OS_UNIX)
00138 bool symLink;
00139 #endif
00140
00141 };
00142
00143
00144 inline bool QFileInfo::caching() const
00145 {
00146 return cache;
00147 }
00148
00149
00150 #endif // QFILEINFO_H