File indexing completed on 2024-04-28 15:26:25

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef knfsshare_h
0009 #define knfsshare_h
0010 
0011 #include <QObject>
0012 
0013 #include "kiocore_export.h"
0014 
0015 #include <memory>
0016 
0017 /**
0018  * @class KNFSShare knfsshare.h <KNFSShare>
0019  *
0020  * Similar functionality like KFileShare,
0021  * but works only for NFS and do not need
0022  * any suid script.
0023  * It parses the /etc/exports file to get its information.
0024  * Singleton class, call instance() to get an instance.
0025  */
0026 class KIOCORE_EXPORT KNFSShare : public QObject
0027 {
0028     Q_OBJECT
0029 public:
0030     /**
0031      * Returns the one and only instance of KNFSShare
0032      */
0033     static KNFSShare *instance();
0034 
0035     /**
0036      * Whether or not the given path is shared by NFS.
0037      * @param path the path to check if it is shared by NFS.
0038      * @return whether the given path is shared by NFS.
0039      */
0040     bool isDirectoryShared(const QString &path) const;
0041 
0042     /**
0043      * Returns a list of all directories shared by NFS.
0044      * The resulting list is not sorted.
0045      * @return a list of all directories shared by NFS.
0046      */
0047     QStringList sharedDirectories() const;
0048 
0049     /**
0050      * KNFSShare destructor.
0051      * Do not call!
0052      * The instance is destroyed automatically!
0053      */
0054     ~KNFSShare() override;
0055 
0056     /**
0057      * Returns the path to the used exports file,
0058      * or null if no exports file was found
0059      */
0060     QString exportsPath() const;
0061 
0062 Q_SIGNALS:
0063     /**
0064      * Emitted when the /etc/exports file has changed
0065      */
0066     void changed();
0067 
0068 private:
0069     KIOCORE_NO_EXPORT KNFSShare();
0070     class KNFSSharePrivate;
0071     std::unique_ptr<KNFSSharePrivate> const d;
0072 
0073     friend class KNFSShareSingleton;
0074 };
0075 
0076 #endif