2015-12-10 05:06:13 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
2021-01-02 01:59:24 +02:00
|
|
|
** Copyright (C) 2016-2021 Ivailo Monev
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
2019-07-02 18:13:44 +00:00
|
|
|
** This file is part of the QtCore module of the Katie Toolkit.
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2019-12-29 23:21:34 +00:00
|
|
|
**
|
2015-12-10 05:06:13 +02:00
|
|
|
** GNU Lesser General Public License Usage
|
2019-12-29 23:21:34 +00:00
|
|
|
** This file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QDIR_H
|
|
|
|
#define QDIR_H
|
|
|
|
|
|
|
|
#include <QtCore/qfileinfo.h>
|
|
|
|
#include <QtCore/qstringlist.h>
|
|
|
|
|
|
|
|
QT_BEGIN_HEADER
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
|
|
|
class QDirPrivate;
|
|
|
|
|
|
|
|
class Q_CORE_EXPORT QDir
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Filter { Dirs = 0x001,
|
|
|
|
Files = 0x002,
|
|
|
|
Drives = 0x004,
|
|
|
|
NoSymLinks = 0x008,
|
|
|
|
AllEntries = Dirs | Files | Drives,
|
|
|
|
TypeMask = 0x00f,
|
|
|
|
|
|
|
|
Readable = 0x010,
|
|
|
|
Writable = 0x020,
|
|
|
|
Executable = 0x040,
|
|
|
|
PermissionMask = 0x070,
|
|
|
|
|
|
|
|
Modified = 0x080,
|
|
|
|
Hidden = 0x100,
|
|
|
|
System = 0x200,
|
|
|
|
|
|
|
|
AccessMask = 0x3F0,
|
|
|
|
|
|
|
|
AllDirs = 0x400,
|
|
|
|
CaseSensitive = 0x800,
|
|
|
|
NoDot = 0x1000,
|
|
|
|
NoDotDot = 0x2000,
|
|
|
|
NoDotAndDotDot = NoDot | NoDotDot,
|
|
|
|
|
|
|
|
NoFilter = -1
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(Filters, Filter)
|
|
|
|
|
|
|
|
enum SortFlag { Name = 0x00,
|
|
|
|
Time = 0x01,
|
|
|
|
Size = 0x02,
|
|
|
|
Unsorted = 0x03,
|
|
|
|
SortByMask = Unsorted,
|
|
|
|
|
|
|
|
DirsFirst = 0x04,
|
|
|
|
Reversed = 0x08,
|
|
|
|
IgnoreCase = 0x10,
|
|
|
|
DirsLast = 0x20,
|
|
|
|
LocaleAware = 0x40,
|
|
|
|
Type = 0x80,
|
|
|
|
NoSort = -1
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(SortFlags, SortFlag)
|
|
|
|
|
|
|
|
QDir(const QDir &);
|
|
|
|
QDir(const QString &path = QString());
|
|
|
|
QDir(const QString &path, const QString &nameFilter,
|
|
|
|
SortFlags sort = SortFlags(Name | IgnoreCase), Filters filter = AllEntries);
|
|
|
|
~QDir();
|
|
|
|
|
|
|
|
QDir &operator=(const QDir &);
|
|
|
|
QDir &operator=(const QString &path);
|
|
|
|
#ifdef Q_COMPILER_RVALUE_REFS
|
|
|
|
inline QDir &operator=(QDir &&other)
|
|
|
|
{ qSwap(d_ptr, other.d_ptr); return *this; }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void setPath(const QString &path);
|
|
|
|
QString path() const;
|
|
|
|
QString absolutePath() const;
|
|
|
|
QString canonicalPath() const;
|
|
|
|
|
|
|
|
QString dirName() const;
|
|
|
|
QString filePath(const QString &fileName) const;
|
|
|
|
QString absoluteFilePath(const QString &fileName) const;
|
|
|
|
QString relativeFilePath(const QString &fileName) const;
|
|
|
|
|
2016-09-14 03:15:37 +00:00
|
|
|
static inline QChar separator()
|
|
|
|
{ return QLatin1Char('/'); }
|
|
|
|
static QString toNativeSeparators(const QString &pathName)
|
|
|
|
{ return pathName; }
|
|
|
|
static QString fromNativeSeparators(const QString &pathName)
|
|
|
|
{ return pathName; }
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
bool cd(const QString &dirName);
|
|
|
|
bool cdUp();
|
|
|
|
|
|
|
|
QStringList nameFilters() const;
|
|
|
|
void setNameFilters(const QStringList &nameFilters);
|
|
|
|
|
|
|
|
Filters filter() const;
|
|
|
|
void setFilter(Filters filter);
|
|
|
|
SortFlags sorting() const;
|
|
|
|
void setSorting(SortFlags sort);
|
|
|
|
|
|
|
|
uint count() const;
|
|
|
|
QString operator[](int) const;
|
|
|
|
|
|
|
|
static QStringList nameFiltersFromString(const QString &nameFilter);
|
|
|
|
|
|
|
|
QStringList entryList(Filters filters = NoFilter, SortFlags sort = NoSort) const;
|
|
|
|
QStringList entryList(const QStringList &nameFilters, Filters filters = NoFilter,
|
|
|
|
SortFlags sort = NoSort) const;
|
|
|
|
|
|
|
|
QFileInfoList entryInfoList(Filters filters = NoFilter, SortFlags sort = NoSort) const;
|
|
|
|
QFileInfoList entryInfoList(const QStringList &nameFilters, Filters filters = NoFilter,
|
|
|
|
SortFlags sort = NoSort) const;
|
|
|
|
|
|
|
|
bool mkdir(const QString &dirName) const;
|
|
|
|
bool rmdir(const QString &dirName) const;
|
|
|
|
bool mkpath(const QString &dirPath) const;
|
|
|
|
bool rmpath(const QString &dirPath) const;
|
|
|
|
|
|
|
|
bool isReadable() const;
|
|
|
|
bool exists() const;
|
|
|
|
bool isRoot() const;
|
|
|
|
|
|
|
|
static bool isRelativePath(const QString &path);
|
|
|
|
inline static bool isAbsolutePath(const QString &path) { return !isRelativePath(path); }
|
|
|
|
bool isRelative() const;
|
|
|
|
inline bool isAbsolute() const { return !isRelative(); }
|
|
|
|
bool makeAbsolute();
|
|
|
|
|
|
|
|
bool operator==(const QDir &dir) const;
|
|
|
|
inline bool operator!=(const QDir &dir) const { return !operator==(dir); }
|
|
|
|
|
|
|
|
bool remove(const QString &fileName);
|
|
|
|
bool rename(const QString &oldName, const QString &newName);
|
|
|
|
bool exists(const QString &name) const;
|
|
|
|
|
|
|
|
static bool setCurrent(const QString &path);
|
|
|
|
static inline QDir current() { return QDir(currentPath()); }
|
|
|
|
static QString currentPath();
|
|
|
|
|
|
|
|
static inline QDir home() { return QDir(homePath()); }
|
|
|
|
static QString homePath();
|
|
|
|
static inline QDir root() { return QDir(rootPath()); }
|
|
|
|
static QString rootPath();
|
|
|
|
static inline QDir temp() { return QDir(tempPath()); }
|
|
|
|
static QString tempPath();
|
|
|
|
|
|
|
|
#ifndef QT_NO_REGEXP
|
|
|
|
static bool match(const QStringList &filters, const QString &fileName);
|
|
|
|
static bool match(const QString &filter, const QString &fileName);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static QString cleanPath(const QString &path);
|
2020-01-13 21:13:31 +00:00
|
|
|
void refresh();
|
2015-12-10 05:06:13 +02:00
|
|
|
|
2020-10-16 18:08:22 +03:00
|
|
|
private:
|
|
|
|
QSharedDataPointer<QDirPrivate> d_ptr;
|
|
|
|
|
|
|
|
friend class QDirIterator;
|
2015-12-10 05:06:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::Filters)
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::SortFlags)
|
|
|
|
|
|
|
|
#ifndef QT_NO_DEBUG_STREAM
|
|
|
|
class QDebug;
|
|
|
|
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters);
|
|
|
|
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QDir &dir);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
QT_END_HEADER
|
|
|
|
|
|
|
|
#endif // QDIR_H
|