8#include <QtCore/qfiledevice.h>
9#include <QtCore/qstring.h>
12#if QT_CONFIG(cxx17_filesystem)
16 namespace filesystem {
24#error qfile.h must be included before any header file that defines open
31#if QT_DEPRECATED_SINCE(6,6)
40class QNtfsPermissionCheckGuard
42 Q_DISABLE_COPY_MOVE(QNtfsPermissionCheckGuard)
45 QNtfsPermissionCheckGuard()
50 ~QNtfsPermissionCheckGuard()
57#if QT_CONFIG(cxx17_filesystem)
59inline QString fromFilesystemPath(
const std::filesystem::path &
path)
68inline std::filesystem::path toFilesystemPath(
const QString &
path)
70 return std::filesystem::path(
reinterpret_cast<const char16_t *
>(
path.cbegin()),
71 reinterpret_cast<const char16_t *
>(
path.cend()));
78using ForceFilesystemPath =
typename std::enable_if_t<std::is_same_v<std::filesystem::path, T>,
int>;
86#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) || defined(QT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH)
87# define QFILE_MAYBE_EXPLICIT explicit
89# define QFILE_MAYBE_EXPLICIT Q_IMPLICIT
97 Q_DECLARE_PRIVATE(
QFile)
104#elif QT_CONFIG(cxx17_filesystem)
105 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
117#elif QT_CONFIG(cxx17_filesystem)
118 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
127#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
128 std::filesystem::path filesystemFileName()
const
129 {
return QtPrivate::toFilesystemPath(
fileName()); }
134#elif QT_CONFIG(cxx17_filesystem)
135 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
142#if defined(Q_OS_DARWIN)
153 static inline QString decodeName(
const char *localFileName)
175 static bool exists(
const std::filesystem::path &
fileName);
176#elif QT_CONFIG(cxx17_filesystem)
177 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
178 static bool exists(
const T &
fileName)
180 return exists(QtPrivate::fromFilesystemPath(
fileName));
187 std::filesystem::path filesystemSymLinkTarget()
const;
188 static std::filesystem::path filesystemSymLinkTarget(
const std::filesystem::path &
fileName);
189#elif QT_CONFIG(cxx17_filesystem)
190 std::filesystem::path filesystemSymLinkTarget()
const
192 return QtPrivate::toFilesystemPath(symLinkTarget());
194 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
195 static std::filesystem::path filesystemSymLinkTarget(
const T &
fileName)
197 return QtPrivate::toFilesystemPath(symLinkTarget(QtPrivate::fromFilesystemPath(
fileName)));
205#elif QT_CONFIG(cxx17_filesystem)
206 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
216 static bool moveToTrash(
const std::filesystem::path &
fileName,
QString *pathInTrash =
nullptr);
217#elif QT_CONFIG(cxx17_filesystem)
218 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
219 static bool moveToTrash(
const T &
fileName,
QString *pathInTrash =
nullptr)
221 return moveToTrash(QtPrivate::fromFilesystemPath(
fileName), pathInTrash);
225 bool rename(
const QString &newName);
226 static bool rename(
const QString &oldName,
const QString &newName);
228 bool rename(
const std::filesystem::path &newName);
229 static bool rename(
const std::filesystem::path &oldName,
230 const std::filesystem::path &newName);
231#elif QT_CONFIG(cxx17_filesystem)
232 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
233 bool rename(
const T &newName)
235 return rename(QtPrivate::fromFilesystemPath(newName));
237 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
238 static bool rename(
const T &oldName,
const T &newName)
240 return rename(QtPrivate::fromFilesystemPath(oldName),
241 QtPrivate::fromFilesystemPath(newName));
245 bool link(
const QString &newName);
248 bool link(
const std::filesystem::path &newName);
249 static bool link(
const std::filesystem::path &
fileName,
250 const std::filesystem::path &newName);
251#elif QT_CONFIG(cxx17_filesystem)
252 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
253 bool link(
const T &newName)
255 return link(QtPrivate::fromFilesystemPath(newName));
257 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
258 static bool link(
const T &
fileName,
const T &newName)
260 return link(QtPrivate::fromFilesystemPath(
fileName),
261 QtPrivate::fromFilesystemPath(newName));
268 bool copy(
const std::filesystem::path &newName);
270 const std::filesystem::path &newName);
271#elif QT_CONFIG(cxx17_filesystem)
272 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
273 bool copy(
const T &newName)
275 return copy(QtPrivate::fromFilesystemPath(newName));
277 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
281 QtPrivate::fromFilesystemPath(newName));
287 bool open(FILE *
f, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle);
288 bool open(
int fd, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle);
300 static Permissions
permissions(
const std::filesystem::path &filename);
301 static bool setPermissions(
const std::filesystem::path &filename, Permissions permissionSpec);
302#elif QT_CONFIG(cxx17_filesystem)
303 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
306 return permissions(QtPrivate::fromFilesystemPath(filename));
308 template<
typename T, QtPrivate::ForceFilesystemPath<T> = 0>
309 static bool setPermissions(
const T &filename, Permissions permissionSpec)
311 return setPermissions(QtPrivate::fromFilesystemPath(filename), permissionSpec);
324 Q_DISABLE_COPY(
QFile)
qint64 size() const override
Returns the size of the file.
virtual bool resize(qint64 sz)
Sets the file size (in bytes) sz.
virtual QString fileName() const
Returns the name of the file.
virtual bool setPermissions(Permissions permissionSpec)
Sets the permissions for the file to the permissions specified.
virtual Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permission for the file.
bool open(OpenMode flags, Permissions permissions)
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
static QString decodeName(const char *localFileName)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromStdString(const std::string &s)
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromStdWString(const std::wstring &s)
Returns a copy of the str string.
QString normalized(NormalizationForm mode, QChar::UnicodeVersion version=QChar::Unicode_Unassigned) const
Returns the string in the given Unicode normalization mode, according to the given version of the Uni...
\inmodule QtCore \reentrant
Combined button and popup list for selecting options.
qAreNtfsPermissionChecksEnabled()
[raii]
Q_CORE_EXPORT int qt_ntfs_permission_lookup
[0]
qEnableNtfsPermissionChecks()
qDisableNtfsPermissionChecks()
static jboolean copy(JNIEnv *, jobject)
#define QFILE_MAYBE_EXPLICIT
GLsizei const GLchar *const * path
#define QT_DEPRECATED_VERSION_X_6_6(text)
file setFileName("readme.txt")
settings remove("monkey")
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent