File indexing completed on 2024-05-12 09:51:53

0001 /*
0002     SPDX-FileCopyrightText: 2008-2011 Volker Lanz <vl@fidra.de>
0003     SPDX-FileCopyrightText: 2014-2017 Andrius Štikonas <andrius@stikonas.eu>
0004     SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk>
0005     SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org>
0006     SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-3.0-or-later
0009 */
0010 
0011 #ifndef KPMCORE_HELPERS_H
0012 #define KPMCORE_HELPERS_H
0013 
0014 #include "core/partition.h"
0015 #include "fs/filesystem.h"
0016 #include "fs/luks.h"
0017 
0018 #include "util/libpartitionmanagerexport.h"
0019 
0020 class KAboutData;
0021 
0022 class Partition;
0023 class QString;
0024 
0025 LIBKPMCORE_EXPORT void registerMetaTypes();
0026 LIBKPMCORE_EXPORT bool caseInsensitiveLessThan(const QString& s1, const QString& s2);
0027 LIBKPMCORE_EXPORT bool checkAccessibleDevices();
0028 LIBKPMCORE_EXPORT bool isMounted(const QString& deviceNode);
0029 LIBKPMCORE_EXPORT KAboutData aboutKPMcore();
0030 
0031 /** Pointer to the file system (which might be inside LUKS container) contained in the partition
0032  * @param p Partition where we look for file system
0033  * @param fs inner FileSystem object
0034 */
0035 template <typename T>
0036 inline LIBKPMCORE_EXPORT void innerFS (const Partition* p, T& fs)
0037 {
0038     Partition* partition = const_cast<Partition*>(p);
0039     if (p->roles().has(PartitionRole::Luks))
0040         fs = dynamic_cast<const T>(dynamic_cast<const FS::luks* const>(&p->fileSystem())->innerFS());
0041     else
0042         fs = dynamic_cast<const T>(&partition->fileSystem());
0043 }
0044 
0045 #endif