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;
206 bool m_bSkipMimeTypeFromContent : 1;
211 mutable bool m_bInitCalled : 1;
218void KFileItemPrivate::ensureInitialized()
const
220 if (!m_bInitCalled) {
225void KFileItemPrivate::init()
const
231 const bool shouldStat = (m_fileMode == KFileItem::Unknown || m_permissions == KFileItem::Unknown || m_entry.
count() == 0) && m_url.
isLocalFile();
253 mode_t mode = stat_mode(buff);
254 if (Utils::isLinkMask(mode)) {
257 mode = stat_mode(buff);
259 mode = (QT_STAT_MASK - 1) | S_IRWXU | S_IRWXG | S_IRWXO;
263 const mode_t
type = mode & QT_STAT_MASK;
275 const auto uid = stat_uid(buff);
276 const auto gid = stat_gid(buff);
282 if (m_fileMode == KFileItem::Unknown) {
285 if (m_permissions == KFileItem::Unknown) {
286 m_permissions = mode & 07777;
291 appendACLAtoms(pathBA, m_entry, type);
295 if (errno != ENOENT) {
297 qCDebug(KIO_CORE) << QStringLiteral(
"KFileItem: error %1: %2").arg(errno).arg(
QString::fromLatin1(strerror(errno))) <<
"when refreshing"
303 m_bInitCalled =
true;
306void KFileItemPrivate::readUDSEntry(
bool _urlIsDirectory)
322 const bool UDS_URL_seen = !urlStr.
isEmpty();
324 m_url =
QUrl(urlStr);
326 m_bIsLocalUrl =
true;
331 m_bMimeTypeKnown = !mimeTypeStr.
isEmpty();
332 if (m_bMimeTypeKnown) {
340 m_hidden = hiddenVal == 1 ? Hidden : (hiddenVal == 0 ? Shown : Auto);
341 m_hiddenCache = HiddenUncached;
343 if (_urlIsDirectory && !UDS_URL_seen && !m_strName.
isEmpty() && m_strName !=
QLatin1String(
".")) {
347 path = QStringLiteral(
"/");
349 m_url.
setPath(Utils::concatPaths(path, m_strName));
355 if (m_fileMode != KFileItem::Unknown) {
356 m_bInitCalled =
true;
367 if (fieldVal != -1) {
382 if (fieldVal != -1) {
391 switch (mappedWhich) {
392 case KFileItem::ModificationTime:
394 case KFileItem::AccessTime:
396 case KFileItem::CreationTime:
404 m_entry.
replace(udsFieldForTime(mappedWhich), time_t_val);
418 const uint uds = udsFieldForTime(mappedWhich);
420 const long long fieldVal = m_entry.
numberValue(uds, -1);
421 if (fieldVal != -1) {
429void KFileItemPrivate::printCompareDebug(
const KFileItemPrivate &item)
const
436 qDebug() <<
"Comparing" << m_url <<
"and" << item.m_url;
437 qDebug() <<
" name" << (m_strName == item.m_strName);
438 qDebug() <<
" local" << (m_bIsLocalUrl == item.m_bIsLocalUrl);
440 qDebug() <<
" mode" << (m_fileMode == item.m_fileMode);
441 qDebug() <<
" perm" << (m_permissions == item.m_permissions);
447 qDebug() <<
" UDS_DEFAULT_ACL_STRING"
450 qDebug() <<
" m_bLink" << (m_bLink == item.m_bLink);
451 qDebug() <<
" m_hidden" << (m_hidden == item.m_hidden);
453 qDebug() <<
" size" << (size() == item.size());
463inline bool KFileItemPrivate::cmp(
const KFileItemPrivate &item)
const
465 if (item.m_bInitCalled) {
470 item.ensureInitialized();
474 printCompareDebug(item);
478 return (m_strName == item.m_strName
479 && m_bIsLocalUrl == item.m_bIsLocalUrl
480 && m_fileMode == item.m_fileMode
481 && m_permissions == item.m_permissions
487 && m_bLink == item.m_bLink
488 && m_hidden == item.m_hidden
489 && size() == item.size()
500inline QString KFileItemPrivate::parsePermissions(mode_t perm)
const
504 static char buffer[12];
510 if ((perm & (S_IXUSR | S_ISUID)) == (S_IXUSR | S_ISUID)) {
512 }
else if ((perm & (S_IXUSR | S_ISUID)) == S_ISUID) {
514 }
else if ((perm & (S_IXUSR | S_ISUID)) == S_IXUSR) {
520 if ((perm & (S_IXGRP | S_ISGID)) == (S_IXGRP | S_ISGID)) {
522 }
else if ((perm & (S_IXGRP | S_ISGID)) == S_ISGID) {
524 }
else if ((perm & (S_IXGRP | S_ISGID)) == S_IXGRP) {
530 if ((perm & (S_IXOTH | S_ISVTX)) == (S_IXOTH | S_ISVTX)) {
532 }
else if ((perm & (S_IXOTH | S_ISVTX)) == S_ISVTX) {
534 }
else if ((perm & (S_IXOTH | S_ISVTX)) == S_IXOTH) {
544 }
else if (m_fileMode != KFileItem::Unknown) {
545 if (Utils::isDirMask(m_fileMode)) {
549 else if (S_ISSOCK(m_fileMode)) {
551 }
else if (S_ISCHR(m_fileMode)) {
553 }
else if (S_ISBLK(m_fileMode)) {
555 }
else if (S_ISFIFO(m_fileMode)) {
566 buffer[1] = (((perm & S_IRUSR) == S_IRUSR) ?
'r' :
'-');
567 buffer[2] = (((perm & S_IWUSR) == S_IWUSR) ?
'w' :
'-');
569 buffer[4] = (((perm & S_IRGRP) == S_IRGRP) ?
'r' :
'-');
570 buffer[5] = (((perm & S_IWGRP) == S_IWGRP) ?
'w' :
'-');
572 buffer[7] = (((perm & S_IROTH) == S_IROTH) ?
'r' :
'-');
573 buffer[8] = (((perm & S_IWOTH) == S_IWOTH) ?
'w' :
'-');
586void KFileItemPrivate::determineMimeTypeHelper(
const QUrl &url)
const
589 if (m_bSkipMimeTypeFromContent || isSlow()) {
609 : d(new KFileItemPrivate(entry,
620 : d(new KFileItemPrivate(
KIO::UDSEntry(), mode,
KFileItem::Unknown, url, false, false,
KFileItem::NormalMimeTypeDetermination))
622 d->m_bMimeTypeKnown = !mimeType.
simplified().isEmpty();
623 if (d->m_bMimeTypeKnown) {
625 d->m_mimeType = db.mimeTypeForName(mimeType);
630 : d(new KFileItemPrivate(
KIO::UDSEntry(),
KFileItem::Unknown,
KFileItem::Unknown, url, false, false, mimeTypeDetermination))
650 qCWarning(KIO_CORE) <<
"null item";
654 d->m_fileMode = KFileItem::Unknown;
655 d->m_permissions = KFileItem::Unknown;
656 d->m_hidden = KFileItemPrivate::Auto;
657 d->m_hiddenCache = KFileItemPrivate::HiddenUncached;
680 d->m_bMimeTypeKnown =
false;
681 d->m_iconName.clear();
689 d->m_delayedMimeTypes = b;
695 qCWarning(KIO_CORE) <<
"null item";
706 qCWarning(KIO_CORE) <<
"null item";
716 qCWarning(KIO_CORE) <<
"null item";
720 d->ensureInitialized();
723 if (!d->m_strName.isEmpty()) {
729 d->m_hiddenCache = KFileItemPrivate::HiddenUncached;
738 d->ensureInitialized();
751 if (d->m_bIsLocalUrl) {
756 size_t linkSize =
size();
758 if (linkSize > SIZE_MAX) {
759 qCWarning(KIO_CORE) <<
"file size bigger than SIZE_MAX, too big for readlink use!" << path;
762 size_t lowerBound = 256;
763 size_t higherBound = 1024;
764 size_t bufferSize = qBound(lowerBound, linkSize + 1, higherBound);
765 QByteArray linkTargetBuffer(bufferSize, Qt::Initialization::Uninitialized);
768 ssize_t n = readlink(pathBA.
constData(), linkTargetBuffer.
data(), linkTargetBuffer.
size());
769 if (n < 0 && errno != ERANGE) {
770 qCWarning(KIO_CORE) <<
"readlink failed!" << pathBA;
772 }
else if (n > 0 &&
static_cast<size_t>(n) != bufferSize) {
778 linkTargetBuffer.
resize(linkTargetBuffer.
size() * 2);
789QString KFileItemPrivate::localPath()
const
807 return d->localPath();
825 return d->recursiveSize();
848 return KACL(fieldVal);
853 return KACL(d->m_permissions);
865 return KACL(fieldVal);
877 return d->time(which);
925 cachedStrings.
insert(gid, groupName);
927 return cachedStrings.
value(gid);
943bool KFileItemPrivate::isSlow()
const
945 if (m_slow == SlowUnknown) {
946 const QString path = localPath();
954 return m_slow == Slow;
957bool KFileItem::isSlow()
const
973 return that->determineMimeType().
name();
982 if (!d->m_mimeType.isValid() || !d->m_bMimeTypeKnown) {
988 d->determineMimeTypeHelper(url);
992 Q_ASSERT(d->m_mimeType.isValid());
995 d->m_bMimeTypeKnown =
true;
998 if (d->m_delayedMimeTypes) {
999 d->m_delayedMimeTypes =
false;
1000 d->m_useIconNameCache =
false;
1004 return d->m_mimeType;
1007bool KFileItem::isMimeTypeKnown()
const
1016 return d->m_bMimeTypeKnown && d->m_guessedMimeType.isEmpty();
1019static bool isDirectoryMounted(
const QUrl &url)
1031 if (info.isDir() && info.size() == 0) {
1037bool KFileItem::isFinalIconKnown()
const
1042 return d->m_bMimeTypeKnown && (!d->m_delayedMimeTypes);
1062 if (isLocalUrl && !d->isSlow() && mime.
inherits(QStringLiteral(
"application/x-desktop"))) {
1071 if (isLocalUrl && isDir() && !d->isSlow() && isDirectoryMounted(url)) {
1073 u.
setPath(Utils::concatPaths(u.
path(), QStringLiteral(
".directory")));
1098 QString icon = cfg.readIcon();
1103 bool isDirEmpty =
true;
1105 while (dirIt.hasNext()) {
1127 const QString icon = cfg.readIcon();
1128 if (cfg.hasLinkType()) {
1132 const QString u = cfg.readUrl();
1138 if (trashConfig.group(QStringLiteral(
"Status")).readEntry(
"Empty",
true)) {
1153 if (d->m_useIconNameCache && !d->m_iconName.isEmpty()) {
1154 return d->m_iconName;
1158 if (!d->m_iconName.isEmpty()) {
1159 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1160 return d->m_iconName;
1168 if (!d->m_guessedMimeType.isEmpty()) {
1171 mime = currentMimeType();
1174 const bool delaySlowOperations = d->m_delayedMimeTypes;
1176 if (isLocalUrl && !delaySlowOperations) {
1179 if (mime.
inherits(QStringLiteral(
"application/x-desktop"))) {
1180 d->m_iconName = iconFromDesktopFile(localFile);
1181 if (!d->m_iconName.isEmpty()) {
1182 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1183 return d->m_iconName;
1188 if (isDirectoryMounted(url)) {
1189 d->m_iconName = iconFromDirectoryFile(localFile);
1190 if (!d->m_iconName.isEmpty()) {
1191 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1192 return d->m_iconName;
1196 d->m_iconName = KIOPrivate::iconForStandardPath(localFile);
1197 if (!d->m_iconName.isEmpty()) {
1198 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1199 return d->m_iconName;
1205 d->m_useIconNameCache = d->m_bMimeTypeKnown;
1206 return d->m_iconName;
1213static bool checkDesktopFile(
const KFileItem &item,
bool _determineMimeType)
1221 if (!item.isRegularFile()) {
1226 if (!item.isReadable()) {
1231 QMimeType mime = _determineMimeType ? item.determineMimeType() : item.currentMimeType();
1232 return mime.
inherits(QStringLiteral(
"application/x-desktop"));
1241 d->ensureInitialized();
1246 names.
append(QStringLiteral(
"emblem-symbolic-link"));
1249 if (!isReadable()) {
1250 names.
append(QStringLiteral(
"emblem-locked"));
1253 if (checkDesktopFile(*
this,
false)) {
1260 names.
append(QStringLiteral(
"emblem-important"));
1265 names.
append(QStringLiteral(
"hidden"));
1273 names.
append(QStringLiteral(
"emblem-shared"));
1291bool KFileItem::isReadable()
const
1297 d->ensureInitialized();
1299 if (d->m_permissions != KFileItem::Unknown) {
1300 const mode_t readMask = S_IRUSR | S_IRGRP | S_IROTH;
1302 if ((d->m_permissions & readMask) == 0) {
1307 if ((d->m_permissions & readMask) == readMask) {
1312 const auto uidOfItem =
userId();
1313 if (uidOfItem != -1) {
1315 if (((uint)uidOfItem) == currentUser.nativeId()) {
1316 return S_IRUSR & d->m_permissions;
1318 const auto gidOfItem =
groupId();
1319 if (gidOfItem != -1) {
1321 return S_IRGRP & d->m_permissions;
1324 return S_IROTH & d->m_permissions;
1329 return S_IRUSR & d->m_permissions;
1341bool KFileItem::isWritable()
const
1347 d->ensureInitialized();
1349 if (d->m_permissions != KFileItem::Unknown) {
1351 if ((d->m_permissions & (S_IWUSR | S_IWGRP | S_IWOTH)) == 0) {
1356 const auto uidOfItem =
userId();
1357 if (uidOfItem != -1) {
1359 if (((uint)uidOfItem) == currentUser.nativeId()) {
1360 return S_IWUSR & d->m_permissions;
1362 const auto gidOfItem =
groupId();
1363 if (gidOfItem != -1) {
1365 return S_IWGRP & d->m_permissions;
1368 if (S_IWOTH & d->m_permissions) {
1375 return S_IWUSR & d->m_permissions;
1380 if (d->m_bIsLocalUrl) {
1387bool KFileItem::isHidden()
const
1394 if (d->m_hidden != KFileItemPrivate::Auto) {
1395 return d->m_hidden == KFileItemPrivate::Hidden;
1397 if (d->m_hiddenCache != KFileItemPrivate::HiddenUncached) {
1398 return d->m_hiddenCache == KFileItemPrivate::HiddenCached;
1402 QString fileName = d->m_url.fileName();
1404 fileName = d->m_strName;
1408 d->m_hiddenCache = fileName.
length() > 1 && fileName[0] ==
QLatin1Char(
'.') ? KFileItemPrivate::HiddenCached : KFileItemPrivate::ShownCached;
1409 return d->m_hiddenCache == KFileItemPrivate::HiddenCached;
1412void KFileItem::setHidden()
1415 d->m_hidden = KFileItemPrivate::Hidden;
1419bool KFileItem::isDir()
const
1425 if (d->m_fileMode != KFileItem::Unknown) {
1427 return Utils::isDirMask(d->m_fileMode);
1430 if (d->m_bMimeTypeKnown && d->m_mimeType.isValid()) {
1433 return d->m_mimeType.inherits(QStringLiteral(
"inode/directory"));
1436 if (d->m_bSkipMimeTypeFromContent) {
1440 d->ensureInitialized();
1442 if (d->m_fileMode == KFileItem::Unknown) {
1447 return Utils::isDirMask(d->m_fileMode);
1450bool KFileItem::isFile()
const
1465 auto toDisplayUrl = [](
const QUrl &url) {
1476 const QString comment = mimeComment();
1479 auto linkText = linkDest();
1480 if (!linkText.startsWith(QStringLiteral(
"anon_inode:"))) {
1482 if (d->m_url.isLocalFile()) {
1487 url = d->m_url.resolved(url);
1489 linkText = toDisplayUrl(url);
1493 text +=
i18n(
"(Symbolic Link to %1)", linkText);
1495 text +=
i18n(
"(%1, Link to %2)", comment, linkText);
1497 }
else if (targetUrl() != url()) {
1498 text +=
i18n(
" (Points to %1)", toDisplayUrl(targetUrl()));
1499 }
else if (Utils::isRegFileMask(d->m_fileMode)) {
1502 text += QStringLiteral(
" (%1)").
arg(comment);
1509 if (!d && !item.d) {
1513 if (!d || !item.d) {
1517 return d->cmp(*item.d);
1522 if (!d && !other.d) {
1526 if (!d || !other.d) {
1530 return d->m_url == other.d->m_url;
1544 return other.d->m_url.isValid();
1546 return d->m_url < other.d->m_url;
1554 return d->m_url < other;
1568 d->ensureInitialized();
1570 if (d->m_access.isNull() && d->m_permissions != KFileItem::Unknown) {
1571 d->m_access = d->parsePermissions(d->m_permissions);
1603 return {
QUrl(),
false};
1606 const QString local_path = localPath();
1610 return {d->m_url, d->m_bIsLocalUrl};
1620 s << a.d->m_strName;
1621 s << a.d->m_strText;
1642 qCWarning(KIO_CORE) <<
"null item";
1652 a.d->m_strName = strName;
1653 a.d->m_strText = strText;
1654 a.d->m_bIsLocalUrl = a.d->m_url.isLocalFile();
1655 a.d->m_bMimeTypeKnown =
false;
1676 d->ensureInitialized();
1678 return d->m_permissions;
1687 d->ensureInitialized();
1689 return d->m_fileMode;
1692bool KFileItem::isLink()
const
1698 d->ensureInitialized();
1703bool KFileItem::isLocalFile()
const
1709 return d->m_bIsLocalUrl;
1718 return d->m_strText;
1728 return d->m_strName;
1729 }
else if (d->m_strLowerCaseName.isNull()) {
1730 d->m_strLowerCaseName = d->m_strName.toLower();
1732 return d->m_strLowerCaseName;
1742 if (!targetUrlStr.
isEmpty()) {
1743 return QUrl(targetUrlStr);
1763 if (!d || d->m_url.isEmpty()) {
1767 if (!d->m_mimeType.isValid()) {
1771 d->m_mimeType = db.
mimeTypeForName(QStringLiteral(
"inode/directory"));
1772 return d->m_mimeType;
1775 if (d->m_delayedMimeTypes) {
1778 d->m_mimeType = db.
mimeTypeForName(QStringLiteral(
"application/octet-stream"));
1779 d->m_bMimeTypeKnown =
false;
1781 d->m_mimeType = mimeTypes.
first();
1783 d->m_bMimeTypeKnown = (mimeTypes.
count() == 1);
1787 d->determineMimeTypeHelper(url);
1788 d->m_bMimeTypeKnown =
true;
1791 return d->m_mimeType;
1800 d->ensureInitialized();
1807 return d ==
nullptr;
1815 if (!d->m_bInitCalled) {
1816 qCWarning(KIO_CORE) <<
"KFileItem: exists called when not initialised" << d->m_url;
1819 return d->m_fileMode != KFileItem::Unknown;
1828 d->ensureInitialized();
1830 if (d->m_permissions == KFileItem::Unknown) {
1834 const mode_t executableMask = S_IXGRP | S_IXUSR | S_IXOTH;
1835 if ((d->m_permissions & executableMask) == 0) {
1840 const auto uid =
userId();
1843 return S_IXUSR & d->m_permissions;
1849 return S_IXGRP & d->m_permissions;
1852 return S_IXOTH & d->m_permissions;
1858 return S_IXUSR & d->m_permissions;
1879 return item.name() == fileName;
1888 return item.url() == url;
1899 for (
const auto &item : *
this) {
1910 for (
const auto &item : *
this) {
1911 lst.
append(item.targetUrl());
1916bool KFileItem::isDesktopFile()
const
1918 return checkDesktopFile(*
this,
true);
1921bool KFileItem::isRegularFile()
const
1927 d->ensureInitialized();
1929 return Utils::isRegFileMask(d->m_fileMode);
1934 if (!d || isDir()) {
1938 const int lastDot = d->m_strText.lastIndexOf(QStringLiteral(
"."));
1940 return d->m_strText.mid(lastDot + 1);
1951 stream <<
"[null KFileItem]";
1953 stream <<
"[KFileItem for " << item.url() <<
"]";
1958#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()