Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qfilesystementry_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QFILESYSTEMENTRY_P_H
5#define QFILESYSTEMENTRY_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19#include <QtCore/qstring.h>
20#include <QtCore/qbytearray.h>
21
23
24class QFileSystemEntry
25{
26public:
27
28#ifndef Q_OS_WIN
29 typedef QByteArray NativePath;
30#else
31 typedef QString NativePath;
32#endif
33 struct FromNativePath{};
34 struct FromInternalPath{};
35
36 Q_AUTOTEST_EXPORT QFileSystemEntry();
37 Q_AUTOTEST_EXPORT explicit QFileSystemEntry(const QString &filePath);
38
39 Q_AUTOTEST_EXPORT QFileSystemEntry(const QString &filePath, FromInternalPath dummy);
40 Q_AUTOTEST_EXPORT QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath dummy);
41 Q_AUTOTEST_EXPORT QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath);
42
43 Q_AUTOTEST_EXPORT QString filePath() const;
44 Q_AUTOTEST_EXPORT QString fileName() const;
45 Q_AUTOTEST_EXPORT QString path() const;
46 Q_AUTOTEST_EXPORT NativePath nativeFilePath() const;
47 Q_AUTOTEST_EXPORT QString baseName() const;
48 Q_AUTOTEST_EXPORT QString completeBaseName() const;
49 Q_AUTOTEST_EXPORT QString suffix() const;
50 Q_AUTOTEST_EXPORT QString completeSuffix() const;
51 Q_AUTOTEST_EXPORT bool isAbsolute() const;
52 Q_AUTOTEST_EXPORT bool isRelative() const;
53 Q_AUTOTEST_EXPORT bool isClean() const;
54
55#if defined(Q_OS_WIN)
56 Q_AUTOTEST_EXPORT bool isDriveRoot() const;
57 static bool isDriveRootPath(const QString &path);
58 static QString removeUncOrLongPathPrefix(QString path);
59#endif
60 Q_AUTOTEST_EXPORT bool isRoot() const;
61
62 Q_AUTOTEST_EXPORT bool isEmpty() const;
63
64 void clear()
65 {
66 *this = QFileSystemEntry();
67 }
68
69 Q_CORE_EXPORT static bool isRootPath(const QString &path);
70
71private:
72 // creates the QString version out of the bytearray version
73 void resolveFilePath() const;
74 // creates the bytearray version out of the QString version
75 void resolveNativeFilePath() const;
76 // resolves the separator
77 void findLastSeparator() const;
78 // resolves the dots and the separator
79 void findFileNameSeparators() const;
80
81 mutable QString m_filePath; // always has slashes as separator
82 mutable NativePath m_nativeFilePath; // native encoding and separators
83
84 mutable qint16 m_lastSeparator; // index in m_filePath of last separator
85 mutable qint16 m_firstDotInFileName; // index after m_filePath for first dot (.)
86 mutable qint16 m_lastDotInFileName; // index after m_firstDotInFileName for last dot (.)
87};
88
89QT_END_NAMESPACE
90
91#endif // include guard
\inmodule QtCore
Definition qcollator.h:44
bool operator()(const QDirSortItem &, const QDirSortItem &) const
Definition qdir.cpp:240
QDirSortItemComparator(QDir::SortFlags flags, QCollator *coll=nullptr)
Definition qdir.cpp:214
int compareStrings(const QString &a, const QString &b, Qt::CaseSensitivity cs) const
Definition qdir.cpp:230
\inmodule QtCore
Definition qmutex.h:313
Combined button and popup list for selecting options.
static qsizetype rootLength(QStringView name)
Definition qdir.cpp:55
static bool qt_cleanPath(QString *path)
Definition qdir.cpp:2356
QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2439
QDebug operator<<(QDebug debug, const QDir &dir)
Definition qdir.cpp:2491
static QDebug operator<<(QDebug debug, QDir::SortFlags sorting)
Definition qdir.cpp:2467
bool comparesEqual(const QDir &lhs, const QDir &rhs)
Definition qdir.cpp:1812
static bool treatAsAbsolute(const QString &path)
Definition qdir.cpp:749
bool qt_normalizePathSegments(QString *path, QDirPrivate::PathNormalizations flags)
Definition qdir.cpp:2217
Q_AUTOTEST_EXPORT bool qt_normalizePathSegments(QString *path, QDirPrivate::PathNormalizations flags)
Definition qdir.cpp:2217
QFileInfo item
Definition qdir.cpp:202
QString suffix_cache
Definition qdir.cpp:201
QDirSortItem(const QFileInfo &fi, QDir::SortFlags sort)
Definition qdir.cpp:190
QDirSortItem()=default
QString filename_cache
Definition qdir.cpp:200