From kde-commits Tue Aug 20 10:29:54 2013 From: Kevin Ottens Date: Tue, 20 Aug 2013 10:29:54 +0000 To: kde-commits Subject: [kdelibs/frameworks] /: Fix porting errors introduced by bf9a709 Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=137699461021654 Git commit b1d903e15b9c62558d67b0ceba0ca725921c79e1 by Kevin Ottens. Committed on 20/08/2013 at 10:01. Pushed by ervin into branch 'frameworks'. Fix porting errors introduced by bf9a709 S_ISLNK is *not* equivalent to "& QT_STAT_LNK" (it's not even equivalent to S_IFLNK in fact). This porting error was caught by our unit tests... CCMAIL: agateau@kde.org M +2 -2 kio/kfile/kpropertiesdialog.cpp M +2 -2 kio/kio/krun.cpp M +2 -2 kio/tests/fileundomanagertest.cpp M +1 -1 kio/tests/kioslavetest.cpp M +1 -1 kio/tests/kiotesthelper.h M +9 -9 kioslave/file/file.cpp M +7 -7 kioslave/file/file_unix.cpp M +6 -6 staging/kio/src/core/kfileitem.cpp M +1 -1 staging/kio/src/core/udsentry.cpp M +1 -1 staging/kio/src/widgets/kurlcompletion.cpp M +1 -1 tier1/karchive/src/k7zip.cpp M +1 -1 tier1/karchive/src/kzip.cpp M +3 -3 tier1/kcoreaddons/src/lib/io/kdirwatch.cpp http://commits.kde.org/kdelibs/b1d903e15b9c62558d67b0ceba0ca725921c79e1 diff --git a/kio/kfile/kpropertiesdialog.cpp b/kio/kfile/kpropertiesdialog.= cpp index baaeced..af8a251 100644 --- a/kio/kfile/kpropertiesdialog.cpp +++ b/kio/kfile/kpropertiesdialog.cpp @@ -896,7 +896,7 @@ KFilePropsPlugin::KFilePropsPlugin( KPropertiesDialog *= _props ) directory +=3D ')'; } = - if (!isTrash && (bDesktopFile || (mode & QT_STAT_DIR)) + if (!isTrash && (bDesktopFile || ((mode & QT_STAT_MASK) =3D=3D QT_STAT= _DIR)) && !d->bMultiple // not implemented for multiple && enableIconButton()) // #56857 { @@ -1487,7 +1487,7 @@ void KFilePropsPlugin::applyIconChanges() if ( url.isLocalFile()) { QString path; = - if (properties->item().mode() & QT_STAT_DIR) + if ((properties->item().mode() & QT_STAT_MASK) =3D=3D QT_STAT_DIR) { path =3D url.toLocalFile() + QString::fromLatin1("/.directory"= ); // don't call updateUrl because the other tabs (i.e. permissio= ns) diff --git a/kio/kio/krun.cpp b/kio/kio/krun.cpp index f2076ca..044a8fe 100644 --- a/kio/kio/krun.cpp +++ b/kio/kio/krun.cpp @@ -1247,7 +1247,7 @@ void KRun::init() = #if 0 // removed for KF5 (for portability). Reintroduce a bool or flag if = useful. // Did we already get the information that it is a directory ? - if (d->m_mode & QT_STAT_DIR) { + if ((d->m_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR) { mimeTypeDetermined("inode/directory"); return; } @@ -1416,7 +1416,7 @@ void KRun::slotStatResult(KJob * job) = const KIO::UDSEntry entry =3D statJob->statResult(); const mode_t mode =3D entry.numberValue(KIO::UDSEntry::UDS_FILE_TY= PE); - if (mode & QT_STAT_DIR) { + if ((mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR) { d->m_bIsDirectory =3D true; // it's a dir } else { diff --git a/kio/tests/fileundomanagertest.cpp b/kio/tests/fileundomanagert= est.cpp index 5e4286a..200448a 100644 --- a/kio/tests/fileundomanagertest.cpp +++ b/kio/tests/fileundomanagertest.cpp @@ -96,9 +96,9 @@ static void createTestSymlink( const QString& path ) if ( !ok ) qFatal("couldn't create symlink: %s", strerror(errno)); QVERIFY( QT_LSTAT( QFile::encodeName( path ), &buf ) =3D=3D 0 ); - QVERIFY( buf.st_mode & QT_STAT_LNK ); + QVERIFY( (buf.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_LNK ); } else { - QVERIFY( buf.st_mode & QT_STAT_LNK ); + QVERIFY( (buf.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_LNK ); } qDebug( "symlink %s created", qPrintable( path ) ); QVERIFY( QFileInfo( path ).isSymLink() ); diff --git a/kio/tests/kioslavetest.cpp b/kio/tests/kioslavetest.cpp index f4433b8..4a02a57 100644 --- a/kio/tests/kioslavetest.cpp +++ b/kio/tests/kioslavetest.cpp @@ -362,7 +362,7 @@ void KioslaveTest::printUDSEntry( const KIO::UDSEntry &= entry ) { mode_t mode =3D (mode_t)entry.numberValue(*it); qDebug() << "File Type : " << mode; - if ( mode & QT_STAT_DIR ) + if ( (mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR ) { qDebug() << "is a dir"; } diff --git a/kio/tests/kiotesthelper.h b/kio/tests/kiotesthelper.h index e75d3cc..3b208c7 100644 --- a/kio/tests/kiotesthelper.h +++ b/kio/tests/kiotesthelper.h @@ -81,7 +81,7 @@ static void createTestSymlink( const QString& path, const= QByteArray& target =3D " qFatal("couldn't create symlink: %s", strerror(errno)); QT_STATBUF buf; QVERIFY( QT_LSTAT( QFile::encodeName( path ), &buf ) =3D=3D 0 ); - QVERIFY( buf.st_mode & QT_STAT_LNK ); + QVERIFY( (buf.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_LNK ); //qDebug( "symlink %s created", qPrintable( path ) ); QVERIFY( QFileInfo( path ).isSymLink() ); } diff --git a/kioslave/file/file.cpp b/kioslave/file/file.cpp index 60fc915..3c8ea7b 100644 --- a/kioslave/file/file.cpp +++ b/kioslave/file/file.cpp @@ -266,7 +266,7 @@ void FileProtocol::mkdir( const QUrl& url, int permissi= ons ) } } = - if ( buff.st_mode & QT_STAT_DIR ) { + if ( (buff.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR ) { // qDebug() << "ERR_DIR_ALREADY_EXIST"; error(KIO::ERR_DIR_ALREADY_EXIST, path); return; @@ -295,11 +295,11 @@ void FileProtocol::get( const QUrl& url ) return; } = - if ( buff.st_mode & QT_STAT_DIR ) { + if ( (buff.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR ) { error(KIO::ERR_IS_DIRECTORY, path); return; } - if ( !( buff.st_mode & QT_STAT_REG ) ) { + if ( ( buff.st_mode & QT_STAT_MASK ) !=3D QT_STAT_REG ) { error(KIO::ERR_CANNOT_OPEN_FOR_READING, path); return; } @@ -392,11 +392,11 @@ void FileProtocol::open(const QUrl &url, QIODevice::O= penMode mode) return; } = - if ( buff.st_mode & QT_STAT_DIR ) { + if ( (buff.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR ) { error(KIO::ERR_IS_DIRECTORY, openPath); return; } - if ( !( buff.st_mode & QT_STAT_REG ) ) { + if ( ( buff.st_mode & QT_STAT_MASK ) !=3D QT_STAT_REG ) { error(KIO::ERR_CANNOT_OPEN_FOR_READING, openPath); return; } @@ -513,7 +513,7 @@ void FileProtocol::put( const QUrl& url, int _mode, KIO= ::JobFlags _flags ) QT_STATBUF buff_part; bPartExists =3D (QT_LSTAT(QFile::encodeName(dest_part).constData()= , &buff_part) !=3D -1); = - if (bPartExists && !(_flags & KIO::Resume) && !(_flags & KIO::Over= write) && buff_part.st_size > 0 && (buff_part.st_mode & QT_STAT_REG)) + if (bPartExists && !(_flags & KIO::Resume) && !(_flags & KIO::Over= write) && buff_part.st_size > 0 && ((buff_part.st_mode & QT_STAT_MASK) =3D= =3D QT_STAT_REG)) { // qDebug() << "calling canResume with" << KIO::number(buff_pa= rt.st_size); = @@ -528,7 +528,7 @@ void FileProtocol::put( const QUrl& url, int _mode, KIO= ::JobFlags _flags ) = if ( bOrigExists && !(_flags & KIO::Overwrite) && !(_flags & KIO::Resu= me)) { - if (buff_orig.st_mode & QT_STAT_DIR) + if ((buff_orig.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR) error( KIO::ERR_DIR_ALREADY_EXIST, dest_orig ); else error( KIO::ERR_FILE_ALREADY_EXIST, dest_orig ); @@ -751,7 +751,7 @@ bool FileProtocol::createUDSEntry( const QString & file= name, const QByteArray & entry.insert( KIO::UDSEntry::UDS_INODE, buff.st_ino ); } = - if (buff.st_mode & QT_STAT_LNK) { + if ((buff.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_LNK) { = char buffer2[ 1000 ]; int n =3D readlink( path.data(), buffer2, 999 ); @@ -1211,7 +1211,7 @@ static void appendACLAtoms( const QByteArray & path, = UDSEntry& entry, mode_t typ = acl_t acl =3D 0; acl_t defaultAcl =3D 0; - bool isDir =3D type & QT_STAT_DIR; + bool isDir =3D (type & QT_STAT_MASK) =3D=3D QT_STAT_DIR; // do we have an acl for the file, and/or a default acl for the dir, i= f it is one? acl =3D acl_get_file( path.data(), ACL_TYPE_ACCESS ); /* Sadly libacl does not provided a means of checking for extended ACL= and default diff --git a/kioslave/file/file_unix.cpp b/kioslave/file/file_unix.cpp index 0a13399..f4bc812 100644 --- a/kioslave/file/file_unix.cpp +++ b/kioslave/file/file_unix.cpp @@ -85,7 +85,7 @@ void FileProtocol::copy( const QUrl &srcUrl, const QUrl &= destUrl, return; } = - if ( buff_src.st_mode & QT_STAT_DIR ) { + if ( (buff_src.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR ) { error(KIO::ERR_IS_DIRECTORY, src); return; } @@ -98,7 +98,7 @@ void FileProtocol::copy( const QUrl &srcUrl, const QUrl &= destUrl, bool dest_exists =3D (QT_LSTAT(_dest.data(), &buff_dest) !=3D -1); if ( dest_exists ) { - if (buff_dest.st_mode & QT_STAT_DIR) + if ((buff_dest.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR) { error(KIO::ERR_DIR_ALREADY_EXIST, dest); return; @@ -119,7 +119,7 @@ void FileProtocol::copy( const QUrl &srcUrl, const QUrl= &destUrl, // If the destination is a symlink and overwrite is TRUE, // remove the symlink first to prevent the scenario where // the symlink actually points to current source! - if ((_flags & KIO::Overwrite) && (buff_dest.st_mode & QT_STAT_LNK)) + if ((_flags & KIO::Overwrite) && ((buff_dest.st_mode & QT_STAT_MAS= K) =3D=3D QT_STAT_LNK)) { //qDebug() << "copy(): LINK DESTINATION"; QFile::remove(dest); @@ -388,8 +388,8 @@ void FileProtocol::listDir( const QUrl& url) continue; // how can stat fail? } entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, - (st.st_mode & QT_STAT_DIR) ? S_IFDIR : S_IFREG ); - const bool isSymLink =3D (st.st_mode & QT_STAT_LNK); + ((st.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR)= ? S_IFDIR : S_IFREG ); + const bool isSymLink =3D ((st.st_mode & QT_STAT_MASK) =3D=3D Q= T_STAT_LNK); #endif if (isSymLink) { // for symlinks obey the UDSEntry contract and provide UDS= _LINK_DEST @@ -437,7 +437,7 @@ void FileProtocol::rename( const QUrl &srcUrl, const QU= rl &destUrl, bool dest_exists =3D (QT_LSTAT(_dest.data(), &buff_dest) !=3D -1); if ( dest_exists ) { - if (buff_dest.st_mode & QT_STAT_DIR) + if ((buff_dest.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR) { error(KIO::ERR_DIR_ALREADY_EXIST, dest); return; @@ -498,7 +498,7 @@ void FileProtocol::symlink( const QString &target, cons= t QUrl &destUrl, KIO::Job else { QT_STATBUF buff_dest; - if (QT_LSTAT(QFile::encodeName(dest), &buff_dest) =3D=3D 0= && (buff_dest.st_mode & QT_STAT_DIR)) + if (QT_LSTAT(QFile::encodeName(dest), &buff_dest) =3D=3D 0= && ((buff_dest.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR)) error(KIO::ERR_DIR_ALREADY_EXIST, dest); else error(KIO::ERR_FILE_ALREADY_EXIST, dest); diff --git a/staging/kio/src/core/kfileitem.cpp b/staging/kio/src/core/kfil= eitem.cpp index 7331192..970dea8 100644 --- a/staging/kio/src/core/kfileitem.cpp +++ b/staging/kio/src/core/kfileitem.cpp @@ -468,7 +468,7 @@ QString KFileItemPrivate::parsePermissions(mode_t perm)= const if (m_bLink) buffer[0] =3D 'l'; else if (m_fileMode !=3D KFileItem::Unknown) { - if (m_fileMode & QT_STAT_DIR) + if ((m_fileMode & QT_STAT_MASK) =3D=3D QT_STAT_DIR) buffer[0] =3D 'd'; #ifdef Q_OS_UNIX else if (S_ISSOCK(m_fileMode)) @@ -1022,7 +1022,7 @@ QStringList KFileItem::overlays() const names.append("emblem-symbolic-link"); } = - if ( !(d->m_fileMode & QT_STAT_DIR) // Locked dirs have a special icon= , use the overlay for files only + if ( ((d->m_fileMode & QT_STAT_MASK) !=3D QT_STAT_DIR) // Locked dirs = have a special icon, use the overlay for files only && !isReadable()) { names.append("object-locked"); } @@ -1052,7 +1052,7 @@ QStringList KFileItem::overlays() const } = #ifndef Q_OS_WIN - if( (d->m_fileMode & QT_STAT_DIR) && d->m_bIsLocalUrl) + if( ((d->m_fileMode & QT_STAT_MASK) =3D=3D QT_STAT_DIR) && d->m_bIsLoc= alUrl) { if (KSambaShare::instance()->isDirectoryShared( d->m_url.toLocalFi= le() ) || KNFSShare::instance()->isDirectoryShared( d->m_url.toLocalFile= () )) @@ -1165,7 +1165,7 @@ bool KFileItem::isDir() const //qDebug() << d << url() << "can't say -> false"; return false; // can't say for sure, so no } - return d->m_fileMode & QT_STAT_DIR; + return (d->m_fileMode & QT_STAT_MASK) =3D=3D QT_STAT_DIR; } = bool KFileItem::isFile() const @@ -1219,7 +1219,7 @@ QString KFileItem::getStatusBarInfo() const { text +=3D i18n(" (Points to %1)", targetUrl().toDisplayString()); } - else if ( d->m_fileMode & QT_STAT_REG ) + else if ( (d->m_fileMode & QT_STAT_MASK) =3D=3D QT_STAT_REG ) { text +=3D QString(" (%1, %2)").arg( comment, KIO::convertSize( siz= e() ) ); } @@ -1654,7 +1654,7 @@ bool KFileItem::isRegularFile() const if (!d) return false; = - return d->m_fileMode & QT_STAT_REG; + return (d->m_fileMode & QT_STAT_MASK) =3D=3D QT_STAT_REG; } = QDebug operator<<(QDebug stream, const KFileItem& item) diff --git a/staging/kio/src/core/udsentry.cpp b/staging/kio/src/core/udsen= try.cpp index 86dce2a..dbfe202 100644 --- a/staging/kio/src/core/udsentry.cpp +++ b/staging/kio/src/core/udsentry.cpp @@ -82,7 +82,7 @@ long long UDSEntry::numberValue(uint field, long long def= aultValue) const = bool UDSEntry::isDir() const { - return numberValue(UDS_FILE_TYPE) & QT_STAT_DIR; + return (numberValue(UDS_FILE_TYPE) & QT_STAT_MASK) =3D=3D QT_STAT_DIR; } = bool UDSEntry::isLink() const diff --git a/staging/kio/src/widgets/kurlcompletion.cpp b/staging/kio/src/w= idgets/kurlcompletion.cpp index 596680a..80a4023 100644 --- a/staging/kio/src/widgets/kurlcompletion.cpp +++ b/staging/kio/src/widgets/kurlcompletion.cpp @@ -1316,7 +1316,7 @@ void KUrlCompletion::postProcessMatch(QString* pMatch= ) const = QT_STATBUF sbuff; if (QT_STAT(file.constData(), &sbuff) =3D=3D 0) { - if (sbuff.st_mode & QT_STAT_DIR) + if ((sbuff.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR) pMatch->append(QLatin1Char('/')); } else { //qDebug() << "Could not stat file" << copy; diff --git a/tier1/karchive/src/k7zip.cpp b/tier1/karchive/src/k7zip.cpp index bb79cfb..7bd2f34 100644 --- a/tier1/karchive/src/k7zip.cpp +++ b/tier1/karchive/src/k7zip.cpp @@ -2636,7 +2636,7 @@ bool K7Zip::openArchive( QIODevice::OpenMode mode ) bool symlink =3D false; if (fileInfo->attributes & FILE_ATTRIBUTE_UNIX_EXTENSION) { access =3D fileInfo->attributes >> 16; - if (access & QT_STAT_LNK) { + if ((access & QT_STAT_MASK) =3D=3D QT_STAT_LNK) { symlink =3D true; } } else { diff --git a/tier1/karchive/src/kzip.cpp b/tier1/karchive/src/kzip.cpp index f268c85..c678ed6 100644 --- a/tier1/karchive/src/kzip.cpp +++ b/tier1/karchive/src/kzip.cpp @@ -699,7 +699,7 @@ bool KZip::openArchive( QIODevice::OpenMode mode ) else { QString symlink; - if (access & QT_STAT_LNK) { + if ((access & QT_STAT_MASK) =3D=3D QT_STAT_LNK) { symlink =3D QFile::decodeName(pfi.guessed_symlink); } QDateTime mtime =3D KArchivePrivate::time_tToDateTime(pfi.= mtime); diff --git a/tier1/kcoreaddons/src/lib/io/kdirwatch.cpp b/tier1/kcoreaddons= /src/lib/io/kdirwatch.cpp index 95c4651..903883e 100644 --- a/tier1/kcoreaddons/src/lib/io/kdirwatch.cpp +++ b/tier1/kcoreaddons/src/lib/io/kdirwatch.cpp @@ -397,7 +397,7 @@ void KDirWatchPrivate::inotifyEventReceived() // so in that case we'll just take both kinds of clients and= emit Deleted. KDirWatch::WatchModes flag =3D KDirWatch::WatchSubDirs | KDi= rWatch::WatchFiles; if (QT_STAT(QFile::encodeName(tpath).constData(), &stat_buf)= =3D=3D 0) { - bool isDir =3D stat_buf.st_mode & QT_STAT_DIR; + bool isDir =3D (stat_buf.st_mode & QT_STAT_MASK) =3D=3D QT= _STAT_DIR; flag =3D isDir ? KDirWatch::WatchSubDirs : KDirWatch::Watc= hFiles; } int counter =3D 0; @@ -815,11 +815,11 @@ void KDirWatchPrivate::addEntry(KDirWatch* instance, = const QString& _path, Entry* e =3D &(*newIt); = if (exists) { - e->isDir =3D stat_buf.st_mode & QT_STAT_DIR; + e->isDir =3D (stat_buf.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_DIR; = if (e->isDir && !isDir) { if (QT_LSTAT(QFile::encodeName(path).constData(), &stat_buf) =3D=3D = 0) { - if (stat_buf.st_mode & QT_STAT_LNK) + if ((stat_buf.st_mode & QT_STAT_MASK) =3D=3D QT_STAT_LNK) // if it's a symlink, don't follow it e->isDir =3D false; else