1 | // -*- c++ -*- |
2 | /* |
3 | This file is part of the KDE libraries |
4 | SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #ifndef KIO_CHMODJOB_H |
10 | #define KIO_CHMODJOB_H |
11 | |
12 | #include "global.h" |
13 | #include "job_base.h" |
14 | #include "kiocore_export.h" |
15 | #include <kfileitem.h> |
16 | |
17 | namespace KIO |
18 | { |
19 | class ChmodJobPrivate; |
20 | /** |
21 | * @class KIO::ChmodJob chmodjob.h <KIO/ChmodJob> |
22 | * |
23 | * This job changes permissions on a list of files or directories, |
24 | * optionally in a recursive manner. |
25 | * @see KIO::chmod() |
26 | */ |
27 | class KIOCORE_EXPORT ChmodJob : public KIO::Job |
28 | { |
29 | Q_OBJECT |
30 | public: |
31 | ~ChmodJob() override; |
32 | |
33 | protected Q_SLOTS: |
34 | void slotResult(KJob *job) override; |
35 | |
36 | protected: |
37 | KIOCORE_NO_EXPORT explicit ChmodJob(ChmodJobPrivate &dd); |
38 | |
39 | private: |
40 | Q_DECLARE_PRIVATE(ChmodJob) |
41 | }; |
42 | |
43 | /** |
44 | * Creates a job that changes permissions/ownership on several files or directories, |
45 | * optionally recursively. |
46 | * This version of chmod uses a KFileItemList so that it directly knows |
47 | * what to do with the items. TODO: a version that takes a QList<QUrl>, |
48 | * and a general job that stats each url and returns a KFileItemList. |
49 | * |
50 | * Note that change of ownership is only supported for local files. |
51 | * |
52 | * Inside directories, the "x" bits will only be changed for files that had |
53 | * at least one "x" bit before, and for directories. |
54 | * This emulates the behavior of chmod +X. |
55 | * |
56 | * @param lstItems The file items representing several files or directories. |
57 | * @param permissions the permissions we want to set |
58 | * @param mask the bits we are allowed to change. |
59 | * For instance, if mask is 0077, we don't change |
60 | * the "user" bits, only "group" and "others". |
61 | * @param newOwner If non-empty, the new owner for the files |
62 | * @param newGroup If non-empty, the new group for the files |
63 | * @param recursive whether to open directories recursively |
64 | * @param flags We support HideProgressInfo here |
65 | * @return The job handling the operation. |
66 | */ |
67 | KIOCORE_EXPORT ChmodJob *chmod(const KFileItemList &lstItems, |
68 | int permissions, |
69 | int mask, |
70 | const QString &newOwner, |
71 | const QString &newGroup, |
72 | bool recursive, |
73 | JobFlags flags = DefaultFlags); |
74 | |
75 | } |
76 | |
77 | #endif |
78 | |