9#include <QtCore/qfiledevice.h>
10#include <QtCore/qstring.h>
16#error qfile.h must be included before any header file that defines open
21#if defined(Q_OS_WIN) || defined(Q_QDOC)
23#if QT_DEPRECATED_SINCE(6
,6
)
24QT_DEPRECATED_VERSION_X_6_6(
"Use QNtfsPermissionCheckGuard RAII class instead.")
25Q_CORE_EXPORT
extern int qt_ntfs_permission_lookup;
28Q_CORE_EXPORT
bool qEnableNtfsPermissionChecks()
noexcept;
29Q_CORE_EXPORT
bool qDisableNtfsPermissionChecks()
noexcept;
30Q_CORE_EXPORT
bool qAreNtfsPermissionChecksEnabled()
noexcept;
32class QNtfsPermissionCheckGuard
34 Q_DISABLE_COPY_MOVE(QNtfsPermissionCheckGuard)
37 QNtfsPermissionCheckGuard()
39 qEnableNtfsPermissionChecks();
42 ~QNtfsPermissionCheckGuard()
44 qDisableNtfsPermissionChecks();
49#if QT_CONFIG(cxx17_filesystem)
56using ForceFilesystemPath =
typename std::enable_if_t<std::is_same_v<std::filesystem::path, T>,
int>;
64#if (QT_VERSION >= QT_VERSION_CHECK(6
, 9
, 0
)) || defined(QT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH)
65# define QFILE_MAYBE_EXPLICIT explicit
67# define QFILE_MAYBE_EXPLICIT Q_IMPLICIT
70class Q_CORE_EXPORT
QFile :
public QFileDevice
75 Q_DECLARE_PRIVATE(QFile)
81 QFILE_MAYBE_EXPLICIT QFile(
const std::filesystem::path &name);
82#elif QT_CONFIG(cxx17_filesystem)
83 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
84 QFILE_MAYBE_EXPLICIT QFile(
const T &name) : QFile(QtPrivate::fromFilesystemPath(name))
90 explicit QFile(QObject *parent);
91 QFile(
const QString &name, QObject *parent);
94 QFile(
const std::filesystem::path &path, QObject *parent);
95#elif QT_CONFIG(cxx17_filesystem)
96 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
97 QFile(
const T &path, QObject *parent) : QFile(QtPrivate::fromFilesystemPath(path), parent)
104 QString fileName()
const override;
105#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
106 std::filesystem::path filesystemFileName()
const
107 {
return QtPrivate::toFilesystemPath(fileName()); }
109 void setFileName(
const QString &name);
111 void setFileName(
const std::filesystem::path &name);
112#elif QT_CONFIG(cxx17_filesystem)
113 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
114 void setFileName(
const T &name)
116 setFileName(QtPrivate::fromFilesystemPath(name));
120#if defined(Q_OS_DARWIN)
122 static inline QByteArray encodeName(
const QString &fileName)
124 return fileName.normalized(QString::NormalizationForm_D).toUtf8();
126 static QString decodeName(
const QByteArray &localFileName)
129 return QString::fromUtf8(localFileName).normalized(QString::NormalizationForm_C);
131 static inline QString decodeName(
const char *localFileName)
133 return QString::fromUtf8(localFileName).normalized(QString::NormalizationForm_C);
136 static inline QByteArray encodeName(
const QString &fileName)
138 return fileName.toLocal8Bit();
140 static QString decodeName(
const QByteArray &localFileName)
142 return QString::fromLocal8Bit(localFileName);
144 static inline QString decodeName(
const char *localFileName)
146 return QString::fromLocal8Bit(localFileName);
151 static bool exists(
const QString &fileName);
153 static bool exists(
const std::filesystem::path &fileName);
154#elif QT_CONFIG(cxx17_filesystem)
155 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
156 static bool exists(
const T &fileName)
158 return exists(QtPrivate::fromFilesystemPath(fileName));
162 QString symLinkTarget()
const;
163 static QString symLinkTarget(
const QString &fileName);
165 std::filesystem::path filesystemSymLinkTarget()
const;
166 static std::filesystem::path filesystemSymLinkTarget(
const std::filesystem::path &fileName);
167#elif QT_CONFIG(cxx17_filesystem)
168 std::filesystem::path filesystemSymLinkTarget()
const
170 return QtPrivate::toFilesystemPath(symLinkTarget());
172 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
173 static std::filesystem::path filesystemSymLinkTarget(
const T &fileName)
175 return QtPrivate::toFilesystemPath(symLinkTarget(QtPrivate::fromFilesystemPath(fileName)));
180 static bool remove(
const QString &fileName);
182 static bool remove(
const std::filesystem::path &fileName);
183#elif QT_CONFIG(cxx17_filesystem)
184 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
185 static bool remove(
const T &fileName)
187 return remove(QtPrivate::fromFilesystemPath(fileName));
191 Q_DECL_PURE_FUNCTION
static bool supportsMoveToTrash();
193 static bool moveToTrash(
const QString &fileName, QString *pathInTrash =
nullptr);
195 static bool moveToTrash(
const std::filesystem::path &fileName, QString *pathInTrash =
nullptr);
196#elif QT_CONFIG(cxx17_filesystem)
197 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
198 static bool moveToTrash(
const T &fileName, QString *pathInTrash =
nullptr)
200 return moveToTrash(QtPrivate::fromFilesystemPath(fileName), pathInTrash);
204 bool rename(
const QString &newName);
205 static bool rename(
const QString &oldName,
const QString &newName);
207 bool rename(
const std::filesystem::path &newName);
208 static bool rename(
const std::filesystem::path &oldName,
209 const std::filesystem::path &newName);
210#elif QT_CONFIG(cxx17_filesystem)
211 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
212 bool rename(
const T &newName)
214 return rename(QtPrivate::fromFilesystemPath(newName));
216 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
217 static bool rename(
const T &oldName,
const T &newName)
219 return rename(QtPrivate::fromFilesystemPath(oldName),
220 QtPrivate::fromFilesystemPath(newName));
224 bool link(
const QString &newName);
225 static bool link(
const QString &fileName,
const QString &newName);
227 bool link(
const std::filesystem::path &newName);
228 static bool link(
const std::filesystem::path &fileName,
229 const std::filesystem::path &newName);
230#elif QT_CONFIG(cxx17_filesystem)
231 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
232 bool link(
const T &newName)
234 return link(QtPrivate::fromFilesystemPath(newName));
236 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
237 static bool link(
const T &fileName,
const T &newName)
239 return link(QtPrivate::fromFilesystemPath(fileName),
240 QtPrivate::fromFilesystemPath(newName));
244#if QT_CONFIG(temporaryfile)
245 bool copy(
const QString &newName, std::optional<QFileDevice::Permissions> perm = std::nullopt);
246 static bool copy(
const QString &fileName,
const QString &newName,
247 std::optional<QFileDevice::Permissions> perm = std::nullopt);
248# if QT_CORE_REMOVED_SINCE(6
, 12
)
249 bool copy(
const QString &newName);
250 static bool copy(
const QString &fileName,
const QString &newName);
254 bool copy(
const std::filesystem::path &newName);
255 static bool copy(
const std::filesystem::path &fileName,
256 const std::filesystem::path &newName);
257#elif QT_CONFIG(cxx17_filesystem) && QT_CONFIG(temporaryfile)
258 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
259 bool copy(
const T &newName)
261 return copy(QtPrivate::fromFilesystemPath(newName));
263 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
264 static bool copy(
const T &fileName,
const T &newName)
266 return copy(QtPrivate::fromFilesystemPath(fileName),
267 QtPrivate::fromFilesystemPath(newName));
271 QFILE_MAYBE_NODISCARD
bool open(OpenMode flags) override;
272 QFILE_MAYBE_NODISCARD
bool open(OpenMode flags, Permissions permissions);
273 QFILE_MAYBE_NODISCARD
bool open(FILE *f, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle);
274 QFILE_MAYBE_NODISCARD
bool open(
int fd, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle);
276 qint64 size()
const override;
278 bool resize(qint64 sz) override;
279 static bool resize(
const QString &filename, qint64 sz);
281 Permissions permissions()
const override;
282 static Permissions permissions(
const QString &filename);
283 bool setPermissions(Permissions permissionSpec) override;
284 static bool setPermissions(
const QString &filename, Permissions permissionSpec);
286 static Permissions permissions(
const std::filesystem::path &filename);
287 static bool setPermissions(
const std::filesystem::path &filename, Permissions permissionSpec);
288#elif QT_CONFIG(cxx17_filesystem)
289 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
290 static Permissions permissions(
const T &filename)
292 return permissions(QtPrivate::fromFilesystemPath(filename));
294 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
295 static bool setPermissions(
const T &filename, Permissions permissionSpec)
297 return setPermissions(QtPrivate::fromFilesystemPath(filename), permissionSpec);
303 QFile(QFilePrivate &dd);
305 QFile(QFilePrivate &dd, QObject *parent =
nullptr);
309 friend class QTemporaryFile;
310 Q_DISABLE_COPY(QFile)
bool testFunctionAttribute(Token tok, FunctionDef *def)
void parseEnumOrFlag(BaseDef *def, QtMocConstants::EnumFlags flags)
bool hasGlobalModuleFragment
void checkSuperClasses(ClassDef *def)
bool inPrivateModuleFragment
bool parseEnum(EnumDef *def, ClassDef *containingClass)
void parseProperty(ClassDef *def, PropertyMode mode)
QByteArray lexemUntil(Token)
EncounteredQmlMacro parseClassInfo(BaseDef *def)
QList< QByteArray > includeFiles
QList< QByteArray > moduleFragmentIncludes
bool requireCompleteTypes
QHash< QByteArray, QByteArray > knownQObjectClasses
void createPropertyDef(PropertyDef &def, int propertyIndex, PropertyMode mode)
void parseClassInfo(ClassDef *def)
QByteArrayView strippedFileName() const
bool parseClassHead(ClassDef *def)
void parsePrivateProperty(ClassDef *def, PropertyMode mode)
void parseFlag(BaseDef *def)
void parsePrivateModuleFragment(qsizetype rewind)
void parseSignals(ClassDef *def)
void parseDeclareMetatype()
void parsePropertyAttributes(PropertyDef &propDef)
void parseInterfaces(ClassDef *def)
bool testFunctionRevision(FunctionDef *def)
bool testFunctionAttribute(FunctionDef *def)
void prependNamespaces(BaseDef &def, const QList< NamespaceDef > &namespaceList) const
QHash< QByteArray, QByteArray > knownGadgets
QList< QByteArray > metaTypes
bool parseFunction(FunctionDef *def, bool inMacro=false)
QByteArray parsePropertyAccessor()
QMap< QString, QJsonArray > metaArgs
bool testForFunctionModifiers(FunctionDef *def)
const QByteArray & toFullyQualified(const QByteArray &name) const noexcept
void parseSlots(ClassDef *def, FunctionDef::Access access)
void parseDeclareInterface()
void checkListSizes(const ClassDef &def)
QTypeRevision parseRevision()
QList< QString > parsedPluginMetadataFiles
qsizetype firstSourceSymbolIndex
ModuleUnitKind moduleUnitKind
bool parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
void checkProperties(ClassDef *cdef)
void parseModuleDeclaration(qsizetype rewind, bool exported)
void parseFunctionArguments(FunctionDef *def)
void parseSlotInPrivate(ClassDef *def, FunctionDef::Access access)
bool inClass(const ClassDef *def) const
void parsePluginData(ClassDef *def)
QByteArray modulePartitionName
void generate(FILE *out, FILE *jsonOutput)
QMap< QByteArray, QByteArray > interface2IdMap
bool inNamespace(const NamespaceDef *def) const
QList< ClassDef > classList
QByteArray resolveIncludeNext(const QByteArray &filename, qsizetype startIndex, qsizetype *foundIndex=nullptr)
void setDebugIncludes(bool value)
void parseDefineArguments(Macro *m)
Symbols preprocessed(const QByteArray &filename, QFile *device)
void substituteUntilNewline(Symbols &substituted)
QList< QByteArray > frameworks
QHash< QByteArray, IncludeResolution > nonlocalIncludePathResolutionCache
static bool preprocessOnly
QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo, qsizetype *foundIndex=nullptr)
static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName)
static Symbols tokenize(const QByteArray &input, int lineNum=1, TokenizeMode mode=TokenizeCpp)
static void macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, qsizetype &index, int lineNum, bool one, const QSet< QByteArray > &excludeSymbols=QSet< QByteArray >())
@ PreparePreprocessorStatement
@ TokenizePreprocessorStatement
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
The QCommandLineParser class provides a means for handling the command line options.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
std::map< Key, T > toStdMap() const &
friend size_t qHash(const M &key, size_t seed=0) noexcept(QHashPrivate::noexceptPairHash< typename M::key_type, typename M::mapped_type >())
QMap(std::map< Key, T > &&other)
std::map< Key, T > toStdMap() &&
QMap(const std::map< Key, T > &other)
friend bool comparesEqual(const QMap &lhs, const QMap &rhs)
QMap(std::initializer_list< std::pair< Key, T > > list)
void swap(QMap< Key, T > &other) noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
constexpr Integer toEncodedVersion() const
Transforms the revision into an integer value, encoding the minor version into the least significant ...
constexpr QTypeRevision()=default
Produces an invalid revision.
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
Produces a QTypeRevision from the given majorVersion with an invalid minor version.
static constexpr bool isValidSegment(Integer segment)
Returns true if the given number can be used as either major or minor version in a QTypeRevision.
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
constexpr bool hasMajorVersion() const
Returns true if the major version is known, otherwise false.
static constexpr QTypeRevision fromMinorVersion(Minor minorVersion)
Produces a QTypeRevision from the given minorVersion with an invalid major version.
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
friend constexpr Qt::strong_ordering compareThreeWay(const QTypeRevision &lhs, const QTypeRevision &rhs) noexcept
constexpr quint8 minorVersion() const
Returns the minor version encoded in the revision.
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
friend constexpr bool comparesEqual(const QTypeRevision &lhs, const QTypeRevision &rhs) noexcept
constexpr bool hasMinorVersion() const
Returns true if the minor version is known, otherwise false.
QByteArray unquotedLexem()
const Symbol & symbol() const
bool dontReplaceSymbol(const QByteArray &name) const
const SafeSymbols & constTop() const
QT_BEGIN_NAMESPACE int collectJson(const QStringList &jsonFiles, const QString &outputFile, bool skipStdIn)
Q_DECLARE_TYPEINFO(EnumDef, Q_RELOCATABLE_TYPE)
QByteArray noRef(const QByteArray &type)
Q_DECLARE_TYPEINFO(PropertyDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(NamespaceDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassInfoDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassDef::Interface, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(SuperClass, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ArgumentDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(PrivateQPropertyDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(FunctionDef, Q_RELOCATABLE_TYPE)
std::conditional_t< std::is_same_v< HashKey, q20::remove_cvref_t< KeyArgument > >, KeyArgument, HashKey > HeterogenousConstructProxy
Combined button and popup list for selecting options.
constexpr PropertyFlags DefaultPropertyFlags
@ PropertyAccessInStaticMetaCall
@ RequiresVariantMetaObject
QString && asString(QString &&s)
constexpr QAnyStringArg qStringLikeToArg(QAnyStringView s) noexcept
const QString & asString(const QString &s)
std::is_same< Char, char32_t > IsCompatibleChar32TypeHelper
constexpr bool isLatin1(QLatin1StringView s) noexcept
QHash< MacroName, Macro > Macros
Q_DECLARE_TYPEINFO(QDateTime::Data, Q_RELOCATABLE_TYPE)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
#define QFILE_MAYBE_EXPLICIT
qsizetype erase_if(QMultiHash< Key, T > &hash, Predicate pred)
#define QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(Class)
#define QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH(Class, Arguments)
#define QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(Class)
#define QT_MK_QHASH_COMPAT(X)
QList< QVariant > QVariantList
QMultiMap< Key, T > operator+=(QMultiMap< Key, T > &lhs, const QMultiMap< Key, T > &rhs)
QSet(InputIterator, InputIterator) -> QSet< ValueType >
size_t qHash(const QSet< T > &key, size_t seed=0) noexcept(noexcept(qHashRangeCommutative(key.begin(), key.end(), seed)))
qsizetype erase_if(QSet< T > &set, Predicate pred)
QString operator+(const QString &s1, QChar s2)
QString operator+(QString &&lhs, const QString &rhs)
qsizetype erase_if(QString &s, Predicate pred)
#define QT_UNICODE_LITERAL(str)
#define qPrintable(string)
QString operator+(QString &&lhs, QChar rhs)
QString operator+(QChar s1, const QString &s2)
#define QStringLiteral(str)
QString operator+(const QString &s1, const QString &s2)
qsizetype erase(QString &s, const T &t)
static QByteArray combinePath(const QString &infile, const QString &outfile)
static bool hasNext(const Symbols &symbols, int i)
static const Symbol & next(const Symbols &symbols, int &i)
int runMoc(int argc, char **argv)
static auto openFileForWriting(const QString &name)
void error(const char *msg="Invalid argument")
static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments, bool &hasOptionFiles)
QByteArray composePreprocessorOutput(const Symbols &symbols)
Q_DECLARE_TYPEINFO(QTypeRevision, Q_RELOCATABLE_TYPE)
int main(int argc, char *argv[])
[ctor_close]
QByteArray normalizedType
QJsonObject toJson() const
QMap< QByteArray, QByteArray > flagAliases
QList< ClassInfoDef > classInfoList
QList< EnumDef > enumList
Interface(const QByteArray &_className)
QMap< QString, QJsonArray > metaArgs
QList< QList< Interface > > interfaceList
QList< FunctionDef > publicList
QList< FunctionDef > methodList
QList< PropertyDef > propertyList
QList< FunctionDef > constructorList
QList< SuperClass > superclassList
bool requireCompleteMethodTypes
QList< FunctionDef > slotList
QList< FunctionDef > signalList
QJsonObject toJson() const
QList< QByteArray > nonClassSignalList
QFlags< QtMocConstants::EnumFlags > flags
QByteArray qualifiedType(const ClassDef *cdef) const
QJsonObject toJson(const ClassDef &cdef) const
QList< QByteArray > values
QByteArray normalizedType
QJsonObject toJson(int index) const
static void accessToJson(QJsonObject *obj, Access acs)
QByteArray inPrivateClass
QList< ArgumentDef > arguments
bool returnTypeIsVolatile
Simple structure used by the Doc and DocParser classes.
QByteArray inPrivateClass
QJsonObject toJson() const
constexpr QAnyStringArg(QAnyStringView v) noexcept
constexpr QLatin1StringArg(QLatin1StringView v) noexcept
QLatin1StringArg()=default
constexpr QStringViewArg(QStringView v) noexcept
bool operator==(const SubArray &other) const
SubArray(const QByteArray &a)
SubArray(const QByteArray &a, qsizetype from, qsizetype len)
FunctionDef::Access access
QByteArrayView unquotedLexemView() const
Symbol(int lineNum, Token token)
operator SubArray() const
QByteArrayView lexemView() const
void mergeStringLiteral(const Symbol &next)
bool operator==(const Symbol &o) const
Symbol(int lineNum, Token token, const QByteArray &lexem, qsizetype from, qsizetype len)
QByteArray unquotedLexem() const
Symbol(int lineNum, Token token, const QByteArray &lexem)
size_t qHash(const SubArray &key, size_t seed=0)
Q_DECLARE_TYPEINFO(Symbol, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(SafeSymbols, Q_RELOCATABLE_TYPE)
#define FOR_ALL_TOKENS(F)