5#include "qplatformdefs.h"
13#include "private/qiodevice_p.h"
14#include "private/qfile_p.h"
15#include "private/qfilesystemengine_p.h"
16#include "private/qsystemerror_p.h"
17#include "private/qtemporaryfile_p.h"
18#if defined(QT_BUILD_CORE_LIB)
23#define tr(X) QString::fromLatin1(X)
49#ifdef QT_NO_FSFILEENGINE
54 auto fs = std::make_unique<QFSFileEngine>();
64#ifdef QT_NO_FSFILEENGINE
69 auto fs = std::make_unique<QFSFileEngine>();
309 d->fileEngine.reset();
422 if (
d->fileName.isEmpty() &&
424 qWarning(
"QFile::remove: Empty or null file name");
430 if (
d->engine()->remove()) {
470 if (
d->fileName.isEmpty() &&
472 qWarning(
"QFile::remove: Empty or null file name");
539 qWarning(
"QFile::rename: Empty or null file name");
542 if (
d->fileName == newName) {
554 bool changingCase =
false;
558 d->fileEngine->id() :
572 for (
int attempt = 0; attempt < 16; ++attempt) {
581 d->fileEngine->setFileName(newName);
582 d->fileName = newName;
593 tr(
"Error while renaming: %1").
arg(
error.toString())
595 +
tr(
"Unable to restore from %1: %2").
600 tr(
"Error while renaming: %1").
arg(
error.toString()));
607 if (changingCase ?
d->engine()->renameOverwrite(newName) :
d->engine()->rename(newName)) {
610 d->fileEngine->setFileName(newName);
611 d->fileName = newName;
626 while ((bytes =
read(block,
sizeof(block))) > 0) {
627 if (bytes !=
out.write(block, bytes)) {
646 d->fileEngine->setFileName(newName);
656 tr(
"Cannot open destination file: %1").
arg(
out.errorString()));
679 return QFile(oldName).rename(newName);
703 qWarning(
"QFile::link: Empty or null file name");
748 qWarning(
"QFile::copy: Empty or null file name");
761 if (
d->engine()->copy(newName)) {
770 const auto fileTemplate =
"%1/qt_temp.XXXXXX"_L1;
771#ifdef QT_NO_TEMPORARYFILE
788 if (!
d->engine()->cloneTo(
out.d_func()->engine())) {
796 if (
in !=
out.write(block,
in)) {
805 if (totalRead !=
size()) {
814 out.d_func()->fileEngine->syncToDisk();
816 if (!
out.rename(newName)) {
820 .
arg(newName,
out.errorString()));
823#ifdef QT_NO_TEMPORARYFILE
828 out.setAutoRemove(
false);
891 qWarning(
"QIODevice::open: File access not specified");
905 d->setError(err,
d->fileEngine->errorString());
936 qWarning(
"QIODevice::open: File access not specified");
950 d->setError(err,
d->fileEngine->errorString());
1006 qWarning(
"QFile::open: File access not specified");
1058 qWarning(
"QFile::open: File access not specified");
1255#ifndef QT_NO_QOBJECT
1256#include "moc_qfile.cpp"
\inmodule QtCore \reentrant
static QAbstractFileEngine * create(const QString &fileName)
Creates and returns a QAbstractFileEngine suitable for processing fileName.
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
static QString tempPath()
Returns the absolute canonical path of the system's temporary directory.
static QString toNativeSeparators(const QString &pathName)
virtual bool isUnnamedFile() const
std::unique_ptr< QAbstractFileEngine > fileEngine
QFileDevice::FileHandleFlags handleFlags
qint64 pos() const override
\reimp
bool seek(qint64 offset) override
For random-access devices, this function sets the current position to pos, returning true on success,...
qint64 size() const override
Returns the size of the file.
void unsetError()
Sets the file's error to QFileDevice::NoError.
virtual bool resize(qint64 sz)
Sets the file size (in bytes) sz.
bool atEnd() const override
Returns true if the end of the file has been reached; otherwise returns false.
FileError error() const
Returns the file error status.
bool isSequential() const override
Returns true if the file can only be manipulated sequentially; otherwise returns false.
virtual QString fileName() const
Returns the name of the file.
FileError
This enum describes the errors that may be returned by the error() function.
virtual bool setPermissions(Permissions permissionSpec)
Sets the permissions for the file to the permissions specified.
void close() override
Calls QFileDevice::flush() and closes the file.
virtual Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permission for the file.
\inmodule QtCore \reentrant
QString symLinkTarget() const
QString absoluteFilePath() const
Returns an absolute path including the file name.
bool exists() const
Returns true if the file exists; otherwise returns false.
QAbstractFileEngine * engine() const override
bool openExternalFile(QIODevice::OpenMode flags, int fd, QFile::FileHandleFlags handleFlags)
static QByteArray id(const QFileSystemEntry &entry)
static bool moveFileToTrash(const QFileSystemEntry &source, QFileSystemEntry &newLocation, QSystemError &error)
static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
Q_AUTOTEST_EXPORT QString filePath() const
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool setPermissions(Permissions permissionSpec) override
Sets the permissions for the file to the permissions specified.
QFile()
Constructs a QFile object.
QString symLinkTarget() const
bool link(const QString &newName)
Creates a link named linkName that points to the file currently specified by fileName().
bool copy(const QString &newName)
Copies the file named fileName() to newName.
bool remove()
Removes the file specified by fileName().
void setFileName(const QString &name)
Sets the name of the file.
QString fileName() const override
Returns the name set by setFileName() or to the QFile constructors.
Permissions permissions() const override
\reimp
~QFile()
Destroys the file object, closing it if necessary.
bool rename(const QString &newName)
Renames the file currently specified by fileName() to newName.
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qint64 size() const override
\reimp
bool resize(qint64 sz) override
\reimp
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
bool isOpen() const
Returns true if the device is open; otherwise returns false.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success,...
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
\macro QT_RESTRICTED_CAST_FROM_ASCII
\inmodule QtCore \reentrant
Combined button and popup list for selecting options.
#define Q_DECL_COLD_FUNCTION
static Q_DECL_COLD_FUNCTION bool file_already_open(QFile &file, const char *where=nullptr)
static QByteArray fileId(HANDLE handle)
GLsizei const GLchar *const * path
#define qUtf16Printable(string)
QFileInfo fi("c:/temp/foo")
[newstuff]
QTextStream out(stdout)
[7]
QFileSystemEntry::NativePath generateNext()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent