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.file; 15 extern(C++): 16 17 import core.stdc.stdio; 18 import qt.config; 19 import qt.core.bytearray; 20 import qt.core.filedevice; 21 import qt.core.global; 22 import qt.core.object; 23 import qt.core.string; 24 import qt.helpers; 25 26 /+ #ifdef open 27 #error qfile.h must be included before any header file that defines open 28 #endif +/ 29 30 31 extern(C++, class) struct QTemporaryFile; 32 extern(C++, class) struct QFilePrivate; 33 34 class /+ Q_CORE_EXPORT +/ QFile : QFileDevice 35 { 36 /+ #ifndef QT_NO_QOBJECT +/ 37 mixin(Q_OBJECT); 38 /+ #endif 39 Q_DECLARE_PRIVATE(QFile) +/ 40 41 public: 42 this(); 43 this(ref const(QString) name); 44 /+ #ifndef QT_NO_QOBJECT +/ 45 /+ explicit +/this(QObject parent); 46 this(ref const(QString) name, QObject parent); 47 /+ #endif +/ 48 ~this(); 49 50 override QString fileName() const; 51 final void setFileName(ref const(QString) name); 52 53 /+ #if defined(Q_OS_DARWIN) +/ 54 // Mac always expects filenames in UTF-8... and decomposed... 55 static if((versionIsSet!("OSX") || versionIsSet!("iOS") || versionIsSet!("TVOS") || versionIsSet!("WatchOS"))) 56 { 57 pragma(inline, true) static QByteArray encodeName(ref const(QString) fileName) 58 { 59 return fileName.normalized(QString.NormalizationForm.NormalizationForm_D).toUtf8(); 60 } 61 static QString decodeName(ref const(QByteArray) localFileName) 62 { 63 // note: duplicated in qglobal.cpp (qEnvironmentVariable) 64 return QString.fromUtf8(localFileName).normalized(QString.NormalizationForm.NormalizationForm_C); 65 } 66 pragma(inline, true) static QString decodeName(const(char)* localFileName) 67 { 68 return QString.fromUtf8(localFileName).normalized(QString.NormalizationForm.NormalizationForm_C); 69 } 70 } 71 else 72 { 73 /+ #else +/ 74 pragma(inline, true) static QByteArray encodeName(ref const(QString) fileName) 75 { 76 return fileName.toLocal8Bit(); 77 } 78 static QString decodeName(ref const(QByteArray) localFileName) 79 { 80 return QString.fromLocal8Bit(localFileName); 81 } 82 pragma(inline, true) static QString decodeName(const(char)* localFileName) 83 { 84 return QString.fromLocal8Bit(localFileName); 85 } 86 } 87 /+ #endif 88 89 #if QT_DEPRECATED_SINCE(5,0) 90 typedef QByteArray (*EncoderFn)(const QString &fileName); 91 typedef QString (*DecoderFn)(const QByteArray &localfileName); 92 QT_DEPRECATED static void setEncodingFunction(EncoderFn) {} 93 QT_DEPRECATED static void setDecodingFunction(DecoderFn) {} 94 #endif +/ 95 96 final bool exists() const; 97 static bool exists(ref const(QString) fileName); 98 99 /+ #if QT_DEPRECATED_SINCE(5, 13) +/ 100 /+ QT_DEPRECATED_X("Use QFile::symLinkTarget() instead") +/ 101 final QString readLink() const; 102 /+ QT_DEPRECATED_X("Use QFile::symLinkTarget(QString) instead") +/ 103 static QString readLink(ref const(QString) fileName); 104 /+ #endif +/ 105 final QString symLinkTarget() const; 106 static QString symLinkTarget(ref const(QString) fileName); 107 108 final bool remove(); 109 static bool remove(ref const(QString) fileName); 110 111 final bool moveToTrash(); 112 static bool moveToTrash(ref const(QString) fileName, QString* pathInTrash = null); 113 114 final bool rename(ref const(QString) newName); 115 static bool rename(ref const(QString) oldName, ref const(QString) newName); 116 117 final bool link(ref const(QString) newName); 118 static bool link(ref const(QString) oldname, ref const(QString) newName); 119 120 /+ bool copy(const QString &newName); +/ 121 /+ static bool copy(const QString &fileName, const QString &newName); +/ 122 123 override bool open(OpenMode flags); 124 //final bool open(FILE* f, OpenMode ioFlags, FileHandleFlags handleFlags=FileHandleFlag.DontCloseHandle); 125 final bool open(int fd, OpenMode ioFlags, FileHandleFlags handleFlags=FileHandleFlag.DontCloseHandle); 126 127 override qint64 size() const; 128 129 override bool resize(qint64 sz); 130 static bool resize(ref const(QString) filename, qint64 sz); 131 132 override Permissions permissions() const; 133 static Permissions permissions(ref const(QString) filename); 134 override bool setPermissions(Permissions permissionSpec); 135 static bool setPermissions(ref const(QString) filename, Permissions permissionSpec); 136 137 protected: 138 /+ #ifdef QT_NO_QOBJECT 139 QFile(QFilePrivate &dd); 140 #else +/ 141 this(ref QFilePrivate dd, QObject parent = null); 142 /+ #endif +/ 143 144 private: 145 /+ friend class QTemporaryFile; +/ 146 /+ Q_DISABLE_COPY(QFile) +/ 147 } 148