source: calamares/trunk/fuentes/src/modules/partition/core/KPMHelpers.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 3.9 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014,      Aurélien Gâteau <agateau@kde.org>
4 *   Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef KPMHELPERS_H
20#define KPMHELPERS_H
21
22// KPMcore
23#include <kpmcore/core/partitiontable.h>
24#include <kpmcore/fs/filesystem.h>
25
26// Qt
27#include <QList>
28
29#include <functional>
30
31class Device;
32class Partition;
33class PartitionNode;
34class PartitionRole;
35
36/**
37 * Helper functions to manipulate partitions
38 */
39namespace KPMHelpers
40{
41
42/**
43 * Thin wrapper on top of CoreBackendManager. Hides things like initializing the
44 * Config instance or instantiating the backend.
45 *
46 * Initialize PartitionManager Config object and load a PartitionManager
47 * backend. It loads the "libparted" plugin by default, but this can be
48 * overloaded by settings the environment variable KPMCORE_BACKEND. Setting it to
49 * "dummy" will load the dummy plugin instead.
50 *
51 * @return true if initialization was successful.
52 */
53bool initKPMcore();
54
55bool isPartitionFreeSpace( Partition* );
56
57/**
58 * Returns true if the partition is planned to be created by the installer as
59 * opposed to already existing on the disk.
60 */
61bool isPartitionNew( Partition* );
62
63/**
64 * Iterates on all devices and return the first partition which is associated
65 * with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint()
66 */
67Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint );
68
69/**
70 * Iterates on all devices and partitions and returns a pointer to the Partition object
71 * for the given path, or nullptr if a Partition for the given path cannot be found.
72 */
73Partition* findPartitionByPath( const QList< Device* >& devices, const QString& path );
74
75/**
76 * Iterates on all devices and partitions and returns a list of pointers to the Partition
77 * objects that satisfy the conditions defined in the criterion function.
78 */
79QList< Partition* > findPartitions( const QList< Device* >& devices,
80                                    std::function< bool ( Partition* ) > criterionFunction );
81
82/**
83 * Helper function to create a new Partition object (does not create anything
84 * on the disk) associated with a FileSystem.
85 */
86Partition* createNewPartition( PartitionNode* parent,
87                               const Device& device,
88                               const PartitionRole& role,
89                               FileSystem::Type fsType,
90                               qint64 firstSector,
91                               qint64 lastSector,
92                               PartitionTable::Flags flags = PartitionTable::FlagNone );
93
94Partition* createNewEncryptedPartition( PartitionNode* parent,
95                                        const Device& device,
96                                        const PartitionRole& role,
97                                        FileSystem::Type fsType,
98                                        qint64 firstSector,
99                                        qint64 lastSector,
100                                        const QString& passphrase,
101                                        PartitionTable::Flags flags = PartitionTable::FlagNone );
102
103Partition* clonePartition( Device* device, Partition* partition );
104
105QString prettyNameForFileSystemType( FileSystem::Type t );
106}
107
108#endif /* KPMHELPERS_H */
Note: See TracBrowser for help on using the repository browser.