Further splitting of detectFileSystem function.
This commit is contained in:
parent
ba05f99720
commit
ae05c031b7
|
@ -464,13 +464,29 @@ FileSystem::Type SfdiskBackend::detectFileSystem(const QString& partitionPath)
|
|||
QStringLiteral("--query=property"),
|
||||
partitionPath });
|
||||
|
||||
if (udevCommand.run(-1) && udevCommand.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("ID_FS_TYPE=(\\w+)"));
|
||||
QRegularExpression re2(QStringLiteral("ID_FS_VERSION=(\\w+)"));
|
||||
QRegularExpressionMatch reFileSystemType = re.match(udevCommand.output());
|
||||
QRegularExpressionMatch reFileSystemVersion = re2.match(udevCommand.output());
|
||||
QString udevTypeRegExp = QStringLiteral("ID_FS_TYPE=(\\w+)");
|
||||
QString udevVersionRegExp = QStringLiteral("ID_FS_VERSION=(\\w+)");
|
||||
|
||||
QString name = {};
|
||||
|
||||
rval = runDetectFileSystemCommand(udevCommand, udevTypeRegExp, udevVersionRegExp, name);
|
||||
|
||||
if (rval == FileSystem::Type::Unknown) {
|
||||
qWarning() << "unknown file system type " << name << " on " << partitionPath;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
FileSystem::Type SfdiskBackend::runDetectFileSystemCommand(ExternalCommand& command, QString& typeRegExp, QString& versionRegExp, QString& name)
|
||||
{
|
||||
FileSystem::Type rval = FileSystem::Type::Unknown;
|
||||
|
||||
if (command.run(-1) && command.exitCode() == 0) {
|
||||
QRegularExpression re(typeRegExp);
|
||||
QRegularExpression re2(versionRegExp);
|
||||
QRegularExpressionMatch reFileSystemType = re.match(command.output());
|
||||
QRegularExpressionMatch reFileSystemVersion = re2.match(command.output());
|
||||
|
||||
QString name = {};
|
||||
if (reFileSystemType.hasMatch()) {
|
||||
name = reFileSystemType.captured(1);
|
||||
}
|
||||
|
@ -480,9 +496,6 @@ FileSystem::Type SfdiskBackend::detectFileSystem(const QString& partitionPath)
|
|||
version = reFileSystemVersion.captured(1);
|
||||
}
|
||||
rval = fileSystemNameToType(name, version);
|
||||
if (rval == FileSystem::Type::Unknown) {
|
||||
qWarning() << "unknown file system type " << name << " on " << partitionPath;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <QVariant>
|
||||
|
||||
class Device;
|
||||
class ExternalCommand;
|
||||
class Partition;
|
||||
class KPluginFactory;
|
||||
class QString;
|
||||
|
@ -53,6 +54,7 @@ private:
|
|||
bool updateDevicePartitionTable(Device& d, const QJsonObject& jsonPartitionTable);
|
||||
static PartitionTable::Flags availableFlags(PartitionTable::TableType type);
|
||||
static FileSystem::Type fileSystemNameToType(const QString& fileSystemName, const QString& version);
|
||||
static FileSystem::Type runDetectFileSystemCommand(ExternalCommand& command, QString& typeRegExp, QString& versionRegExp, QString& name);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue