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
17namespace KIO
18{
19class ChmodJobPrivate;
20/*!
21 * \class KIO::ChmodJob
22 * \inheaderfile KIO/ChmodJob
23 * \inmodule KIOCore
24 *
25 * \brief This job changes permissions on a list of files or directories,
26 * optionally in a recursive manner.
27 *
28 * \sa KIO::chmod()
29 */
30class KIOCORE_EXPORT ChmodJob : public KIO::Job
31{
32 Q_OBJECT
33public:
34 ~ChmodJob() override;
35
36protected Q_SLOTS:
37 void slotResult(KJob *job) override;
38
39protected:
40 KIOCORE_NO_EXPORT explicit ChmodJob(ChmodJobPrivate &dd);
41
42private:
43 Q_DECLARE_PRIVATE(ChmodJob)
44};
45
46/*!
47 * \relates KIO::ChmodJob
48 *
49 * Creates a job that changes permissions/ownership on several files or directories,
50 * optionally recursively.
51 * This version of chmod uses a KFileItemList so that it directly knows
52 * what to do with the items. TODO: a version that takes a QList<QUrl>,
53 * and a general job that stats each url and returns a KFileItemList.
54 *
55 * Note that change of ownership is only supported for local files.
56 *
57 * Inside directories, the "x" bits will only be changed for files that had
58 * at least one "x" bit before, and for directories.
59 * This emulates the behavior of chmod +X.
60 *
61 * \a lstItems The file items representing several files or directories.
62 *
63 * \a permissions the permissions we want to set
64 *
65 * \a mask the bits we are allowed to change.
66 * For instance, if mask is 0077, we don't change
67 * the "user" bits, only "group" and "others".
68 *
69 * \a newOwner If non-empty, the new owner for the files
70 *
71 * \a newGroup If non-empty, the new group for the files
72 *
73 * \a recursive whether to open directories recursively
74 *
75 * \a flags We support HideProgressInfo here
76 *
77 * Returns the job handling the operation.
78 */
79KIOCORE_EXPORT ChmodJob *chmod(const KFileItemList &lstItems,
80 int permissions,
81 int mask,
82 const QString &newOwner,
83 const QString &newGroup,
84 bool recursive,
85 JobFlags flags = DefaultFlags);
86
87}
88
89#endif
90

source code of kio/src/core/chmodjob.h