11#include "../kioworkers/file/stat_unix.h"
12#include "config-kiocore.h"
15#include "../aclhelpers_p.h"
18#include "../utils_p.h"
19#include "kiocoredebug.h"
20#include "kioglobal_p.h"
26#include <QDirIterator>
28#include <QMimeDatabase>
30#include <KConfigGroup>
31#include <KDesktopFile>
32#include <KLocalizedString>
33#include <kmountpoint.h>
36#include <ksambashare.h>
38#include <KFileSystemType>
39#include <KProtocolManager>
42#define KFILEITEM_DEBUG 0
50 const QUrl &itemOrDirUrl,
52 bool delayedMimeTypes,
53 KFileItem::MimeTypeDetermination mimeTypeDetermination)
59 , m_strLowerCaseName()
62 , m_permissions(permissions)
65 , m_bIsLocalUrl(itemOrDirUrl.isLocalFile())
66 , m_bMimeTypeKnown(false)
67 , m_delayedMimeTypes(delayedMimeTypes)
68 , m_useIconNameCache(false)
70 , m_hiddenCache(HiddenUncached)
72 , m_bSkipMimeTypeFromContent(mimeTypeDetermination ==
KFileItem::SkipMimeTypeFromContent)
73 , m_bInitCalled(false)
75 if (entry.
count() != 0) {
76 readUDSEntry(urlIsDirectory);
78 Q_ASSERT(!urlIsDirectory);
79 m_strName = itemOrDirUrl.fileName();
80 m_strText = KIO::decodeFileName(m_strName);
87 void ensureInitialized()
const;
100 bool cmp(
const KFileItemPrivate &item)
const;
101 void printCompareDebug(
const KFileItemPrivate &item)
const;
108 void readUDSEntry(
bool _urlIsDirectory);
113 QString parsePermissions(mode_t perm)
const;
118 void determineMimeTypeHelper(
const QUrl &url)
const;
148 mutable QString m_strLowerCaseName;
158 mutable mode_t m_fileMode;
162 mutable mode_t m_permissions;
167 mutable bool m_addACL : 1;
172 mutable bool m_bLink : 1;
176 bool m_bIsLocalUrl : 1;
178 mutable bool m_bMimeTypeKnown : 1;
179 mutable bool m_delayedMimeTypes : 1;
182 mutable bool m_useIconNameCache : 1;
185 enum { Auto, Hidden, Shown } m_hidden : 3;
186 mutable enum { HiddenUncached, HiddenCached, ShownCached } m_hiddenCache : 3;
189 mutable enum { SlowUnknown, Fast, Slow } m_slow : 3;
194 bool m_bSkipMimeTypeFromContent : 1;
199 mutable bool m_bInitCalled : 1;
206void KFileItemPrivate::ensureInitialized()
const
208 if (!m_bInitCalled) {
213void KFileItemPrivate::init()
const
219 const bool shouldStat = (m_fileMode == KFileItem::Unknown || m_permissions == KFileItem::Unknown || m_entry.
count() == 0) && m_url.
isLocalFile();
241 mode_t mode = stat_mode(buff);
242 if (Utils::isLinkMask(mode)) {
245 mode = stat_mode(buff);
247 mode = (QT_STAT_MASK - 1) | S_IRWXU | S_IRWXG | S_IRWXO;
251 const mode_t
type = mode & QT_STAT_MASK;
263 const auto uid = stat_uid(buff);
264 const auto gid = stat_gid(buff);
270 if (m_fileMode == KFileItem::Unknown) {
273 if (m_permissions == KFileItem::Unknown) {
274 m_permissions = mode & 07777;
279 appendACLAtoms(pathBA, m_entry, type);
283 if (errno != ENOENT) {
285 qCDebug(KIO_CORE) << QStringLiteral(
"KFileItem: error %1: %2").arg(errno).arg(
QString::fromLatin1(strerror(errno))) <<
"when refreshing"
291 m_bInitCalled =
true;
294void KFileItemPrivate::readUDSEntry(
bool _urlIsDirectory)
310 const bool UDS_URL_seen = !urlStr.
isEmpty();
312 m_url =
QUrl(urlStr);
314 m_bIsLocalUrl =
true;
319 m_bMimeTypeKnown = !mimeTypeStr.
isEmpty();
320 if (m_bMimeTypeKnown) {
328 m_hidden = hiddenVal == 1 ? Hidden : (hiddenVal == 0 ? Shown : Auto);
329 m_hiddenCache = HiddenUncached;
331 if (_urlIsDirectory && !UDS_URL_seen && !m_strName.
isEmpty() && m_strName !=
QLatin1String(
".")) {
335 path = QStringLiteral(
"/");
337 m_url.
setPath(Utils::concatPaths(path, m_strName));
343 if (m_fileMode != KFileItem::Unknown) {
344 m_bInitCalled =
true;
355 if (fieldVal != -1) {
370 if (fieldVal != -1) {
379 switch (mappedWhich) {
380 case KFileItem::ModificationTime:
382 case KFileItem::AccessTime:
384 case KFileItem::CreationTime:
392 m_entry.
replace(udsFieldForTime(mappedWhich), time_t_val);
406 const uint uds = udsFieldForTime(mappedWhich);
408 const long long fieldVal = m_entry.
numberValue(uds, -1);
409 if (fieldVal != -1) {
417void KFileItemPrivate::printCompareDebug(
const KFileItemPrivate &item)
const
424 qDebug() <<
"Comparing" << m_url <<
"and" << item.m_url;
425 qDebug() <<
" name" << (m_strName == item.m_strName);
426 qDebug() <<
" local" << (m_bIsLocalUrl == item.m_bIsLocalUrl);
428 qDebug() <<
" mode" << (m_fileMode == item.m_fileMode);
429 qDebug() <<
" perm" << (m_permissions == item.m_permissions);
435 qDebug() <<
" UDS_DEFAULT_ACL_STRING"
438 qDebug() <<
" m_bLink" << (m_bLink == item.m_bLink);
439 qDebug() <<
" m_hidden" << (m_hidden == item.m_hidden);
441 qDebug() <<
" size" << (size() == item.size());
451inline bool KFileItemPrivate::cmp(
const KFileItemPrivate &item)
const
453 if (item.m_bInitCalled) {
458 item.ensureInitialized();
462 printCompareDebug(item);
466 return (m_strName == item.m_strName
467 && m_bIsLocalUrl == item.m_bIsLocalUrl
468 && m_fileMode == item.m_fileMode
469 && m_permissions == item.m_permissions
475 && m_bLink == item.m_bLink
476 && m_hidden == item.m_hidden
477 && size() == item.size()
488inline QString KFileItemPrivate::parsePermissions(mode_t perm)
const
492 static char buffer[12];
498 if ((perm & (S_IXUSR | S_ISUID)) == (S_IXUSR | S_ISUID)) {
500 }
else if ((perm & (S_IXUSR | S_ISUID)) == S_ISUID) {
502 }
else if ((perm & (S_IXUSR | S_ISUID)) == S_IXUSR) {
508 if ((perm & (S_IXGRP | S_ISGID)) == (S_IXGRP | S_ISGID)) {
510 }
else if ((perm & (S_IXGRP | S_ISGID)) == S_ISGID) {
512 }
else if ((perm & (S_IXGRP | S_ISGID)) == S_IXGRP) {
518 if ((perm & (S_IXOTH | S_ISVTX)) == (S_IXOTH | S_ISVTX)) {
520 }
else if ((perm & (S_IXOTH | S_ISVTX)) == S_ISVTX) {
522 }
else if ((perm & (S_IXOTH | S_ISVTX)) == S_IXOTH) {
532 }
else if (m_fileMode != KFileItem::Unknown) {
533 if (Utils::isDirMask(m_fileMode)) {
537 else if (S_ISSOCK(m_fileMode)) {
539 }
else if (S_ISCHR(m_fileMode)) {
541 }
else if (S_ISBLK(m_fileMode)) {
543 }
else if (S_ISFIFO(m_fileMode)) {
554 buffer[1] = (((perm & S_IRUSR) == S_IRUSR) ?
'r' :
'-');
555 buffer[2] = (((perm & S_IWUSR) == S_IWUSR) ?
'w' :
'-');
557 buffer[4] = (((perm & S_IRGRP) == S_IRGRP) ?
'r' :
'-');
558 buffer[5] = (((perm & S_IWGRP) == S_IWGRP) ?
'w' :
'-');
560 buffer[7] = (((perm & S_IROTH) == S_IROTH) ?
'r' :
'-');
561 buffer[8] = (((perm & S_IWOTH) == S_IWOTH) ?
'w' :
'-');
574void KFileItemPrivate::determineMimeTypeHelper(
const QUrl &url)
const
577 if (m_bSkipMimeTypeFromContent || isSlow()) {
597 : d(new KFileItemPrivate(entry,
608 : d(new KFileItemPrivate(
KIO::UDSEntry(), mode,
KFileItem::Unknown, url, false, false,
KFileItem::NormalMimeTypeDetermination))
610 d->m_bMimeTypeKnown = !mimeType.
simplified().isEmpty();
611 if (d->m_bMimeTypeKnown) {
613 d->m_mimeType = db.mimeTypeForName(mimeType);
618 : d(new KFileItemPrivate(
KIO::UDSEntry(),
KFileItem::Unknown,
KFileItem::Unknown, url, false, false, mimeTypeDetermination))
638 qCWarning(KIO_CORE) <<
"null item";
642 d->m_fileMode = KFileItem::Unknown;
643 d->m_permissions = KFileItem::Unknown;
644 d->m_hidden = KFileItemPrivate::Auto;
645 d->m_hiddenCache = KFileItemPrivate::HiddenUncached;
668 d->m_bMimeTypeKnown =
false;
669 d->m_iconName.clear();
677 d->m_delayedMimeTypes = b;
683 qCWarning(KIO_CORE) <<
"null item";
694 qCWarning(KIO_CORE) <<
"null item";
704 qCWarning(KIO_CORE) <<
"null item";
708 d->ensureInitialized();
711 if (!d->m_strName.isEmpty()) {
717 d->m_hiddenCache = KFileItemPrivate::HiddenUncached;
726 d->ensureInitialized();
739 if (d->m_bIsLocalUrl) {
744 size_t linkSize =
size();
746 if (linkSize > SIZE_MAX) {
747 qCWarning(KIO_CORE) <<
"file size bigger than SIZE_MAX, too big for readlink use!" << path;
750 size_t lowerBound = 256;
751 size_t higherBound = 1024;
752 size_t bufferSize = qBound(lowerBound, linkSize + 1, higherBound);
753 QByteArray linkTargetBuffer(bufferSize, Qt::Initialization::Uninitialized);
756 ssize_t n = readlink(pathBA.
constData(), linkTargetBuffer.
data(), linkTargetBuffer.
size());
757 if (n < 0 && errno != ERANGE) {
758 qCWarning(KIO_CORE) <<
"readlink failed!" << pathBA;
760 }
else if (n > 0 &&
static_cast<size_t>(n) != bufferSize) {
766 linkTargetBuffer.
resize(linkTargetBuffer.
size() * 2);
777QString KFileItemPrivate::localPath()
const
795 return d->localPath();
813 return d->recursiveSize();
836 return KACL(fieldVal);
841 return KACL(d->m_permissions);
853 return KACL(fieldVal);
865 return d->time(which);
913 cachedStrings.
insert(gid, groupName);
915 return cachedStrings.
value(gid);
931bool KFileItemPrivate::isSlow()
const
933 if (m_slow == SlowUnknown) {
934 const QString path = localPath();
942 return m_slow == Slow;
945bool KFileItem::isSlow()
const
961 return that->determineMimeType().
name();
970 if (!d->m_mimeType.isValid() || !d->m_bMimeTypeKnown) {
976 d->determineMimeTypeHelper(url);
980 Q_ASSERT(d->m_mimeType.isValid());
983 d->m_bMimeTypeKnown =
true;
986 if (d->m_delayedMimeTypes) {
987 d->m_delayedMimeTypes =
false;
988 d->m_useIconNameCache =
false;
992 return d->m_mimeType;
995bool KFileItem::isMimeTypeKnown()
const
1004 return d->m_bMimeTypeKnown && d->m_guessedMimeType.isEmpty();
1007static bool isDirectoryMounted(
const QUrl &url)
1019 if (info.isDir() && info.size() == 0) {
1025bool KFileItem::isFinalIconKnown()
const
1030 return d->m_bMimeTypeKnown && (!d->m_delayedMimeTypes);
1050 if (isLocalUrl && !d->isSlow() && mime.
inherits(QStringLiteral(
"application/x-desktop"))) {
1059 if (isLocalUrl && isDir() && !d->isSlow() && isDirectoryMounted(url)) {
1061 u.
setPath(Utils::concatPaths(u.
path(), QStringLiteral(
".directory")));
1086 QString icon = cfg.readIcon();
1091 bool isDirEmpty =
true;
1093 while (dirIt.hasNext()) {
1115 const QString icon = cfg.readIcon();
1116 if (cfg.hasLinkType()) {
1120 const QString u = cfg.readUrl();
1126 if (trashConfig.group(QStringLiteral(
"Status")).readEntry(
"Empty",
true)) {
1141 if (d->m_useIconNameCache && !d->m_iconName.isEmpty()) {
1142 return d->m_iconName;
1146 if (!d->m_iconName.isEmpty()) {
1147 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1148 return d->m_iconName;
1156 if (!d->m_guessedMimeType.isEmpty()) {
1159 mime = currentMimeType();
1162 const bool delaySlowOperations = d->m_delayedMimeTypes;
1164 if (isLocalUrl && !delaySlowOperations) {
1167 if (mime.
inherits(QStringLiteral(
"application/x-desktop"))) {
1168 d->m_iconName = iconFromDesktopFile(localFile);
1169 if (!d->m_iconName.isEmpty()) {
1170 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1171 return d->m_iconName;
1176 if (isDirectoryMounted(url)) {
1177 d->m_iconName = iconFromDirectoryFile(localFile);
1178 if (!d->m_iconName.isEmpty()) {
1179 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1180 return d->m_iconName;
1184 d->m_iconName = KIOPrivate::iconForStandardPath(localFile);
1185 if (!d->m_iconName.isEmpty()) {
1186 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1187 return d->m_iconName;
1193 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1194 return d->m_iconName;
1201static bool checkDesktopFile(
const KFileItem &item,
bool _determineMimeType)
1209 if (!item.isRegularFile()) {
1214 if (!item.isReadable()) {
1219 QMimeType mime = _determineMimeType ? item.determineMimeType() : item.currentMimeType();
1220 return mime.
inherits(QStringLiteral(
"application/x-desktop"));
1229 d->ensureInitialized();
1234 names.
append(QStringLiteral(
"emblem-symbolic-link"));
1237 if (!isReadable()) {
1238 names.
append(QStringLiteral(
"emblem-locked"));
1241 if (checkDesktopFile(*
this,
false)) {
1248 names.
append(QStringLiteral(
"emblem-important"));
1253 names.
append(QStringLiteral(
"hidden"));
1261 names.
append(QStringLiteral(
"emblem-shared"));
1279bool KFileItem::isReadable()
const
1285 d->ensureInitialized();
1287 if (d->m_permissions != KFileItem::Unknown) {
1288 const mode_t readMask = S_IRUSR | S_IRGRP | S_IROTH;
1290 if ((d->m_permissions & readMask) == 0) {
1295 if ((d->m_permissions & readMask) == readMask) {
1300 const auto uidOfItem =
userId();
1301 if (uidOfItem != -1) {
1303 if (((uint)uidOfItem) == currentUser.nativeId()) {
1304 return S_IRUSR & d->m_permissions;
1306 const auto gidOfItem =
groupId();
1307 if (gidOfItem != -1) {
1309 return S_IRGRP & d->m_permissions;
1312 return S_IROTH & d->m_permissions;
1317 return S_IRUSR & d->m_permissions;
1329bool KFileItem::isWritable()
const
1335 d->ensureInitialized();
1337 if (d->m_permissions != KFileItem::Unknown) {
1339 if ((d->m_permissions & (S_IWUSR | S_IWGRP | S_IWOTH)) == 0) {
1344 const auto uidOfItem =
userId();
1345 if (uidOfItem != -1) {
1347 if (((uint)uidOfItem) == currentUser.nativeId()) {
1348 return S_IWUSR & d->m_permissions;
1350 const auto gidOfItem =
groupId();
1351 if (gidOfItem != -1) {
1353 return S_IWGRP & d->m_permissions;
1356 if (S_IWOTH & d->m_permissions) {
1363 return S_IWUSR & d->m_permissions;
1368 if (d->m_bIsLocalUrl) {
1375bool KFileItem::isHidden()
const
1382 if (d->m_hidden != KFileItemPrivate::Auto) {
1383 return d->m_hidden == KFileItemPrivate::Hidden;
1385 if (d->m_hiddenCache != KFileItemPrivate::HiddenUncached) {
1386 return d->m_hiddenCache == KFileItemPrivate::HiddenCached;
1390 QString fileName = d->m_url.fileName();
1392 fileName = d->m_strName;
1396 d->m_hiddenCache = fileName.
length() > 1 && fileName[0] ==
QLatin1Char(
'.') ? KFileItemPrivate::HiddenCached : KFileItemPrivate::ShownCached;
1397 return d->m_hiddenCache == KFileItemPrivate::HiddenCached;
1400void KFileItem::setHidden()
1403 d->m_hidden = KFileItemPrivate::Hidden;
1407bool KFileItem::isDir()
const
1413 if (d->m_fileMode != KFileItem::Unknown) {
1415 return Utils::isDirMask(d->m_fileMode);
1418 if (d->m_bMimeTypeKnown && d->m_mimeType.isValid()) {
1421 return d->m_mimeType.inherits(QStringLiteral(
"inode/directory"));
1424 if (d->m_bSkipMimeTypeFromContent) {
1428 d->ensureInitialized();
1430 if (d->m_fileMode == KFileItem::Unknown) {
1435 return Utils::isDirMask(d->m_fileMode);
1438bool KFileItem::isFile()
const
1453 auto toDisplayUrl = [](
const QUrl &url) {
1464 const QString comment = mimeComment();
1467 auto linkText = linkDest();
1468 if (!linkText.startsWith(QStringLiteral(
"anon_inode:"))) {
1470 if (d->m_url.isLocalFile()) {
1475 url = d->m_url.resolved(url);
1477 linkText = toDisplayUrl(url);
1481 text +=
i18n(
"(Symbolic Link to %1)", linkText);
1483 text +=
i18n(
"(%1, Link to %2)", comment, linkText);
1485 }
else if (targetUrl() != url()) {
1486 text +=
i18n(
" (Points to %1)", toDisplayUrl(targetUrl()));
1487 }
else if (Utils::isRegFileMask(d->m_fileMode)) {
1490 text += QStringLiteral(
" (%1)").
arg(comment);
1497 if (!d && !item.d) {
1501 if (!d || !item.d) {
1505 return d->cmp(*item.d);
1510 if (!d && !other.d) {
1514 if (!d || !other.d) {
1518 return d->m_url == other.d->m_url;
1532 return other.d->m_url.isValid();
1534 return d->m_url < other.d->m_url;
1542 return d->m_url < other;
1556 d->ensureInitialized();
1558 if (d->m_access.isNull() && d->m_permissions != KFileItem::Unknown) {
1559 d->m_access = d->parsePermissions(d->m_permissions);
1591 return {
QUrl(),
false};
1594 const QString local_path = localPath();
1598 return {d->m_url, d->m_bIsLocalUrl};
1608 s << a.d->m_strName;
1609 s << a.d->m_strText;
1630 qCWarning(KIO_CORE) <<
"null item";
1640 a.d->m_strName = strName;
1641 a.d->m_strText = strText;
1642 a.d->m_bIsLocalUrl = a.d->m_url.isLocalFile();
1643 a.d->m_bMimeTypeKnown =
false;
1664 d->ensureInitialized();
1666 return d->m_permissions;
1675 d->ensureInitialized();
1677 return d->m_fileMode;
1680bool KFileItem::isLink()
const
1686 d->ensureInitialized();
1691bool KFileItem::isLocalFile()
const
1697 return d->m_bIsLocalUrl;
1706 return d->m_strText;
1716 return d->m_strName;
1717 }
else if (d->m_strLowerCaseName.isNull()) {
1718 d->m_strLowerCaseName = d->m_strName.toLower();
1720 return d->m_strLowerCaseName;
1730 if (!targetUrlStr.
isEmpty()) {
1731 return QUrl(targetUrlStr);
1751 if (!d || d->m_url.isEmpty()) {
1755 if (!d->m_mimeType.isValid()) {
1759 d->m_mimeType = db.
mimeTypeForName(QStringLiteral(
"inode/directory"));
1760 return d->m_mimeType;
1763 if (d->m_delayedMimeTypes) {
1766 d->m_mimeType = db.
mimeTypeForName(QStringLiteral(
"application/octet-stream"));
1767 d->m_bMimeTypeKnown =
false;
1769 d->m_mimeType = mimeTypes.
first();
1771 d->m_bMimeTypeKnown = (mimeTypes.
count() == 1);
1775 d->determineMimeTypeHelper(url);
1776 d->m_bMimeTypeKnown =
true;
1779 return d->m_mimeType;
1788 d->ensureInitialized();
1795 return d ==
nullptr;
1803 if (!d->m_bInitCalled) {
1804 qCWarning(KIO_CORE) <<
"KFileItem: exists called when not initialised" << d->m_url;
1807 return d->m_fileMode != KFileItem::Unknown;
1816 d->ensureInitialized();
1818 if (d->m_permissions == KFileItem::Unknown) {
1822 const mode_t executableMask = S_IXGRP | S_IXUSR | S_IXOTH;
1823 if ((d->m_permissions & executableMask) == 0) {
1828 const auto uid =
userId();
1831 return S_IXUSR & d->m_permissions;
1837 return S_IXGRP & d->m_permissions;
1840 return S_IXOTH & d->m_permissions;
1846 return S_IXUSR & d->m_permissions;
1867 return item.name() == fileName;
1876 return item.url() == url;
1887 for (
const auto &item : *
this) {
1898 for (
const auto &item : *
this) {
1899 lst.
append(item.targetUrl());
1904bool KFileItem::isDesktopFile()
const
1906 return checkDesktopFile(*
this,
true);
1909bool KFileItem::isRegularFile()
const
1915 d->ensureInitialized();
1917 return Utils::isRegFileMask(d->m_fileMode);
1922 if (!d || isDir()) {
1926 const int lastDot = d->m_strText.lastIndexOf(QStringLiteral(
"."));
1928 return d->m_strText.mid(lastDot + 1);
1939 stream <<
"[null KFileItem]";
1941 stream <<
"[KFileItem for " << item.url() <<
"]";
1946#include "moc_kfileitem.cpp"
The KACL class encapsulates a POSIX Access Control List.
bool hasKey(const char *key) const
QString readEntry(const char *key, const char *aDefault=nullptr) const
QString readComment() const
KConfigGroup desktopGroup() const
static bool isAuthorizedDesktopFile(const QString &path)
KFileItem findByUrl(const QUrl &url) const
Find a KFileItem by URL and return it.
KFileItem findByName(const QString &fileName) const
Find a KFileItem by name and return it.
KFileItemList()
Creates an empty list of file items.
QList< QUrl > targetUrlList() const
QList< QUrl > urlList() const
A KFileItem is a generic class to handle a file, local or remote.
KFileItem & operator=(const KFileItem &)
Copy assignment.
int userId() const
Returns the file's owner's user id.
int groupId() const
Returns the file's owner's group id.
QUrl mostLocalUrl(bool *local=nullptr) const
Tries to return a local URL for this file item if possible.
bool operator==(const KFileItem &other) const
Returns true if both items share the same URL.
void setUrl(const QUrl &url)
Sets the item's URL.
bool operator!=(const KFileItem &other) const
Returns true if both items do not share the same URL.
KIO::filesize_t size() const
Returns the size of the file, if known.
Q_INVOKABLE QString timeString(KFileItem::FileTimes which=ModificationTime) const
Requests the modification, access or creation time as a string, depending on which.
FileTimes
The timestamps associated with a file.
Q_INVOKABLE QDateTime time(KFileItem::FileTimes which) const
Requests the modification, access or creation time, depending on which.
bool cmp(const KFileItem &item) const
Somewhat like a comparison operator, but more explicit, and it can detect that two fileitems differ i...
bool hasExtendedACL() const
Tells if the file has extended access level information ( Posix ACL )
KACL defaultACL() const
Returns the default access control list for the directory.
mode_t permissions() const
Returns the permissions of the file (stat.st_mode containing only permissions).
KIO::filesize_t recursiveSize() const
For folders, its recursive size: the size of its files plus the recursiveSize of its folder.
KFileItem()
Null KFileItem.
KACL ACL() const
Returns the access control list for the file.
void refreshMimeType()
Re-reads MIME type information.
MostLocalUrlResult isMostLocalUrl() const
Returns a MostLocalUrlResult, with the local Url for this item if possible (otherwise an empty Url),...
bool exists() const
returns whether the KFileItem exists on-disk Call only after initialization (i.e KIO::stat or refresh...
bool isNull() const
Return true if default-constructed.
KIO::UDSEntry entry() const
Returns the UDS entry.
bool isExecutable() const
Return true if the file has executable permission.
QString suffix() const
Returns the file extension Similar to QFileInfo::suffix except it takes into account UDS_DISPLAY_NAME...
mode_t mode() const
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
QString permissionsString() const
Returns the access permissions for the file as a string.
void setLocalPath(const QString &path)
Sets the item's local path (UDS_LOCAL_PATH).
void setDelayedMimeTypes(bool b)
Sets MIME type determination to be immediate or on demand.
void refresh()
Throw away and re-read (for local files) all information about the file.
bool operator<(const KFileItem &other) const
Returns true if this item's URL is lexically less than other's URL; otherwise returns false.
void setName(const QString &name)
Sets the item's name (i.e. the filename).
Universal Directory Service.
void reserve(int size)
Calling this function before inserting items into an empty UDSEntry may save time and memory.
QString stringValue(uint field) const
long long numberValue(uint field, long long defaultValue=0) const
@ UDS_LOCAL_USER_ID
User ID of the file owner.
@ UDS_CREATION_TIME
The time the file was created. Required time format: seconds since UNIX epoch.
@ UDS_ICON_OVERLAY_NAMES
A comma-separated list of supplementary icon overlays which will be added to the list of overlays cre...
@ UDS_HIDDEN
Treat the file as a hidden file (if set to 1) or as a normal file (if set to 0).
@ UDS_URL
An alternative URL (If different from the caption).
@ UDS_GROUP
Group Name of the file owner Not present on local fs, use UDS_LOCAL_GROUP_ID.
@ UDS_LINK_DEST
Name of the file where the link points to Allows to check for a symlink (don't use S_ISLNK !...
@ UDS_LOCAL_GROUP_ID
Group ID of the file owner.
@ UDS_MIME_TYPE
A MIME type; the KIO worker should set it if it's known.
@ UDS_LOCAL_PATH
A local file path if the KIO worker display files sitting on the local filesystem (but in another hie...
@ UDS_FILE_TYPE
File type, part of the mode returned by stat (for a link, this returns the file type of the pointed i...
@ UDS_DISPLAY_TYPE
User-readable type of file (if not specified, the MIME type's description is used)
@ UDS_MODIFICATION_TIME
The last time the file was modified. Required time format: seconds since UNIX epoch.
@ UDS_COMMENT
A comment which will be displayed as is to the user.
@ UDS_SIZE
Size of the file.
@ UDS_DEVICE_ID
Device number for this file, used to detect hardlinks.
@ UDS_ACCESS_TIME
The last time the file was opened. Required time format: seconds since UNIX epoch.
@ UDS_DISPLAY_NAME
If set, contains the label to display instead of the 'real name' in UDS_NAME.
@ UDS_DEFAULT_ACL_STRING
The default access control list serialized into a single string.
@ UDS_NAME
Filename - as displayed in directory listings etc.
@ UDS_TARGET_URL
This file is a shortcut or mount, pointing to an URL in a different hierarchy.
@ UDS_ICON_NAME
Name of the icon, that should be used for displaying.
@ UDS_ACL_STRING
The access control list serialized into a single string.
@ UDS_RECURSIVE_SIZE
For folders, the recursize size of its content.
@ UDS_GUESSED_MIME_TYPE
A MIME type to be used for displaying only.
@ UDS_INODE
Inode number for this file, used to detect hardlinks.
@ UDS_USER
User Name of the file owner Not present on local fs, use UDS_LOCAL_USER_ID.
@ UDS_EXTENDED_ACL
Indicates that the entry has extended ACL entries.
@ UDS_ACCESS
Access permissions (part of the mode returned by stat)
bool contains(uint field) const
check existence of a field
void replace(uint field, const QString &value)
Replace or insert field with string value.
int count() const
count fields
static KNFSShare * instance()
Returns the one and only instance of KNFSShare.
static bool supportsWriting(const QUrl &url)
Returns whether the protocol can store data to URLs.
static KSambaShare * instance()
QList< KUserGroup > groups(uint maxCount=KCOREADDONS_UINT_MAX) const
QString loginName() const
QString i18n(const char *text, const TYPE &arg...)
AKONADI_CALENDAR_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &collection)
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
KCOREADDONS_EXPORT Type fileSystemType(const QString &path)
A namespace for KIO globals.
KIOCORE_EXPORT QString convertSize(KIO::filesize_t size)
Converts size from bytes to the string representation.
qulonglong filesize_t
64-bit file size
@ StatDefaultDetails
Default StatDetail flag when creating a StatJob.
KIOCORE_EXPORT QString decodeFileName(const QString &str)
Decodes (from the filename to the text displayed) This doesn't do anything anymore,...
QString path(const QString &relativePath)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
KCOREADDONS_EXPORT QString tildeCollapse(const QString &path)
const char * constData() const const
void resize(qsizetype newSize, char c)
qsizetype size() const const
void truncate(qsizetype pos)
QDateTime fromSecsSinceEpoch(qint64 secs)
QDateTime toLocalTime() const const
qint64 toSecsSinceEpoch() const const
QByteArray encodeName(const QString &fileName)
QString symLinkTarget() const const
bool isReadable() const const
bool isWritable() const const
qint64 size() const const
void append(QList< T > &&value)
const_iterator cbegin() const const
const_iterator cend() const const
qsizetype count() const const
bool isEmpty() const const
void reserve(qsizetype size)
qsizetype size() const const
QString toString(QDate date, FormatType format) const const
bool contains(const Key &key) const const
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue) const const
QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const const
QMimeType mimeTypeForName(const QString &nameOrAlias) const const
QMimeType mimeTypeForUrl(const QUrl &url) const const
QList< QMimeType > mimeTypesForFileName(const QString &fileName) const const
bool inherits(const QString &mimeTypeName) const const
QString arg(Args &&... args) const const
QString fromLatin1(QByteArrayView str)
QString fromUtf8(QByteArrayView str)
bool isEmpty() const const
qsizetype length() const const
QString simplified() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QStringView mid(qsizetype start, qsizetype length) const const
QUrl adjusted(FormattingOptions options) const const
QString fileName(ComponentFormattingOptions options) const const
QUrl fromLocalFile(const QString &localFile)
bool isEmpty() const const
bool isLocalFile() const const
bool isValid() const const
QString path(ComponentFormattingOptions options) const const
QString scheme() const const
void setPath(const QString &path, ParsingMode mode)
void setScheme(const QString &scheme)
QString toDisplayString(FormattingOptions options) const const
QString toLocalFile() const const
QVariant fromValue(T &&value)
static KUserId currentUserId()