| 1 | /**************************************************************************** | 
|---|
| 2 | ** $Id: qfileinfo.h 2 2005-11-16 15:49:26Z dmik $ | 
|---|
| 3 | ** | 
|---|
| 4 | ** Definition of QFileInfo class | 
|---|
| 5 | ** | 
|---|
| 6 | ** Created : 950628 | 
|---|
| 7 | ** | 
|---|
| 8 | ** Copyright (C) 1992-2002 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 | template <class T> class QDeepCopy; | 
|---|
| 50 |  | 
|---|
| 51 |  | 
|---|
| 52 | class Q_EXPORT QFileInfo | 
|---|
| 53 | { | 
|---|
| 54 | public: | 
|---|
| 55 | enum PermissionSpec { | 
|---|
| 56 | ReadOwner = 04000, WriteOwner = 02000, ExeOwner = 01000, | 
|---|
| 57 | ReadUser  = 00400, WriteUser  = 00200, ExeUser  = 00100, | 
|---|
| 58 | ReadGroup = 00040, WriteGroup = 00020, ExeGroup = 00010, | 
|---|
| 59 | ReadOther = 00004, WriteOther = 00002, ExeOther = 00001 }; | 
|---|
| 60 |  | 
|---|
| 61 | QFileInfo(); | 
|---|
| 62 | QFileInfo( const QString &file ); | 
|---|
| 63 | QFileInfo( const QFile & ); | 
|---|
| 64 | #ifndef QT_NO_DIR | 
|---|
| 65 | QFileInfo( const QDir &, const QString &fileName ); | 
|---|
| 66 | #endif | 
|---|
| 67 | QFileInfo( const QFileInfo & ); | 
|---|
| 68 | ~QFileInfo(); | 
|---|
| 69 |  | 
|---|
| 70 | QFileInfo  &operator=( const QFileInfo & ); | 
|---|
| 71 |  | 
|---|
| 72 | void        setFile( const QString &file ); | 
|---|
| 73 | void        setFile( const QFile & ); | 
|---|
| 74 | #ifndef QT_NO_DIR | 
|---|
| 75 | void        setFile( const QDir &, const QString &fileName ); | 
|---|
| 76 | #endif | 
|---|
| 77 | bool        exists()        const; | 
|---|
| 78 | void        refresh()       const; | 
|---|
| 79 | bool        caching()       const; | 
|---|
| 80 | void        setCaching( bool ); | 
|---|
| 81 |  | 
|---|
| 82 | QString     filePath()      const; | 
|---|
| 83 | QString     fileName()      const; | 
|---|
| 84 | #ifndef QT_NO_DIR //### | 
|---|
| 85 | QString     absFilePath()   const; | 
|---|
| 86 | #endif | 
|---|
| 87 | QString     baseName( bool complete = FALSE ) const; | 
|---|
| 88 | QString     extension( bool complete = TRUE ) const; | 
|---|
| 89 |  | 
|---|
| 90 | #ifndef QT_NO_DIR //### | 
|---|
| 91 | QString     dirPath( bool absPath = FALSE ) const; | 
|---|
| 92 | #endif | 
|---|
| 93 | #ifndef QT_NO_DIR | 
|---|
| 94 | QDir        dir( bool absPath = FALSE )     const; | 
|---|
| 95 | #endif | 
|---|
| 96 | bool        isReadable()    const; | 
|---|
| 97 | bool        isWritable()    const; | 
|---|
| 98 | bool        isExecutable()  const; | 
|---|
| 99 | bool        isHidden()      const; | 
|---|
| 100 |  | 
|---|
| 101 | #ifndef QT_NO_DIR //### | 
|---|
| 102 | bool        isRelative()    const; | 
|---|
| 103 | bool        convertToAbs(); | 
|---|
| 104 | #endif | 
|---|
| 105 |  | 
|---|
| 106 | bool        isFile()        const; | 
|---|
| 107 | bool        isDir()         const; | 
|---|
| 108 | bool        isSymLink()     const; | 
|---|
| 109 |  | 
|---|
| 110 | QString     readLink()      const; | 
|---|
| 111 |  | 
|---|
| 112 | QString     owner()         const; | 
|---|
| 113 | uint        ownerId()       const; | 
|---|
| 114 | QString     group()         const; | 
|---|
| 115 | uint        groupId()       const; | 
|---|
| 116 |  | 
|---|
| 117 | bool        permission( int permissionSpec ) const; | 
|---|
| 118 |  | 
|---|
| 119 | #if (QT_VERSION-0 >= 0x040000) | 
|---|
| 120 | #error "QFileInfo::size() should return QIODevice::Offset instead of uint" | 
|---|
| 121 | #elif defined(QT_ABI_QT4) | 
|---|
| 122 | QIODevice::Offset size()    const; | 
|---|
| 123 | #else | 
|---|
| 124 | uint        size()          const; | 
|---|
| 125 | #endif | 
|---|
| 126 |  | 
|---|
| 127 | QDateTime   created()       const; | 
|---|
| 128 | QDateTime   lastModified()  const; | 
|---|
| 129 | QDateTime   lastRead()      const; | 
|---|
| 130 |  | 
|---|
| 131 | private: | 
|---|
| 132 | void        doStat() const; | 
|---|
| 133 | static void slashify( QString & ); | 
|---|
| 134 | static void makeAbs( QString & ); | 
|---|
| 135 |  | 
|---|
| 136 | QString     fn; | 
|---|
| 137 | QFileInfoCache *fic; | 
|---|
| 138 | bool        cache; | 
|---|
| 139 | #if defined(Q_OS_UNIX) | 
|---|
| 140 | bool        symLink; | 
|---|
| 141 | #endif | 
|---|
| 142 |  | 
|---|
| 143 | void detach(); | 
|---|
| 144 | friend class QDeepCopy< QFileInfo >; | 
|---|
| 145 | }; | 
|---|
| 146 |  | 
|---|
| 147 |  | 
|---|
| 148 | inline bool QFileInfo::caching() const | 
|---|
| 149 | { | 
|---|
| 150 | return cache; | 
|---|
| 151 | } | 
|---|
| 152 |  | 
|---|
| 153 |  | 
|---|
| 154 | #endif // QFILEINFO_H | 
|---|