Bootstrap: remove QTemporaryFile

Done by harmonizing the use on the QT_CONFIG(temporaryfile) macro and
fixing one test that was missing. We can't remove the older macro
because it is marked PBULIC) but we don't need to use it ourselves.

Change-Id: I01ec3c774d9943adb903fffd17b7eb4dd1a4e63f
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
Thiago Macieira 2024-02-27 20:08:23 -08:00
parent 7942f7eedf
commit b57a9a3cd9
12 changed files with 22 additions and 23 deletions

View File

@ -84,7 +84,7 @@
#define QT_FEATURE_slog2 -1
#define QT_FEATURE_syslog -1
#define QT_NO_SYSTEMLOCALE
#define QT_FEATURE_temporaryfile 1
#define QT_FEATURE_temporaryfile -1
#define QT_FEATURE_textdate 1
#undef QT_FEATURE_thread
#define QT_FEATURE_thread -1

View File

@ -584,7 +584,7 @@ QFile::rename(const QString &newName)
return false;
}
#ifdef Q_OS_LINUX
#if defined(Q_OS_LINUX) && QT_CONFIG(temporaryfile)
// rename() on Linux simply does nothing when renaming "foo" to "Foo" on a case-insensitive
// FS, such as FAT32. Move the file away and rename in 2 steps to work around.
QTemporaryFileName tfn(d->fileName);
@ -789,7 +789,7 @@ QFile::copy(const QString &newName)
d->setError(QFile::CopyError, tr("Cannot open %1 for input").arg(d->fileName));
} else {
const auto fileTemplate = "%1/qt_temp.XXXXXX"_L1;
#ifdef QT_NO_TEMPORARYFILE
#if !QT_CONFIG(temporaryfile)
QFile out(fileTemplate.arg(QFileInfo(newName).path()));
if (!out.open(QIODevice::ReadWrite))
error = true;
@ -841,7 +841,7 @@ QFile::copy(const QString &newName)
.arg(newName, out.errorString()));
}
}
#ifdef QT_NO_TEMPORARYFILE
#if !QT_CONFIG(temporaryfile)
if (error)
out.remove();
#else

View File

@ -3,7 +3,7 @@
#include "qsavefile.h"
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
#include "qplatformdefs.h"
#include "private/qsavefile_p.h"
@ -412,4 +412,4 @@ QT_END_NAMESPACE
#include "moc_qsavefile.cpp"
#endif
#endif // QT_NO_TEMPORARYFILE
#endif // QT_CONFIG(temporaryfile)

View File

@ -6,7 +6,7 @@
#include <QtCore/qglobal.h>
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
#include <QtCore/qfiledevice.h>
#include <QtCore/qstring.h>
@ -62,6 +62,6 @@ private:
QT_END_NAMESPACE
#endif // QT_NO_TEMPORARYFILE
#endif // QT_CONFIG(temporaryfile)
#endif // QSAVEFILE_H

View File

@ -17,7 +17,7 @@
#include <QtCore/qglobal.h>
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
#include "private/qfiledevice_p.h"
@ -42,6 +42,6 @@ protected:
QT_END_NAMESPACE
#endif // QT_NO_TEMPORARYFILE
#endif // QT_CONFIG(temporaryfile)
#endif // QSAVEFILE_P_H

View File

@ -129,12 +129,12 @@ bool QConfFile::isWritable() const
{
QFileInfo fileInfo(name);
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
if (fileInfo.exists()) {
#endif
QFile file(name);
return file.open(QFile::ReadWrite);
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
} else {
// Create the directories to the file.
QDir dir(fileInfo.absolutePath());

View File

@ -4,7 +4,7 @@
#include "qtemporarydir.h"
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
#include "qdebug.h"
#include "qplatformdefs.h"
@ -324,4 +324,4 @@ bool QTemporaryDir::remove()
QT_END_NAMESPACE
#endif // QT_NO_TEMPORARYFILE
#endif // QT_CONFIG(temporaryfile)

View File

@ -11,7 +11,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
class QTemporaryDirPrivate;
@ -52,7 +52,7 @@ inline void swap(QTemporaryDir &lhs, QTemporaryDir &rhs) noexcept
lhs.swap(rhs);
}
#endif // QT_NO_TEMPORARYFILE
#endif // QT_CONFIG(temporaryfile)
QT_END_NAMESPACE

View File

@ -156,7 +156,7 @@ QFileSystemEntry::NativePath QTemporaryFileName::generateNext()
return path;
}
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
/*!
\internal
@ -969,7 +969,7 @@ bool QTemporaryFile::open(OpenMode flags)
return false;
}
#endif // QT_NO_TEMPORARYFILE
#endif // QT_CONFIG(temporaryfile)
QT_END_NAMESPACE

View File

@ -14,7 +14,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
class QTemporaryFilePrivate;
class QLockFilePrivate;
@ -94,7 +94,7 @@ private:
Q_DISABLE_COPY(QTemporaryFile)
};
#endif // QT_NO_TEMPORARYFILE
#endif // QT_CONFIG(temporaryfile)
QT_END_NAMESPACE

View File

@ -45,7 +45,7 @@ struct QTemporaryFileName
QFileSystemEntry::NativePath generateNext();
};
#ifndef QT_NO_TEMPORARYFILE
#if QT_CONFIG(temporaryfile)
class QTemporaryFilePrivate : public QFilePrivate
{
@ -116,7 +116,7 @@ public:
bool unnamedFile = false;
};
#endif // QT_NO_TEMPORARYFILE
#endif // QT_CONFIG(temporaryfile)
QT_END_NAMESPACE

View File

@ -39,7 +39,6 @@ qt_internal_extend_target(Bootstrap
../../corelib/io/qresource.cpp
../../corelib/io/qsavefile.cpp
../../corelib/io/qstandardpaths.cpp
../../corelib/io/qtemporaryfile.cpp
../../corelib/kernel/qcoreapplication.cpp
../../corelib/kernel/qiterable.cpp
../../corelib/kernel/qmetacontainer.cpp