generic: remove redundant Q_OS_UNIX definition checks

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-15 09:28:30 +02:00
parent 663493317c
commit 0c5d00727e
11 changed files with 1 additions and 51 deletions

View file

@ -480,7 +480,6 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa
}
} else {
// Open existing file. *DON'T* create it if it suddenly does not exist!
#ifdef Q_OS_UNIX
int fd = KDE_open(QFile::encodeName(filePath()), O_WRONLY | O_TRUNC);
if (fd < 0) {
return false;
@ -498,15 +497,6 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa
writeEntries(locale, f, writeMap);
f.close();
fclose(fp);
#else
QFile f( filePath() );
// XXX This is broken - it DOES create the file if it is suddenly gone.
if (!f.open( QIODevice::WriteOnly | QIODevice::Truncate )) {
return false;
}
f.setTextModeEnabled(true);
writeEntries(locale, f, writeMap);
#endif
}
return true;
}

View file

@ -102,7 +102,6 @@ bool KSaveFile::open(OpenMode flags)
tempFile.setAutoRemove(false);
tempFile.setFileTemplate(d->realFileName + QLatin1String("XXXXXX.new"));
if (!tempFile.open()) {
#ifdef Q_OS_UNIX
if (d->directWriteFallback && errno == EACCES) {
QFile::setFileName(d->realFileName);
if (QFile::open(flags)) {
@ -112,7 +111,6 @@ bool KSaveFile::open(OpenMode flags)
return true;
}
}
#endif
// we only check here if the directory can be written to
// the actual filename isn't written to, but replaced later
@ -214,7 +212,6 @@ bool KSaveFile::finalize()
}
bool success = false;
#ifdef Q_OS_UNIX
static const bool extraSync = (::getenv("KDE_EXTRA_FSYNC") != 0 ? true : false);
if (extraSync) {
if (flush()) {
@ -233,7 +230,6 @@ bool KSaveFile::finalize()
}
}
}
#endif
close();

View file

@ -1192,15 +1192,11 @@ void KConfigTest::testReparent()
static void ageTimeStamp(const QString& path, int nsec)
{
#ifdef Q_OS_UNIX
QDateTime mtime = QFileInfo(path).lastModified().addSecs(-nsec);
struct utimbuf utbuf;
utbuf.actime = mtime.toTime_t();
utbuf.modtime = utbuf.actime;
utime(QFile::encodeName(path), &utbuf);
#else
QTest::qSleep(nsec * 1000);
#endif
}
void KConfigTest::testWriteOnSync()

View file

@ -68,7 +68,6 @@ void KMountPointTest::testCurrentMountPoints()
QVERIFY(!found);
// Check findByPath
#ifdef Q_OS_UNIX
const KMountPoint::Ptr rootMountPoint = mountPoints.findByPath("/");
QVERIFY(rootMountPoint);
QCOMPARE(rootMountPoint->mountPoint(), QString("/"));
@ -89,7 +88,6 @@ void KMountPointTest::testCurrentMountPoints()
} else {
kDebug() << "/home doesn't seem to exist, skipping test";
}
#endif
}
void KMountPointTest::testPossibleMountPoints()
@ -119,13 +117,11 @@ void KMountPointTest::testPossibleMountPoints()
QVERIFY(mountWithDevice);
#ifdef Q_OS_UNIX
const KMountPoint::Ptr rootMountPoint = mountPoints.findByPath("/");
QVERIFY(rootMountPoint);
QCOMPARE(rootMountPoint->mountPoint(), QString("/"));
QVERIFY(rootMountPoint->realDeviceName().startsWith(QLatin1String("/dev"))); // portable?
QVERIFY(!rootMountPoint->mountOptions().contains("noauto")); // how would this work?
QVERIFY(!rootMountPoint->probablySlow());
#endif
}

View file

@ -63,21 +63,14 @@ static QString recurse(QProcess::ProcessChannelMode how)
void KProcessTest::test_channels()
{
#ifdef Q_OS_UNIX
QString e, a;
TESTCHAN(SeparateChannels, "separate", "", EO, EE);
TESTCHAN(ForwardedChannels, "forwarded", EO EE, "", "");
TESTCHAN(MergedChannels, "merged", "", EO EE, "");
#else
QSKIP("This test needs a UNIX system", SkipSingle);
#endif
}
void KProcessTest::test_setShellCommand()
{
#if !defined(Q_OS_UNIX)
QSKIP("This test needs a free UNIX system", SkipSingle);
#else
KProcess p;
p.setShellCommand("cat");
@ -86,7 +79,6 @@ void KProcessTest::test_setShellCommand()
QVERIFY(p.program().at(0).endsWith("/bin/cat"));
p.setShellCommand("true || false");
QCOMPARE(p.program(), QStringList() << "/bin/sh" << "-c" << "true || false");
#endif
}
static void recursor(char **argv)

