1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.core.fileinfo; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.datetime; 19 import qt.core.dir; 20 import qt.core.file; 21 import qt.core.global; 22 import qt.core.list; 23 import qt.core.shareddata; 24 import qt.core.string; 25 import qt.core.typeinfo; 26 import qt.helpers; 27 28 /+ class QDir; +/ 29 extern(C++, class) struct QDirIteratorPrivate; 30 /+ class QDateTime; +/ 31 extern(C++, class) struct QFileInfoPrivate; 32 33 @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_CORE_EXPORT +/ QFileInfo 34 { 35 private: 36 /+ friend class QDirIteratorPrivate; +/ 37 public: 38 /+ explicit +/this(QFileInfoPrivate* d); 39 40 @disable this(); 41 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 42 ref typeof(this) rawConstructor(); 43 static typeof(this) create() 44 { 45 typeof(this) r = typeof(this).init; 46 r.rawConstructor(); 47 return r; 48 } 49 50 this(ref const(QString) file); 51 //this(const QFile &file); 52 this(ref const(QDir) dir, ref const(QString) file); 53 @disable this(this); 54 this(ref const(QFileInfo) fileinfo); 55 ~this(); 56 57 /+ref QFileInfo operator =(ref const(QFileInfo) fileinfo);+/ 58 /+ QFileInfo &operator=(QFileInfo &&other) noexcept { swap(other); return *this; } +/ 59 60 /+ void swap(QFileInfo &other) noexcept 61 { qSwap(d_ptr, other.d_ptr); } +/ 62 63 /+bool operator ==(ref const(QFileInfo) fileinfo) const;+/ 64 /+pragma(inline, true) bool operator !=(ref const(QFileInfo) fileinfo) const { return !(operator==(fileinfo)); }+/ 65 66 void setFile(ref const(QString) file); 67 //void setFile(const QFile &file); 68 void setFile(ref const(QDir) dir, ref const(QString) file); 69 bool exists() const; 70 static bool exists(ref const(QString) file); 71 void refresh(); 72 73 QString filePath() const; 74 QString absoluteFilePath() const; 75 QString canonicalFilePath() const; 76 QString fileName() const; 77 QString baseName() const; 78 QString completeBaseName() const; 79 QString suffix() const; 80 QString bundleName() const; 81 QString completeSuffix() const; 82 83 QString path() const; 84 QString absolutePath() const; 85 QString canonicalPath() const; 86 QDir dir() const; 87 QDir absoluteDir() const; 88 89 bool isReadable() const; 90 bool isWritable() const; 91 bool isExecutable() const; 92 bool isHidden() const; 93 bool isNativePath() const; 94 95 bool isRelative() const; 96 pragma(inline, true) bool isAbsolute() const { return !isRelative(); } 97 bool makeAbsolute(); 98 99 bool isFile() const; 100 bool isDir() const; 101 bool isSymLink() const; 102 bool isSymbolicLink() const; 103 bool isShortcut() const; 104 bool isJunction() const; 105 bool isRoot() const; 106 bool isBundle() const; 107 108 /+ #if QT_DEPRECATED_SINCE(5, 13) +/ 109 /+ QT_DEPRECATED_X("Use QFileInfo::symLinkTarget() instead") +/ 110 QString readLink() const; 111 /+ #endif +/ 112 QString symLinkTarget() const; 113 114 QString owner() const; 115 uint ownerId() const; 116 QString group() const; 117 uint groupId() const; 118 119 bool permission(QFile.Permissions permissions) const; 120 QFile.Permissions permissions() const; 121 122 qint64 size() const; 123 124 // ### Qt6: inline these functions 125 /+ #if QT_DEPRECATED_SINCE(5, 10) +/ 126 /+ QT_DEPRECATED_X("Use either birthTime() or metadataChangeTime()") +/ 127 QDateTime created() const; 128 /+ #endif +/ 129 QDateTime birthTime() const; 130 QDateTime metadataChangeTime() const; 131 QDateTime lastModified() const; 132 QDateTime lastRead() const; 133 QDateTime fileTime(QFile.FileTime time) const; 134 135 bool caching() const; 136 void setCaching(bool on); 137 138 protected: 139 QSharedDataPointer!(QFileInfoPrivate) d_ptr; 140 141 private: 142 /+ friend class QFileInfoGatherer; +/ 143 void stat(); 144 /+ QFileInfoPrivate* d_func(); +/ 145 /+ inline const QFileInfoPrivate* d_func() const 146 { 147 return d_ptr.constData(); 148 } +/ 149 } 150 151 /+ Q_DECLARE_SHARED(QFileInfo) +/ 152 153 alias QFileInfoList = QList!(QFileInfo); 154 155 /+ #ifndef QT_NO_DEBUG_STREAM 156 Q_CORE_EXPORT QDebug operator<<(QDebug, const QFileInfo &); 157 #endif 158 159 160 Q_DECLARE_METATYPE(QFileInfo) +/ 161