Baloo

udstools.h
1/*
2 SPDX-FileCopyrightText: 2005 David Faure <faure@kde.org>
3 SPDX-FileCopyrightText: 2007 Thiago Macieira <thiago@kde.org>
4 SPDX-FileCopyrightText: 2020 Stefan BrĂ¼ns <bruns@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef BALOO_KIO_COMMON_UDSTOOLS_H_
10#define BALOO_KIO_COMMON_UDSTOOLS_H_
11
12#include "usergroupcache.h"
13#include "idutils.h"
14#include <QUrl>
15
16namespace Baloo {
17
18class UdsFactory
19{
20public:
21 KIO::UDSEntry createUdsEntry(const QString& filePath) const;
22
23private:
24 UserGroupCache m_userGroupCache;
25};
26
27inline KIO::UDSEntry UdsFactory::createUdsEntry(const QString& filePath) const
28{
29 KIO::UDSEntry uds;
30
31 QT_STATBUF statBuf;
32 const QByteArray ba = QFile::encodeName(filePath);
33 if (filePathToStat(ba, statBuf) != 0) {
34 return uds;
35 }
36
37 uds.reserve(12);
38 uds.fastInsert(KIO::UDSEntry::UDS_DEVICE_ID, statBuf.st_dev);
39 uds.fastInsert(KIO::UDSEntry::UDS_INODE, statBuf.st_ino);
40
41 mode_t type = statBuf.st_mode & S_IFMT;
42 mode_t access = statBuf.st_mode & 07777;
43
44 uds.fastInsert(KIO::UDSEntry::UDS_SIZE, statBuf.st_size);
48 uds.fastInsert(KIO::UDSEntry::UDS_ACCESS_TIME, statBuf.st_atime);
49#ifndef Q_OS_WIN
50 uds.fastInsert(KIO::UDSEntry::UDS_USER, m_userGroupCache.getUserName(KUserId(statBuf.st_uid)));
51 uds.fastInsert(KIO::UDSEntry::UDS_GROUP, m_userGroupCache.getGroupName(KGroupId(statBuf.st_gid)));
52#else
53#pragma message("TODO: st_uid and st_gid are always zero, use GetSecurityInfo to find the owner")
54#endif
55
56 QUrl url = QUrl::fromLocalFile(filePath);
60
61 return uds;
62}
63
64}
65#endif
void reserve(int size)
void fastInsert(uint field, const QString &value)
Type type(const QSqlDatabase &db)
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
QByteArray encodeName(const QString &fileName)
QString fileName(ComponentFormattingOptions options) const const
QUrl fromLocalFile(const QString &localFile)
QString url(FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.