KCoreAddons

klistopenfilesjob.h
1/*
2 This file is part of the KDE project
3
4 SPDX-FileCopyrightText: 2010 Jacopo De Simoi <wilderkde@gmail.com>
5 SPDX-FileCopyrightText: 2014 Lukáš Tinkl <ltinkl@redhat.com>
6 SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
7 SPDX-FileCopyrightText: 2019 David Hallas <david@davidhallas.dk>
8
9 SPDX-License-Identifier: LGPL-2.0-only
10*/
11
12#ifndef KLISTOPENFILESJOB_H
13#define KLISTOPENFILESJOB_H
14
15#include <QObject>
16#include <QString>
17#include <kcoreaddons_export.h>
18#include <kjob.h>
19#include <kprocesslist.h>
20
21#include <memory>
22
23class KListOpenFilesJobPrivate;
24
25/**
26 * @brief Provides information about processes that have open files in a given path or subdirectory of path.
27 *
28 * When start() is invoked it starts to collect information about processes that have any files open in path or a
29 * subdirectory of path. When it is done the KJob::result signal is emitted and the result can be retrieved with the
30 * processInfoList function.
31 *
32 * On Unix like systems the lsof utility is used to get the list of processes.
33 * On Windows the listing always fails with error code NotSupported.
34 *
35 * @since 5.63
36 */
37class KCOREADDONS_EXPORT KListOpenFilesJob : public KJob
38{
39 Q_OBJECT
40public:
41 explicit KListOpenFilesJob(const QString &path);
42 ~KListOpenFilesJob() override;
43 void start() override;
44 /**
45 * @brief Returns the list of processes with open files for the requested path
46 * @return The list of processes with open files for the requested path
47 */
48 KProcessList::KProcessInfoList processInfoList() const;
49
50public:
51 /**
52 * @brief Special error codes emitted by KListOpenFilesJob
53 *
54 * The KListOpenFilesJob uses the error codes defined here besides the standard error codes defined by KJob
55 */
56 enum class Error {
57 /*** Indicates that the platform doesn't support listing open files by processes */
58 NotSupported = KJob::UserDefinedError + 1,
59 /*** Internal error has ocurred */
60 InternalError = KJob::UserDefinedError + 2,
61 /*** The specified path does not exist */
62 DoesNotExist = KJob::UserDefinedError + 11,
63 };
64
65private:
66 friend class KListOpenFilesJobPrivate;
67 std::unique_ptr<KListOpenFilesJobPrivate> const d;
68};
69
70#endif // KLISTOPENFILESJOB_H
The base class for all jobs.
Definition kjob.h:74
virtual Q_SCRIPTABLE void start()=0
Starts the job asynchronously.
Provides information about processes that have open files in a given path or subdirectory of path.
Error
Special error codes emitted by KListOpenFilesJob.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.