mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: remove redundant Q_OS_UNIX definition checks
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
663493317c
commit
0c5d00727e
11 changed files with 1 additions and 51 deletions
|
@ -480,7 +480,6 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Open existing file. *DON'T* create it if it suddenly does not exist!
|
// 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);
|
int fd = KDE_open(QFile::encodeName(filePath()), O_WRONLY | O_TRUNC);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -498,15 +497,6 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa
|
||||||
writeEntries(locale, f, writeMap);
|
writeEntries(locale, f, writeMap);
|
||||||
f.close();
|
f.close();
|
||||||
fclose(fp);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,6 @@ bool KSaveFile::open(OpenMode flags)
|
||||||
tempFile.setAutoRemove(false);
|
tempFile.setAutoRemove(false);
|
||||||
tempFile.setFileTemplate(d->realFileName + QLatin1String("XXXXXX.new"));
|
tempFile.setFileTemplate(d->realFileName + QLatin1String("XXXXXX.new"));
|
||||||
if (!tempFile.open()) {
|
if (!tempFile.open()) {
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
if (d->directWriteFallback && errno == EACCES) {
|
if (d->directWriteFallback && errno == EACCES) {
|
||||||
QFile::setFileName(d->realFileName);
|
QFile::setFileName(d->realFileName);
|
||||||
if (QFile::open(flags)) {
|
if (QFile::open(flags)) {
|
||||||
|
@ -112,7 +111,6 @@ bool KSaveFile::open(OpenMode flags)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// we only check here if the directory can be written to
|
// we only check here if the directory can be written to
|
||||||
// the actual filename isn't written to, but replaced later
|
// the actual filename isn't written to, but replaced later
|
||||||
|
@ -214,7 +212,6 @@ bool KSaveFile::finalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
static const bool extraSync = (::getenv("KDE_EXTRA_FSYNC") != 0 ? true : false);
|
static const bool extraSync = (::getenv("KDE_EXTRA_FSYNC") != 0 ? true : false);
|
||||||
if (extraSync) {
|
if (extraSync) {
|
||||||
if (flush()) {
|
if (flush()) {
|
||||||
|
@ -233,7 +230,6 @@ bool KSaveFile::finalize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
close();
|
close();
|
||||||
|
|
||||||
|
|
|
@ -1192,15 +1192,11 @@ void KConfigTest::testReparent()
|
||||||
|
|
||||||
static void ageTimeStamp(const QString& path, int nsec)
|
static void ageTimeStamp(const QString& path, int nsec)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
QDateTime mtime = QFileInfo(path).lastModified().addSecs(-nsec);
|
QDateTime mtime = QFileInfo(path).lastModified().addSecs(-nsec);
|
||||||
struct utimbuf utbuf;
|
struct utimbuf utbuf;
|
||||||
utbuf.actime = mtime.toTime_t();
|
utbuf.actime = mtime.toTime_t();
|
||||||
utbuf.modtime = utbuf.actime;
|
utbuf.modtime = utbuf.actime;
|
||||||
utime(QFile::encodeName(path), &utbuf);
|
utime(QFile::encodeName(path), &utbuf);
|
||||||
#else
|
|
||||||
QTest::qSleep(nsec * 1000);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KConfigTest::testWriteOnSync()
|
void KConfigTest::testWriteOnSync()
|
||||||
|
|
|
@ -68,7 +68,6 @@ void KMountPointTest::testCurrentMountPoints()
|
||||||
QVERIFY(!found);
|
QVERIFY(!found);
|
||||||
|
|
||||||
// Check findByPath
|
// Check findByPath
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
const KMountPoint::Ptr rootMountPoint = mountPoints.findByPath("/");
|
const KMountPoint::Ptr rootMountPoint = mountPoints.findByPath("/");
|
||||||
QVERIFY(rootMountPoint);
|
QVERIFY(rootMountPoint);
|
||||||
QCOMPARE(rootMountPoint->mountPoint(), QString("/"));
|
QCOMPARE(rootMountPoint->mountPoint(), QString("/"));
|
||||||
|
@ -89,7 +88,6 @@ void KMountPointTest::testCurrentMountPoints()
|
||||||
} else {
|
} else {
|
||||||
kDebug() << "/home doesn't seem to exist, skipping test";
|
kDebug() << "/home doesn't seem to exist, skipping test";
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMountPointTest::testPossibleMountPoints()
|
void KMountPointTest::testPossibleMountPoints()
|
||||||
|
@ -119,13 +117,11 @@ void KMountPointTest::testPossibleMountPoints()
|
||||||
|
|
||||||
QVERIFY(mountWithDevice);
|
QVERIFY(mountWithDevice);
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
const KMountPoint::Ptr rootMountPoint = mountPoints.findByPath("/");
|
const KMountPoint::Ptr rootMountPoint = mountPoints.findByPath("/");
|
||||||
QVERIFY(rootMountPoint);
|
QVERIFY(rootMountPoint);
|
||||||
QCOMPARE(rootMountPoint->mountPoint(), QString("/"));
|
QCOMPARE(rootMountPoint->mountPoint(), QString("/"));
|
||||||
QVERIFY(rootMountPoint->realDeviceName().startsWith(QLatin1String("/dev"))); // portable?
|
QVERIFY(rootMountPoint->realDeviceName().startsWith(QLatin1String("/dev"))); // portable?
|
||||||
QVERIFY(!rootMountPoint->mountOptions().contains("noauto")); // how would this work?
|
QVERIFY(!rootMountPoint->mountOptions().contains("noauto")); // how would this work?
|
||||||
QVERIFY(!rootMountPoint->probablySlow());
|
QVERIFY(!rootMountPoint->probablySlow());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,21 +63,14 @@ static QString recurse(QProcess::ProcessChannelMode how)
|
||||||
|
|
||||||
void KProcessTest::test_channels()
|
void KProcessTest::test_channels()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
QString e, a;
|
QString e, a;
|
||||||
TESTCHAN(SeparateChannels, "separate", "", EO, EE);
|
TESTCHAN(SeparateChannels, "separate", "", EO, EE);
|
||||||
TESTCHAN(ForwardedChannels, "forwarded", EO EE, "", "");
|
TESTCHAN(ForwardedChannels, "forwarded", EO EE, "", "");
|
||||||
TESTCHAN(MergedChannels, "merged", "", EO EE, "");
|
TESTCHAN(MergedChannels, "merged", "", EO EE, "");
|
||||||
#else
|
|
||||||
QSKIP("This test needs a UNIX system", SkipSingle);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KProcessTest::test_setShellCommand()
|
void KProcessTest::test_setShellCommand()
|
||||||
{
|
{
|
||||||
#if !defined(Q_OS_UNIX)
|
|
||||||
QSKIP("This test needs a free UNIX system", SkipSingle);
|
|
||||||
#else
|
|
||||||
KProcess p;
|
KProcess p;
|
||||||
|
|
||||||
p.setShellCommand("cat");
|
p.setShellCommand("cat");
|
||||||
|
@ -86,7 +79,6 @@ void KProcessTest::test_setShellCommand()
|
||||||
QVERIFY(p.program().at(0).endsWith("/bin/cat"));
|
QVERIFY(p.program().at(0).endsWith("/bin/cat"));
|
||||||
p.setShellCommand("true || false");
|
p.setShellCommand("true || false");
|
||||||
QCOMPARE(p.program(), QStringList() << "/bin/sh" << "-c" << "true || false");
|
QCOMPARE(p.program(), QStringList() << "/bin/sh" << "-c" << "true || false");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recursor(char **argv)
|
static void recursor(char **argv)
|
||||||
|
|
|
@ -186,7 +186,6 @@ void KSaveFileTest::transactionalWriteNoPermissionsOnDir_data()
|
||||||
|
|
||||||
void KSaveFileTest::transactionalWriteNoPermissionsOnDir()
|
void KSaveFileTest::transactionalWriteNoPermissionsOnDir()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
QFETCH(bool, directWriteFallback);
|
QFETCH(bool, directWriteFallback);
|
||||||
// Restore permissions so that the QTemporaryDir cleanup can happen
|
// Restore permissions so that the QTemporaryDir cleanup can happen
|
||||||
class PermissionRestorer
|
class PermissionRestorer
|
||||||
|
@ -255,11 +254,8 @@ void KSaveFileTest::transactionalWriteNoPermissionsOnDir()
|
||||||
QVERIFY(!file.open(QIODevice::WriteOnly));
|
QVERIFY(!file.open(QIODevice::WriteOnly));
|
||||||
QCOMPARE((int)file.error(), (int)QFile::PermissionsError);
|
QCOMPARE((int)file.error(), (int)QFile::PermissionsError);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void KSaveFileTest::test_backupFile()
|
void KSaveFileTest::test_backupFile()
|
||||||
{
|
{
|
||||||
KTemporaryFile file;
|
KTemporaryFile file;
|
||||||
|
|
|
@ -213,7 +213,6 @@ void KStandarddirsTest::testFindExe()
|
||||||
QString klauncherexe = KGlobal::dirs()->locate( "exe", "klauncher4" );
|
QString klauncherexe = KGlobal::dirs()->locate( "exe", "klauncher4" );
|
||||||
QVERIFY2(klauncherexe.endsWith("bin/klauncher4" EXT, PATH_SENSITIVITY), qPrintable(klauncherexe));
|
QVERIFY2(klauncherexe.endsWith("bin/klauncher4" EXT, PATH_SENSITIVITY), qPrintable(klauncherexe));
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
// findExe with a result in libexec
|
// findExe with a result in libexec
|
||||||
const QString kioslave = KGlobal::dirs()->findExe( "kioslave" );
|
const QString kioslave = KGlobal::dirs()->findExe( "kioslave" );
|
||||||
QVERIFY( !kioslave.isEmpty() );
|
QVERIFY( !kioslave.isEmpty() );
|
||||||
|
@ -234,21 +233,16 @@ void KStandarddirsTest::testFindExe()
|
||||||
}
|
}
|
||||||
QVERIFY(possibleResults.contains(sh));
|
QVERIFY(possibleResults.contains(sh));
|
||||||
QDir::setCurrent(pwd);
|
QDir::setCurrent(pwd);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
QFile home( m_kdehome );
|
QFile home( m_kdehome );
|
||||||
const QString target = m_kdehome + "/linktodir";
|
const QString target = m_kdehome + "/linktodir";
|
||||||
home.link( target );
|
home.link( target );
|
||||||
QVERIFY( KGlobal::dirs()->findExe( target ).isEmpty() );
|
QVERIFY( KGlobal::dirs()->findExe( target ).isEmpty() );
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
// findExe for a binary not part of KDE
|
// findExe for a binary not part of KDE
|
||||||
const QString ls = KGlobal::dirs()->findExe( "ls" );
|
const QString ls = KGlobal::dirs()->findExe( "ls" );
|
||||||
QVERIFY( !ls.isEmpty() );
|
QVERIFY( !ls.isEmpty() );
|
||||||
QVERIFY( ls.endsWith( QLatin1String( "bin/ls" ) ) );
|
QVERIFY( ls.endsWith( QLatin1String( "bin/ls" ) ) );
|
||||||
#endif
|
|
||||||
|
|
||||||
// findExe with no result
|
// findExe with no result
|
||||||
const QString idontexist = KGlobal::dirs()->findExe( "idontexist" );
|
const QString idontexist = KGlobal::dirs()->findExe( "idontexist" );
|
||||||
|
|
|
@ -55,15 +55,11 @@
|
||||||
#include "kiconeffect.h"
|
#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)
|
static bool pathIsRelative(const QString &path)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
return (!path.isEmpty() && path[0] != QChar('/'));
|
return (!path.isEmpty() && path[0] != QChar('/'));
|
||||||
#else
|
|
||||||
return QDir::isRelativePath(path);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -185,13 +185,11 @@ static QList< QWeakPointer< QWidget > > *x11Filter = 0;
|
||||||
*/
|
*/
|
||||||
static void installSigpipeHandler()
|
static void installSigpipeHandler()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
act.sa_flags = 0;
|
act.sa_flags = 0;
|
||||||
sigaction(SIGPIPE, &act, 0);
|
sigaction(SIGPIPE, &act, 0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KApplication::installX11EventFilter( QWidget* filter )
|
void KApplication::installX11EventFilter( QWidget* filter )
|
||||||
|
|
|
@ -443,7 +443,6 @@ void FileUndoManagerTest::testTrashFiles()
|
||||||
|
|
||||||
static void setTimeStamp( const QString& path )
|
static void setTimeStamp( const QString& path )
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
// Put timestamp in the past so that we can check that the
|
// Put timestamp in the past so that we can check that the
|
||||||
// copy actually preserves it.
|
// copy actually preserves it.
|
||||||
struct timeval tp;
|
struct timeval tp;
|
||||||
|
@ -453,7 +452,6 @@ static void setTimeStamp( const QString& path )
|
||||||
utbuf.modtime = tp.tv_sec + 60; // 60 second in the future
|
utbuf.modtime = tp.tv_sec + 60; // 60 second in the future
|
||||||
utime( QFile::encodeName( path ), &utbuf );
|
utime( QFile::encodeName( path ), &utbuf );
|
||||||
qDebug( "Time changed for %s", qPrintable( path ) );
|
qDebug( "Time changed for %s", qPrintable( path ) );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileUndoManagerTest::testModifyFileBeforeUndo()
|
void FileUndoManagerTest::testModifyFileBeforeUndo()
|
||||||
|
|
|
@ -43,14 +43,12 @@ QDateTime s_referenceTimeStamp;
|
||||||
|
|
||||||
static void setTimeStamp( const QString& path, const QDateTime& mtime )
|
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
|
// Put timestamp in the past so that we can check that the listing is correct
|
||||||
struct utimbuf utbuf;
|
struct utimbuf utbuf;
|
||||||
utbuf.actime = mtime.toTime_t();
|
utbuf.actime = mtime.toTime_t();
|
||||||
utbuf.modtime = utbuf.actime;
|
utbuf.modtime = utbuf.actime;
|
||||||
utime( QFile::encodeName( path ), &utbuf );
|
utime( QFile::encodeName( path ), &utbuf );
|
||||||
//qDebug( "Time changed for %s", qPrintable( path ) );
|
//qDebug( "Time changed for %s", qPrintable( path ) );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createTestFile( const QString& path, bool plainText = false )
|
static void createTestFile( const QString& path, bool plainText = false )
|
||||||
|
|
Loading…
Add table
Reference in a new issue