Warning, file /frameworks/kio/src/ioslaves/file/file.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2000-2002 Stephan Kulow <coolo@kde.org> 0003 SPDX-FileCopyrightText: 2000-2002 David Faure <faure@kde.org> 0004 SPDX-FileCopyrightText: 2000-2002 Waldo Bastian <bastian@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef __file_h__ 0010 #define __file_h__ 0011 0012 #include <kio/global.h> 0013 #include <kio/slavebase.h> 0014 0015 #include <KUser> 0016 #include <QFile> 0017 #include <QHash> 0018 #include <QObject> 0019 0020 #include <config-kioslave-file.h> 0021 #include <qplatformdefs.h> // mode_t 0022 0023 #if HAVE_SYS_ACL_H 0024 #include <sys/acl.h> 0025 #endif 0026 #if HAVE_ACL_LIBACL_H 0027 #include <acl/libacl.h> 0028 #endif 0029 0030 #include "file_p.h" 0031 0032 #include <QLoggingCategory> 0033 Q_DECLARE_LOGGING_CATEGORY(KIO_FILE) 0034 0035 class FileProtocol : public QObject, public KIO::SlaveBase 0036 { 0037 Q_OBJECT 0038 public: 0039 FileProtocol(const QByteArray &pool, const QByteArray &app); 0040 ~FileProtocol() override; 0041 0042 void get(const QUrl &url) override; 0043 virtual void put(const QUrl &url, int _mode, KIO::JobFlags _flags) override; 0044 virtual void copy(const QUrl &src, const QUrl &dest, int mode, KIO::JobFlags flags) override; 0045 virtual void rename(const QUrl &src, const QUrl &dest, KIO::JobFlags flags) override; 0046 virtual void symlink(const QString &target, const QUrl &dest, KIO::JobFlags flags) override; 0047 0048 void stat(const QUrl &url) override; 0049 void listDir(const QUrl &url) override; 0050 void mkdir(const QUrl &url, int permissions) override; 0051 void chmod(const QUrl &url, int permissions) override; 0052 void chown(const QUrl &url, const QString &owner, const QString &group) override; 0053 void setModificationTime(const QUrl &url, const QDateTime &mtime) override; 0054 void del(const QUrl &url, bool isfile) override; 0055 void open(const QUrl &url, QIODevice::OpenMode mode) override; 0056 void read(KIO::filesize_t size) override; 0057 void write(const QByteArray &data) override; 0058 void seek(KIO::filesize_t offset) override; 0059 void truncate(KIO::filesize_t length); 0060 bool copyXattrs(const int src_fd, const int dest_fd); 0061 void close() override; 0062 0063 /** 0064 * Special commands supported by this slave: 0065 * 1 - mount 0066 * 2 - unmount 0067 */ 0068 void special(const QByteArray &data) override; 0069 void unmount(const QString &point); 0070 void mount(bool _ro, const char *_fstype, const QString &dev, const QString &point); 0071 0072 #if HAVE_POSIX_ACL 0073 static bool isExtendedACL(acl_t acl); 0074 #endif 0075 0076 protected: 0077 void virtual_hook(int id, void *data) override; 0078 0079 private: 0080 int setACL(const char *path, mode_t perm, bool _directoryDefault); 0081 QString getUserName(KUserId uid) const; 0082 QString getGroupName(KGroupId gid) const; 0083 bool deleteRecursive(const QString &path); 0084 0085 void fileSystemFreeSpace(const QUrl &url); // KF6 TODO: Turn into virtual method in SlaveBase 0086 0087 bool privilegeOperationUnitTestMode(); 0088 PrivilegeOperationReturnValue execWithElevatedPrivilege(ActionType action, const QVariantList &args, int errcode); 0089 PrivilegeOperationReturnValue tryOpen(QFile &f, const QByteArray &path, int flags, int mode, int errcode); 0090 0091 // We want to execute chmod/chown/utime with elevated privileges (in copy & put) 0092 // only during the brief period privileges are elevated. If it's not the case show 0093 // a warning and continue. 0094 PrivilegeOperationReturnValue tryChangeFileAttr(ActionType action, const QVariantList &args, int errcode); 0095 0096 void redirect(const QUrl &url); 0097 0098 // Close without calling finish(). Use this to close after error. 0099 void closeWithoutFinish(); 0100 0101 private: 0102 QFile *mFile; 0103 0104 bool testMode = false; 0105 KIO::StatDetails getStatDetails(); 0106 }; 0107 0108 #endif