1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtCore module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QFILESYSTEMENGINE_P_H
41#define QFILESYSTEMENGINE_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include "qfile.h"
55#include "qfilesystementry_p.h"
56#include "qfilesystemmetadata_p.h"
57#include <QtCore/private/qsystemerror_p.h>
58
59QT_BEGIN_NAMESPACE
60
61class QFileSystemEngine
62{
63public:
64 static bool isCaseSensitive()
65 {
66#ifndef Q_OS_WIN
67 return true;
68#else
69 return false;
70#endif
71 }
72
73 static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data);
74 static QFileSystemEntry canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data);
75 static QFileSystemEntry absoluteName(const QFileSystemEntry &entry);
76 static QByteArray id(const QFileSystemEntry &entry);
77 static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data);
78 static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data);
79
80#if defined(Q_OS_UNIX)
81 static QString resolveUserName(uint userId);
82 static QString resolveGroupName(uint groupId);
83#endif
84
85#if defined(Q_OS_DARWIN)
86 static QString bundleName(const QFileSystemEntry &entry);
87#else
88 static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); }
89#endif
90
91 static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data,
92 QFileSystemMetaData::MetaDataFlags what);
93#if defined(Q_OS_UNIX)
94 static bool cloneFile(int srcfd, int dstfd, const QFileSystemMetaData &knownData);
95 static bool fillMetaData(int fd, QFileSystemMetaData &data); // what = PosixStatFlags
96 static QByteArray id(int fd);
97 static bool setFileTime(int fd, const QDateTime &newDate,
98 QAbstractFileEngine::FileTime whatTime, QSystemError &error);
99 static bool setPermissions(int fd, QFile::Permissions permissions, QSystemError &error,
100 QFileSystemMetaData *data = nullptr);
101#endif
102#if defined(Q_OS_WIN)
103
104 static bool uncListSharesOnServer(const QString &server, QStringList *list); //Used also by QFSFileEngineIterator::hasNext()
105 static bool fillMetaData(int fd, QFileSystemMetaData &data,
106 QFileSystemMetaData::MetaDataFlags what);
107 static bool fillMetaData(HANDLE fHandle, QFileSystemMetaData &data,
108 QFileSystemMetaData::MetaDataFlags what);
109 static bool fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data,
110 QFileSystemMetaData::MetaDataFlags what);
111 static QByteArray id(HANDLE fHandle);
112 static bool setFileTime(HANDLE fHandle, const QDateTime &newDate,
113 QAbstractFileEngine::FileTime whatTime, QSystemError &error);
114 static QString owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own);
115 static QString nativeAbsoluteFilePath(const QString &path);
116#endif
117 //homePath, rootPath and tempPath shall return clean paths
118 static QString homePath();
119 static QString rootPath();
120 static QString tempPath();
121
122 static bool createDirectory(const QFileSystemEntry &entry, bool createParents);
123 static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents);
124
125 static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error);
126
127 static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error);
128 static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error);
129 static bool renameOverwriteFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error);
130 static bool removeFile(const QFileSystemEntry &entry, QSystemError &error);
131
132 static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error,
133 QFileSystemMetaData *data = nullptr);
134
135 // unused, therefore not implemented
136 static bool setFileTime(const QFileSystemEntry &entry, const QDateTime &newDate,
137 QAbstractFileEngine::FileTime whatTime, QSystemError &error);
138
139 static bool setCurrentPath(const QFileSystemEntry &entry);
140 static QFileSystemEntry currentPath();
141
142 static QAbstractFileEngine *resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry,
143 QFileSystemMetaData &data);
144private:
145 static QString slowCanonicalized(const QString &path);
146#if defined(Q_OS_WIN)
147 static void clearWinStatData(QFileSystemMetaData &data);
148#endif
149};
150
151QT_END_NAMESPACE
152
153#endif // include guard
154