Use trimmed() instead of simplified().

This commit is contained in:
Andrius Štikonas 2016-05-05 12:46:27 +01:00
parent 27af037bb4
commit 0bd44b94dc
4 changed files with 5 additions and 11 deletions

View File

@ -66,7 +66,7 @@ static qint32 getPhysicalSectorSize(const QString& device_node)
if (f.open(QIODevice::ReadOnly)) { if (f.open(QIODevice::ReadOnly)) {
QByteArray a = f.readLine(); QByteArray a = f.readLine();
return a.simplified().toInt(); return a.trimmed().toInt();
} }
return -1; return -1;

View File

@ -510,7 +510,7 @@ QString luks::readUUID(const QString& deviceNode) const
ExternalCommand cmd(QStringLiteral("cryptsetup"), ExternalCommand cmd(QStringLiteral("cryptsetup"),
{ QStringLiteral("luksUUID"), deviceNode }); { QStringLiteral("luksUUID"), deviceNode });
if (cmd.run()) { if (cmd.run()) {
return cmd.output().simplified(); return cmd.output().trimmed();
} }
return QStringLiteral("---"); return QStringLiteral("---");
} }

View File

@ -123,19 +123,13 @@ qint64 ntfs::readUsedCapacity(const QString& deviceNode) const
bool ntfs::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) bool ntfs::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
{ {
ExternalCommand writeCmd(report, QStringLiteral("ntfslabel"), { QStringLiteral("--force"), deviceNode, newLabel.simplified() }); ExternalCommand writeCmd(report, QStringLiteral("ntfslabel"), { QStringLiteral("--force"), deviceNode, newLabel });
writeCmd.setProcessChannelMode(QProcess::SeparateChannels); writeCmd.setProcessChannelMode(QProcess::SeparateChannels);
if (!writeCmd.run(-1)) if (!writeCmd.run(-1))
return false; return false;
ExternalCommand testCmd(QStringLiteral("ntfslabel"), { QStringLiteral("--force"), deviceNode }); return true;
testCmd.setProcessChannelMode(QProcess::SeparateChannels);
if (!testCmd.run(-1))
return false;
return testCmd.output().simplified() == newLabel.simplified();
} }
bool ntfs::check(Report& report, const QString& deviceNode) const bool ntfs::check(Report& report, const QString& deviceNode) const

View File

@ -79,7 +79,7 @@ bool isMounted(const QString& deviceNode)
deviceNode }); deviceNode });
if (cmd.run(-1) && cmd.exitCode() == 0) { if (cmd.run(-1) && cmd.exitCode() == 0) {
return !cmd.output().simplified().isEmpty(); return !cmd.output().trimmed().isEmpty();
} }
return false; return false;
} }