Changeset View
Changeset View
Standalone View
Standalone View
src/ioslaves/file/file_unix.cpp
Show All 31 Lines | |||||
32 | #include <qplatformdefs.h> | 32 | #include <qplatformdefs.h> | ||
33 | 33 | | |||
34 | #include <QDebug> | 34 | #include <QDebug> | ||
35 | #include <kconfiggroup.h> | 35 | #include <kconfiggroup.h> | ||
36 | #include <klocalizedstring.h> | 36 | #include <klocalizedstring.h> | ||
37 | #include <kmountpoint.h> | 37 | #include <kmountpoint.h> | ||
38 | 38 | | |||
39 | #include <errno.h> | 39 | #include <errno.h> | ||
40 | #ifdef HAVE_SYS_XATTR_H | ||||
40 | #include <sys/xattr.h> | 41 | #include <sys/xattr.h> | ||
42 | #endif | ||||
41 | #include <utime.h> | 43 | #include <utime.h> | ||
42 | 44 | | |||
43 | #include <KAuth> | 45 | #include <KAuth> | ||
44 | 46 | | |||
45 | #include "fdreceiver.h" | 47 | #include "fdreceiver.h" | ||
46 | 48 | | |||
47 | //sendfile has different semantics in different platforms | 49 | //sendfile has different semantics in different platforms | ||
48 | #if defined HAVE_SENDFILE && defined Q_OS_LINUX | 50 | #if defined HAVE_SENDFILE && defined Q_OS_LINUX | ||
▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Line(s) | 398 | { | |||
406 | hostname[ 0 ] = '\0'; | 408 | hostname[ 0 ] = '\0'; | ||
407 | if (!gethostname(hostname, 255)) { | 409 | if (!gethostname(hostname, 255)) { | ||
408 | hostname[sizeof(hostname) - 1] = '\0'; | 410 | hostname[sizeof(hostname) - 1] = '\0'; | ||
409 | } | 411 | } | ||
410 | 412 | | |||
411 | return (QString::compare(url.host(), QLatin1String(hostname), Qt::CaseInsensitive) == 0); | 413 | return (QString::compare(url.host(), QLatin1String(hostname), Qt::CaseInsensitive) == 0); | ||
412 | } | 414 | } | ||
413 | 415 | | |||
414 | #ifdef Q_OS_LINUX | 416 | #ifdef HAVE_SYS_XATTR_H | ||
dfaure: should be #if, not #ifdef.
It's always defined, to either 0 or 1. | |||||
415 | static bool isNtfsHidden(const QString &filename) | 417 | static bool isNtfsHidden(const QString &filename) | ||
416 | { | 418 | { | ||
417 | constexpr auto attrName = "system.ntfs_attrib_be"; | 419 | constexpr auto attrName = "system.ntfs_attrib_be"; | ||
418 | const auto filenameEncoded = QFile::encodeName(filename); | 420 | const auto filenameEncoded = QFile::encodeName(filename); | ||
419 | auto length = getxattr(filenameEncoded.data(), attrName, nullptr, 0); | 421 | auto length = getxattr(filenameEncoded.data(), attrName, nullptr, 0); | ||
420 | if (length <= 0) { | 422 | if (length <= 0) { | ||
421 | return false; | 423 | return false; | ||
422 | } | 424 | } | ||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 541 | if (isSymLink) { | |||
540 | // for symlinks obey the UDSEntry contract and provide UDS_LINK_DEST | 542 | // for symlinks obey the UDSEntry contract and provide UDS_LINK_DEST | ||
541 | // even if we don't know the link dest (and DeleteJob doesn't care...) | 543 | // even if we don't know the link dest (and DeleteJob doesn't care...) | ||
542 | entry.insert(KIO::UDSEntry::UDS_LINK_DEST, QStringLiteral("Dummy Link Target")); | 544 | entry.insert(KIO::UDSEntry::UDS_LINK_DEST, QStringLiteral("Dummy Link Target")); | ||
543 | } | 545 | } | ||
544 | listEntry(entry); | 546 | listEntry(entry); | ||
545 | 547 | | |||
546 | } else { | 548 | } else { | ||
547 | if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details)) { | 549 | if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details)) { | ||
548 | #ifdef Q_OS_LINUX | 550 | #ifdef HAVE_SYS_XATTR_H | ||
dfaure: same | |||||
549 | if (isNtfsHidden(filename)) { | 551 | if (isNtfsHidden(filename)) { | ||
550 | entry.insert(KIO::UDSEntry::UDS_HIDDEN, 1); | 552 | entry.insert(KIO::UDSEntry::UDS_HIDDEN, 1); | ||
551 | } | 553 | } | ||
552 | #endif | 554 | #endif | ||
553 | listEntry(entry); | 555 | listEntry(entry); | ||
554 | } | 556 | } | ||
555 | } | 557 | } | ||
556 | } | 558 | } | ||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |
should be #if, not #ifdef.
It's always defined, to either 0 or 1.