View file

@ -186,7 +186,6 @@ void KSaveFileTest::transactionalWriteNoPermissionsOnDir_data()
void KSaveFileTest::transactionalWriteNoPermissionsOnDir()
{
#ifdef Q_OS_UNIX
QFETCH(bool, directWriteFallback);
// Restore permissions so that the QTemporaryDir cleanup can happen
class PermissionRestorer
@ -255,11 +254,8 @@ void KSaveFileTest::transactionalWriteNoPermissionsOnDir()
QVERIFY(!file.open(QIODevice::WriteOnly));
QCOMPARE((int)file.error(), (int)QFile::PermissionsError);
}
#endif
}
void KSaveFileTest::test_backupFile()
{
KTemporaryFile file;

View file

@ -213,7 +213,6 @@ void KStandarddirsTest::testFindExe()
QString klauncherexe = KGlobal::dirs()->locate( "exe", "klauncher4" );
QVERIFY2(klauncherexe.endsWith("bin/klauncher4" EXT, PATH_SENSITIVITY), qPrintable(klauncherexe));
#ifdef Q_OS_UNIX
// findExe with a result in libexec
const QString kioslave = KGlobal::dirs()->findExe( "kioslave" );
QVERIFY( !kioslave.isEmpty() );
@ -234,21 +233,16 @@ void KStandarddirsTest::testFindExe()
}
QVERIFY(possibleResults.contains(sh));
QDir::setCurrent(pwd);
#endif
#ifdef Q_OS_UNIX
QFile home( m_kdehome );
const QString target = m_kdehome + "/linktodir";
home.link( target );
QVERIFY( KGlobal::dirs()->findExe( target ).isEmpty() );
#endif
#ifdef Q_OS_UNIX
// findExe for a binary not part of KDE
const QString ls = KGlobal::dirs()->findExe( "ls" );
QVERIFY( !ls.isEmpty() );
QVERIFY( ls.endsWith( QLatin1String( "bin/ls" ) ) );
#endif
// findExe with no result
const QString idontexist = KGlobal::dirs()->findExe( "idontexist" );

View file

@ -55,15 +55,11 @@
#include "kiconeffect.h"
/**
* Checks for relative paths quickly on UNIX-alikes, slowly on everything else.
* Checks for relative paths quickly on UNIX-alikes
*/
static bool pathIsRelative(const QString &path)
{
#ifdef Q_OS_UNIX
return (!path.isEmpty() && path[0] != QChar('/'));
#else
return QDir::isRelativePath(path);
#endif
}
/**

View file

@ -185,13 +185,11 @@ static QList< QWeakPointer< QWidget > > *x11Filter = 0;
*/
static void installSigpipeHandler()
{
#ifdef Q_OS_UNIX
struct sigaction act;
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
sigaction(SIGPIPE, &act, 0);
#endif
}
void KApplication::installX11EventFilter( QWidget* filter )

View file

@ -443,7 +443,6 @@ void FileUndoManagerTest::testTrashFiles()
static void setTimeStamp( const QString& path )
{
#ifdef Q_OS_UNIX
// Put timestamp in the past so that we can check that the
// copy actually preserves it.
struct timeval tp;
@ -453,7 +452,6 @@ static void setTimeStamp( const QString& path )
utbuf.modtime = tp.tv_sec + 60; // 60 second in the future
utime( QFile::encodeName( path ), &utbuf );
qDebug( "Time changed for %s", qPrintable( path ) );
#endif
}
void FileUndoManagerTest::testModifyFileBeforeUndo()

View file

@ -43,14 +43,12 @@ QDateTime s_referenceTimeStamp;
static void setTimeStamp( const QString& path, const QDateTime& mtime )
{
#ifdef Q_OS_UNIX
// Put timestamp in the past so that we can check that the listing is correct
struct utimbuf utbuf;
utbuf.actime = mtime.toTime_t();
utbuf.modtime = utbuf.actime;
utime( QFile::encodeName( path ), &utbuf );
//qDebug( "Time changed for %s", qPrintable( path ) );
#endif
}
static void createTestFile( const QString& path, bool plainText = false )