41 #include "qplatformdefs.h"
49 #include "private/qiodevice_p.h"
50 #include "private/qfile_p.h"
51 #include "private/qfilesystemengine_p.h"
52 #include "private/qsystemerror_p.h"
53 #include "private/qtemporaryfile_p.h"
54 #if defined(QT_BUILD_CORE_LIB)
59 #define tr(X) QString::fromLatin1(X)
65 static bool file_already_open(
QFile &
file,
const char *where =
nullptr)
67 qWarning(
"QFile::%s: File (%ls) already open", where ? where :
"open", qUtf16Printable(
file.
fileName()));
83 #ifdef QT_NO_FSFILEENGINE
88 auto fs = std::make_unique<QFSFileEngine>();
98 #ifdef QT_NO_FSFILEENGINE
103 auto fs = std::make_unique<QFSFileEngine>();
331 file_already_open(*
this,
"setFileName");
334 d->fileEngine.reset();
447 if (
d->fileName.isEmpty() &&
449 qWarning(
"QFile::remove: Empty or null file name");
455 if (
d->engine()->remove()) {
495 if (
d->fileName.isEmpty() &&
497 qWarning(
"QFile::remove: Empty or null file name");
564 qWarning(
"QFile::rename: Empty or null file name");
567 if (
d->fileName == newName) {
579 bool changingCase =
false;
583 d->fileEngine->id() :
597 for (
int attempt = 0; attempt < 16; ++attempt) {
606 d->fileEngine->setFileName(newName);
607 d->fileName = newName;
618 tr(
"Error while renaming: %1").
arg(
error.toString())
620 +
tr(
"Unable to restore from %1: %2").
625 tr(
"Error while renaming: %1").
arg(
error.toString()));
632 if (changingCase ?
d->engine()->renameOverwrite(newName) :
d->engine()->rename(newName)) {
635 d->fileEngine->setFileName(newName);
636 d->fileName = newName;
652 if (bytes !=
out.write(
block, bytes)) {
671 d->fileEngine->setFileName(newName);
681 tr(
"Cannot open destination file: %1").
arg(
out.errorString()));
704 return QFile(oldName).rename(newName);
728 qWarning(
"QFile::link: Empty or null file name");
770 qWarning(
"QFile::copy: Empty or null file name");
783 if (
d->engine()->copy(newName)) {
792 const auto fileTemplate =
QLatin1String(
"%1/qt_temp.XXXXXX");
793 #ifdef QT_NO_TEMPORARYFILE
810 if (!
d->engine()->cloneTo(
out.d_func()->engine())) {
827 if (totalRead !=
size()) {
836 out.d_func()->fileEngine->syncToDisk();
838 if (!
out.rename(newName)) {
842 .
arg(newName,
out.errorString()));
845 #ifdef QT_NO_TEMPORARYFILE
850 out.setAutoRemove(
false);
901 return file_already_open(*
this);
907 qWarning(
"QIODevice::open: File access not specified");
921 d->setError(err,
d->fileEngine->errorString());
946 return file_already_open(*
this);
952 qWarning(
"QIODevice::open: File access not specified");
966 d->setError(err,
d->fileEngine->errorString());
1016 return file_already_open(*
this);
1022 qWarning(
"QFile::open: File access not specified");
1068 return file_already_open(*
this);
1074 qWarning(
"QFile::open: File access not specified");
1269 #ifndef QT_NO_QOBJECT
1270 #include "moc_qfile.cpp"
static QAbstractFileEngine * create(const QString &fileName)
The QByteArray class provides an array of bytes.
bool isNull() const noexcept
static QString tempPath()
static QString toNativeSeparators(const QString &pathName)
The QFSFileEngine class implements Qt's default file engine.
virtual bool isUnnamedFile() const
The QFileDevice class provides an interface for reading from and writing to open files.
qint64 pos() const override
bool seek(qint64 offset) override
qint64 size() const override
virtual bool resize(qint64 sz)
bool atEnd() const override
bool isSequential() const override
virtual QString fileName() const
virtual bool setPermissions(Permissions permissionSpec)
virtual Permissions permissions() const
std::unique_ptr< QAbstractFileEngine > fileEngine
QFileDevice::FileHandleFlags handleFlags
The QFile class provides an interface for reading from and writing to files.
bool open(OpenMode flags) override
bool setPermissions(Permissions permissionSpec) override
QString symLinkTarget() const
bool link(const QString &newName)
bool copy(const QString &newName)
void setFileName(const QString &name)
QString fileName() const override
Permissions permissions() const override
bool rename(const QString &newName)
qint64 size() const override
bool resize(qint64 sz) override
The QFileInfo class provides system-independent file information.
QString symLinkTarget() const
QString absoluteFilePath() const
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)
virtual bool open(QIODeviceBase::OpenMode mode)
QString errorString() const
virtual bool seek(qint64 pos)
qint64 read(char *data, qint64 maxlen)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QObject class is the base class of all Qt objects.
The QString class provides a Unicode character string.
The QTemporaryFile class is an I/O device that operates on temporary files.
#define Q_DECL_COLD_FUNCTION
GLsizei const GLchar *const * path
QFileInfo fi("c:/temp/foo")
[newstuff]
QTextStream out(stdout)
[7]
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QFileSystemEntry::NativePath generateNext()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent