File indexing completed on 2024-12-01 07:33:10

0001 /*
0002     SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef _K3B_LSOF_WRAPPER_H_
0007 #define _K3B_LSOF_WRAPPER_H_
0008 
0009 #include <QList>
0010 #include <QString>
0011 
0012 namespace K3b {
0013     namespace Device {
0014         class Device;
0015     }
0016 
0017     class LsofWrapper
0018     {
0019     public:
0020         LsofWrapper();
0021         ~LsofWrapper();
0022 
0023         /**
0024          * Checks which processes currently have an open file descriptor
0025          * to the device.
0026          *
0027          * \return true if lsof was successfully called.
0028          */
0029         bool checkDevice( Device::Device* );
0030 
0031         struct Process {
0032             QString name;
0033             int pid;
0034         };
0035 
0036         /**
0037          * \return A list of all applications that had an open
0038          * handle on the device used in the last successful call
0039          * to checkDevice.
0040          */
0041         const QList<Process>& usingApplications() const;
0042 
0043     private:
0044         bool findLsofExecutable();
0045 
0046         class Private;
0047         Private* d;
0048     };
0049 }
0050 
0051 #endif
0052