2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2020-08-08 23:32:09 +02:00
|
|
|
*
|
2020-05-30 16:15:03 +02:00
|
|
|
* SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
2020-08-08 23:32:09 +02:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2019-06-13 14:55:43 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2019-06-13 14:55:43 +02:00
|
|
|
*
|
2020-05-30 16:15:03 +02:00
|
|
|
*
|
2019-06-13 14:55:43 +02:00
|
|
|
*/
|
2019-06-19 09:06:05 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: this functionality is only available when Calamares is compiled
|
|
|
|
* with KPMcore support.
|
|
|
|
*/
|
|
|
|
|
2019-06-13 14:55:43 +02:00
|
|
|
#ifndef PARTITION_FILESYSTEM_H
|
|
|
|
#define PARTITION_FILESYSTEM_H
|
|
|
|
|
2020-08-08 23:32:09 +02:00
|
|
|
#include "DllMacro.h"
|
2022-07-19 11:46:57 +02:00
|
|
|
#include "partition/Global.h"
|
2020-08-08 23:32:09 +02:00
|
|
|
|
2019-06-13 14:55:43 +02:00
|
|
|
#include <kpmcore/fs/filesystem.h>
|
|
|
|
|
|
|
|
namespace CalamaresUtils
|
|
|
|
{
|
|
|
|
namespace Partition
|
|
|
|
{
|
2020-08-08 23:32:09 +02:00
|
|
|
QString DLLEXPORT prettyNameForFileSystemType( FileSystem::Type t );
|
2020-02-13 13:48:12 +01:00
|
|
|
|
2020-08-09 00:00:14 +02:00
|
|
|
/** @brief Returns a machine-readable identifier for the filesystem type
|
|
|
|
*
|
|
|
|
* This identifier is used in filesystem manipulation --
|
|
|
|
* e.g. when mounting the filesystem, or in /etc/fstab. It
|
|
|
|
* is almost always just what KPMCore says it is, with
|
|
|
|
* the following exceptions:
|
|
|
|
* - reiserfs is called "reiser" by KPMCore, "reiserfs" by Calamares
|
|
|
|
*/
|
|
|
|
QString DLLEXPORT untranslatedFS( FileSystem::Type t );
|
|
|
|
|
|
|
|
/** @brief Returns the machine-readable identifier for the given @p fs
|
|
|
|
*
|
|
|
|
* See notes for untranslatedFS(), above.
|
|
|
|
*/
|
2020-02-13 13:48:12 +01:00
|
|
|
static inline QString
|
|
|
|
untranslatedFS( FileSystem& fs )
|
|
|
|
{
|
2020-08-09 00:00:14 +02:00
|
|
|
return untranslatedFS( fs.type() );
|
2020-02-13 13:48:12 +01:00
|
|
|
}
|
|
|
|
|
2020-08-09 00:00:14 +02:00
|
|
|
/** @brief Returns a machine-readable identifier for the given @p fs
|
|
|
|
*
|
|
|
|
* Returns an empty string is the @p fs is not valid (e.g. nullptr).
|
|
|
|
*/
|
2020-02-13 13:48:12 +01:00
|
|
|
static inline QString
|
|
|
|
untranslatedFS( FileSystem* fs )
|
|
|
|
{
|
|
|
|
return fs ? untranslatedFS( *fs ) : QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline QString
|
|
|
|
userVisibleFS( FileSystem& fs )
|
|
|
|
{
|
|
|
|
return fs.name();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline QString
|
|
|
|
userVisibleFS( FileSystem* fs )
|
|
|
|
{
|
|
|
|
return fs ? userVisibleFS( *fs ) : QString();
|
|
|
|
}
|
|
|
|
|
2022-07-19 11:46:57 +02:00
|
|
|
/** @brief Mark a particular filesystem type as used (or not)
|
|
|
|
*
|
|
|
|
* See useFilesystemGS(const QString&, bool); this method uses the filesystem type
|
|
|
|
* enumeration to pick the name. (The other implementation is in `Global.h`
|
|
|
|
* because it touches Global Storage, but this one needs KPMcore)
|
|
|
|
*/
|
|
|
|
inline void
|
|
|
|
useFilesystemGS( FileSystem::Type filesystem, bool used )
|
|
|
|
{
|
|
|
|
useFilesystemGS( untranslatedFS( filesystem ), used );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* @brief Reads from global storage whether the typesystem type is used
|
|
|
|
*
|
|
|
|
* See isFilesystemUsedGS(const QString&). (The other implementation is in `Global.h`
|
|
|
|
* because it touches Global Storage, but this one needs KPMcore)
|
|
|
|
*/
|
|
|
|
inline bool
|
|
|
|
isFilesystemUsedGS( FileSystem::Type filesystem )
|
|
|
|
{
|
|
|
|
return isFilesystemUsedGS( untranslatedFS( filesystem ) );
|
|
|
|
}
|
2020-02-13 13:48:12 +01:00
|
|
|
|
2019-06-13 14:55:43 +02:00
|
|
|
} // namespace Partition
|
|
|
|
} // namespace CalamaresUtils
|
|
|
|
|
|
|
|
#endif // PARTITION_PARTITIONQUERY_H
|