Port away from QRegExp to QRegularExpression.
This commit is contained in:
parent
29c6578351
commit
bb2de6cd56
|
@ -27,9 +27,10 @@
|
|||
#include "util/externalcommand.h"
|
||||
#include "util/report.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <KIOCore/KMountPoint>
|
||||
|
@ -214,7 +215,7 @@ void Partition::adjustLogicalNumbers(qint32 deletedNumber, qint32 insertedNumber
|
|||
|
||||
foreach(Partition * p, children()) {
|
||||
QString path = p->partitionPath();
|
||||
path.remove(QRegExp(QStringLiteral("([0-9]+$)")));
|
||||
path.remove(QRegularExpression(QStringLiteral("(\\d+$)")));
|
||||
if (deletedNumber > 4 && p->number() > deletedNumber)
|
||||
p->setPartitionPath(path + QString::number(p->number() - 1));
|
||||
else if (insertedNumber > 4 && p->number() >= insertedNumber)
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include "util/capacity.h"
|
||||
#include "util/report.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QRegExp>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
@ -109,11 +109,12 @@ qint64 btrfs::readUsedCapacity(const QString& deviceNode) const
|
|||
ExternalCommand cmd(QStringLiteral("btrfs"),
|
||||
{ QStringLiteral("filesystem"), QStringLiteral("show"), QStringLiteral("--raw"), deviceNode });
|
||||
|
||||
if (cmd.run()) {
|
||||
QRegExp rxBytesUsed(QStringLiteral(" used (\\d+) path ") + deviceNode);
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral(" used (\\d+) path ") + deviceNode);
|
||||
QRegularExpressionMatch reBytesUsed = re.match(cmd.output());
|
||||
|
||||
if (rxBytesUsed.indexIn(cmd.output()) != -1)
|
||||
return rxBytesUsed.cap(1).toLongLong();
|
||||
if (reBytesUsed.hasMatch())
|
||||
return reBytesUsed.captured(1).toLongLong();
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "util/capacity.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QRegExp>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "util/externalcommand.h"
|
||||
#include "util/capacity.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QRegExp>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
|
@ -98,22 +98,25 @@ qint64 ext2::readUsedCapacity(const QString& deviceNode) const
|
|||
|
||||
if (cmd.run()) {
|
||||
qint64 blockCount = -1;
|
||||
QRegExp rxBlockCount(QStringLiteral("Block count:\\s*(\\d+)"));
|
||||
QRegularExpression re(QStringLiteral("Block count:\\s+(\\w+)"));
|
||||
QRegularExpressionMatch reBlockCount = re.match(cmd.output());
|
||||
|
||||
if (rxBlockCount.indexIn(cmd.output()) != -1)
|
||||
blockCount = rxBlockCount.cap(1).toLongLong();
|
||||
if (reBlockCount.hasMatch())
|
||||
blockCount = reBlockCount.captured(1).toLongLong();
|
||||
|
||||
qint64 freeBlocks = -1;
|
||||
QRegExp rxFreeBlocks(QStringLiteral("Free blocks:\\s*(\\d+)"));
|
||||
re.setPattern(QStringLiteral("Free blocks:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reFreeBlocks = re.match(cmd.output());
|
||||
|
||||
if (rxFreeBlocks.indexIn(cmd.output()) != -1)
|
||||
freeBlocks = rxFreeBlocks.cap(1).toLongLong();
|
||||
if (reFreeBlocks.hasMatch())
|
||||
freeBlocks = reFreeBlocks.captured(1).toLongLong();
|
||||
|
||||
qint64 blockSize = -1;
|
||||
QRegExp rxBlockSize(QStringLiteral("Block size:\\s*(\\d+)"));
|
||||
re.setPattern(QStringLiteral("Block size:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reBlockSize = re.match(cmd.output());
|
||||
|
||||
if (rxBlockSize.indexIn(cmd.output()) != -1)
|
||||
blockSize = rxBlockSize.cap(1).toLongLong();
|
||||
if (reBlockSize.hasMatch())
|
||||
blockSize = reBlockSize.captured(1).toLongLong();
|
||||
|
||||
if (blockCount > -1 && freeBlocks > -1 && blockSize > -1)
|
||||
return (blockCount - freeBlocks) * blockSize;
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
|
@ -106,19 +106,21 @@ qint64 fat16::readUsedCapacity(const QString& deviceNode) const
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("fsck.msdos"), { QStringLiteral("-n"), QStringLiteral("-v"), deviceNode });
|
||||
|
||||
if (cmd.run()) {
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
qint64 usedClusters = -1;
|
||||
QRegExp rxClusters(QStringLiteral("files, (\\d+)/\\d+ "));
|
||||
QRegularExpression re(QStringLiteral("files, (\\d+)/\\d+ "));
|
||||
QRegularExpressionMatch reClusters = re.match(cmd.output());
|
||||
|
||||
if (rxClusters.indexIn(cmd.output()) != -1)
|
||||
usedClusters = rxClusters.cap(1).toLongLong();
|
||||
if (reClusters.hasMatch())
|
||||
usedClusters = reClusters.captured(1).toLongLong();
|
||||
|
||||
qint64 clusterSize = -1;
|
||||
|
||||
QRegExp rxClusterSize(QStringLiteral("(\\d+) bytes per cluster"));
|
||||
re.setPattern(QStringLiteral("(\\d+) bytes per cluster"));
|
||||
QRegularExpressionMatch reClusterSize = re.match(cmd.output());
|
||||
|
||||
if (rxClusterSize.indexIn(cmd.output()) != -1)
|
||||
clusterSize = rxClusterSize.cap(1).toLongLong();
|
||||
if (reClusterSize.hasMatch())
|
||||
clusterSize = reClusterSize.captured(1).toLongLong();
|
||||
|
||||
if (usedClusters > -1 && clusterSize > -1)
|
||||
return usedClusters * clusterSize;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "util/capacity.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "util/report.h"
|
||||
#include "util/capacity.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
@ -100,26 +100,29 @@ qint64 jfs::readUsedCapacity(const QString& deviceNode) const
|
|||
|
||||
if (cmd.start() && cmd.write("dm") == 2 && cmd.waitFor()) {
|
||||
qint64 blockSize = -1;
|
||||
QRegExp rxBlockSize(QStringLiteral("Block Size: (\\d+)"));
|
||||
QRegularExpression re(QStringLiteral("Block Size: (\\d+)"));
|
||||
QRegularExpressionMatch reBlockSize = re.match(cmd.output());
|
||||
|
||||
if (rxBlockSize.indexIn(cmd.output()) != -1)
|
||||
blockSize = rxBlockSize.cap(1).toLongLong();
|
||||
if (reBlockSize.hasMatch())
|
||||
blockSize = reBlockSize.captured(1).toLongLong();
|
||||
|
||||
qint64 nBlocks = -1;
|
||||
QRegExp rxnBlocks(QStringLiteral("dn_mapsize:\\s+0x([0-9a-f]+)"));
|
||||
re.setPattern(QStringLiteral("dn_mapsize:\\s+0x(\\x+)"));
|
||||
QRegularExpressionMatch renBlocks = re.match(cmd.output());
|
||||
|
||||
bool ok = false;
|
||||
if (rxnBlocks.indexIn(cmd.output()) != -1) {
|
||||
nBlocks = rxnBlocks.cap(1).toLongLong(&ok, 16);
|
||||
if (renBlocks.hasMatch()) {
|
||||
nBlocks = renBlocks.captured(1).toLongLong(&ok, 16);
|
||||
if (!ok)
|
||||
nBlocks = -1;
|
||||
}
|
||||
|
||||
qint64 nFree = -1;
|
||||
QRegExp rxnFree(QStringLiteral("dn_nfree:\\s+0x([0-9a-f]+)"));
|
||||
re.setPattern(QStringLiteral("dn_nfree:\\s+0x(\\x+)"));
|
||||
QRegularExpressionMatch renFree = re.match(cmd.output());
|
||||
|
||||
if (rxnFree.indexIn(cmd.output()) != -1) {
|
||||
nFree = rxnFree.cap(1).toLongLong(&ok, 16);
|
||||
if (renFree.hasMatch()) {
|
||||
nFree = renFree.captured(1).toLongLong(&ok, 16);
|
||||
if (!ok)
|
||||
nFree = -1;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <QDebug>
|
||||
#include <QDialog>
|
||||
#include <QPointer>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
|
||||
|
@ -499,7 +500,7 @@ bool luks::resize(Report& report, const QString& deviceNode, qint64 newLength) c
|
|||
else if (m_innerFs->resize(report, mapperNode, payloadLength))
|
||||
{
|
||||
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("--size"), QString::number(payloadLength / m_logicalSectorSize), QStringLiteral("resize"), mapperNode });
|
||||
report.line() << xi18nc("@info/plain", "Resizing encrypted file system on partition <filename>%1</filename>.", deviceNode);
|
||||
report.line() << xi18nc("@info/plain", "Resize encrypted file system on partition <filename>%1</filename>.", deviceNode);
|
||||
if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)
|
||||
{
|
||||
return true;
|
||||
|
@ -559,10 +560,11 @@ QString luks::getCipherName(const QString& deviceNode)
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxCipherName(QStringLiteral("(?:Cipher name:\\s+)([A-Za-z0-9-]+)"));
|
||||
if (rxCipherName.indexIn(cmd.output()) > -1)
|
||||
return rxCipherName.cap(1);
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("Cipher name:\\s+(\\w+)"));
|
||||
QRegularExpressionMatch reCipherName = re.match(cmd.output());
|
||||
if (reCipherName.hasMatch())
|
||||
return reCipherName.captured(1);
|
||||
}
|
||||
return QStringLiteral("---");
|
||||
}
|
||||
|
@ -571,10 +573,11 @@ QString luks::getCipherMode(const QString& deviceNode)
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxCipherMode(QStringLiteral("(?:Cipher mode:\\s+)([A-Za-z0-9-]+)"));
|
||||
if (rxCipherMode.indexIn(cmd.output()) > -1)
|
||||
return rxCipherMode.cap(1);
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("Cipher mode:\\s+(\\w+)"));
|
||||
QRegularExpressionMatch reCipherMode = re.match(cmd.output());
|
||||
if (reCipherMode.hasMatch())
|
||||
return reCipherMode.captured(1);
|
||||
}
|
||||
return QStringLiteral("---");
|
||||
}
|
||||
|
@ -583,10 +586,11 @@ QString luks::getHashName(const QString& deviceNode)
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxHash(QStringLiteral("(?:Hash spec:\\s+)([A-Za-z0-9-]+)"));
|
||||
if (rxHash.indexIn(cmd.output()) > -1)
|
||||
return rxHash.cap(1);
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("Hash spec:\\s+(\\w+)"));
|
||||
QRegularExpressionMatch reHash = re.match(cmd.output());
|
||||
if (reHash.hasMatch())
|
||||
return reHash.captured(1);
|
||||
}
|
||||
return QStringLiteral("---");
|
||||
}
|
||||
|
@ -595,10 +599,11 @@ QString luks::getKeySize(const QString& deviceNode)
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxKeySize(QStringLiteral("(?:MK bits:\\s+)(\\d+)"));
|
||||
if (rxKeySize.indexIn(cmd.output()) > -1)
|
||||
return rxKeySize.cap(1);
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("MK bits:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reKeySize = re.match(cmd.output());
|
||||
if (reKeySize.hasMatch())
|
||||
return reKeySize.captured(1);
|
||||
}
|
||||
return QStringLiteral("---");
|
||||
}
|
||||
|
@ -607,10 +612,11 @@ QString luks::getPayloadOffset(const QString& deviceNode)
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxPayloadOffset(QStringLiteral("(?:Payload offset:\\s+)(\\d+)"));
|
||||
if (rxPayloadOffset.indexIn(cmd.output()) > -1)
|
||||
return rxPayloadOffset.cap(1);
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("Payload offset:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch rePayloadOffset = re.match(cmd.output());
|
||||
if (rePayloadOffset.hasMatch())
|
||||
return rePayloadOffset.captured(1);
|
||||
}
|
||||
return QStringLiteral("---");
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QTemporaryDir>
|
||||
#include <QUuid>
|
||||
|
@ -124,12 +125,15 @@ qint64 nilfs2::readUsedCapacity(const QString& deviceNode) const
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("nilfs-tune"), { QStringLiteral("-l"), deviceNode });
|
||||
|
||||
if (cmd.run()) {
|
||||
QRegExp rxBlockSize(QStringLiteral("(?:Block size:\\s+)(\\d+)"));
|
||||
QRegExp rxDeviceSize(QStringLiteral("(?:Device size:\\s+)(\\d+)"));
|
||||
QRegExp rxFreeBlocks(QStringLiteral("(?:Free blocks count:\\s+)(\\d+)"));
|
||||
if (rxBlockSize.indexIn(cmd.output()) != -1 && rxDeviceSize.indexIn(cmd.output()) != -1 && rxFreeBlocks.indexIn(cmd.output()) != -1)
|
||||
return rxDeviceSize.cap(1).toLongLong() - rxBlockSize.cap(1).toLongLong() * rxFreeBlocks.cap(1).toLongLong();
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("Block size:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reBlockSize = re.match(cmd.output());
|
||||
re.setPattern(QStringLiteral("Device size:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reDeviceSize = re.match(cmd.output());
|
||||
re.setPattern(QStringLiteral("Free blocks count:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reFreeBlocks = re.match(cmd.output());
|
||||
if (reBlockSize.hasMatch() && reDeviceSize.hasMatch() && reFreeBlocks.hasMatch())
|
||||
return reDeviceSize.captured(1).toLongLong() - reBlockSize.captured(1).toLongLong() * reFreeBlocks.captured(1).toLongLong();
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
|
@ -25,13 +25,14 @@
|
|||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QFile>
|
||||
#include <QUuid>
|
||||
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
|
@ -107,12 +108,13 @@ qint64 ntfs::readUsedCapacity(const QString& deviceNode) const
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("ntfsresize"), { QStringLiteral("--info"), QStringLiteral("--force"), QStringLiteral("--no-progress-bar"), deviceNode });
|
||||
|
||||
if (cmd.run()) {
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
qint64 usedBytes = -1;
|
||||
QRegExp rxUsedBytes(QStringLiteral("resize at (\\d+) bytes"));
|
||||
QRegularExpression re(QStringLiteral("resize at (\\d+) bytes"));
|
||||
QRegularExpressionMatch reUsedBytes = re.match(cmd.output());
|
||||
|
||||
if (rxUsedBytes.indexIn(cmd.output()) != -1)
|
||||
usedBytes = rxUsedBytes.cap(1).toLongLong();
|
||||
if (reUsedBytes.hasMatch())
|
||||
usedBytes = reUsedBytes.captured(1).toLongLong();
|
||||
|
||||
if (usedBytes > -1)
|
||||
return usedBytes;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "util/externalcommand.h"
|
||||
#include "util/capacity.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QRegExp>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
|
@ -129,11 +129,12 @@ bool ocfs2::resize(Report& report, const QString& deviceNode, qint64 length) con
|
|||
ExternalCommand cmdBlockSize(QStringLiteral("debugfs.ocfs2"), { QStringLiteral("--request"), QStringLiteral("stats"), deviceNode });
|
||||
|
||||
qint32 blockSize = -1;
|
||||
if (cmdBlockSize.run()) {
|
||||
QRegExp rxBlockSizeBits(QStringLiteral("Block Size Bits: (\\d+)"));
|
||||
if (cmdBlockSize.run(-1) && cmdBlockSize.exitCode() == 0) {
|
||||
QRegularExpression re(QStringLiteral("Block Size Bits: (\\d+)"));
|
||||
QRegularExpressionMatch reBlockSizeBits = re.match(cmdBlockSize.output());
|
||||
|
||||
if (rxBlockSizeBits.indexIn(cmdBlockSize.output()) != -1)
|
||||
blockSize = 1 << rxBlockSizeBits.cap(1).toInt();
|
||||
if (reBlockSizeBits.hasMatch())
|
||||
blockSize = 1 << reBlockSizeBits.captured(1).toInt();
|
||||
}
|
||||
|
||||
if (blockSize == -1)
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "util/capacity.h"
|
||||
#include "util/externalcommand.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
|
@ -87,24 +87,27 @@ qint64 reiser4::readUsedCapacity(const QString& deviceNode) const
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("debugfs.reiser4"), { deviceNode });
|
||||
|
||||
if (cmd.run()) {
|
||||
if (cmd.run(-1) && cmd.exitCode() == 16) {
|
||||
qint64 blocks = -1;
|
||||
QRegExp rxBlocks(QStringLiteral("blocks:\\s+(\\d+)"));
|
||||
QRegularExpression re(QStringLiteral("blocks:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reBlocks = re.match(cmd.output());
|
||||
|
||||
if (rxBlocks.indexIn(cmd.output()) != -1)
|
||||
blocks = rxBlocks.cap(1).toLongLong();
|
||||
if (reBlocks.hasMatch())
|
||||
blocks = reBlocks.captured(1).toLongLong();
|
||||
|
||||
qint64 blockSize = -1;
|
||||
QRegExp rxBlockSize(QStringLiteral("blksize:\\s+(\\d+)"));
|
||||
re.setPattern(QStringLiteral("blksize:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reBlockSize = re.match(cmd.output());
|
||||
|
||||
if (rxBlockSize.indexIn(cmd.output()) != -1)
|
||||
blockSize = rxBlockSize.cap(1).toLongLong();
|
||||
if (reBlockSize.hasMatch())
|
||||
blockSize = reBlockSize.captured(1).toLongLong();
|
||||
|
||||
qint64 freeBlocks = -1;
|
||||
QRegExp rxFreeBlocks(QStringLiteral("free blocks:\\s+(\\d+)"));
|
||||
re.setPattern(QStringLiteral("free blocks:\\s+(\\d+)"));
|
||||
QRegularExpressionMatch reFreeBlocks = re.match(cmd.output());
|
||||
|
||||
if (rxFreeBlocks.indexIn(cmd.output()) != -1)
|
||||
freeBlocks = rxFreeBlocks.cap(1).toLongLong();
|
||||
if (reFreeBlocks.hasMatch())
|
||||
freeBlocks = reFreeBlocks.captured(1).toLongLong();
|
||||
|
||||
if (blocks > - 1 && blockSize > -1 && freeBlocks > -1)
|
||||
return (blocks - freeBlocks) * blockSize;
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include "util/externalcommand.h"
|
||||
#include "util/capacity.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
#include <QUuid>
|
||||
|
||||
namespace FS
|
||||
|
@ -102,24 +102,27 @@ qint64 reiserfs::readUsedCapacity(const QString& deviceNode) const
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("debugreiserfs"), { deviceNode });
|
||||
|
||||
if (cmd.run()) {
|
||||
if (cmd.run(-1) && cmd.exitCode() == 16) {
|
||||
qint64 blockCount = -1;
|
||||
QRegExp rxBlockCount(QStringLiteral("Count of blocks[^:]+: (\\d+)"));
|
||||
QRegularExpression re(QStringLiteral("Count of blocks[^:]+: (\\d+)"));
|
||||
QRegularExpressionMatch reBlockCount = re.match(cmd.output());
|
||||
|
||||
if (rxBlockCount.indexIn(cmd.output()) != -1)
|
||||
blockCount = rxBlockCount.cap(1).toLongLong();
|
||||
if (reBlockCount.hasMatch())
|
||||
blockCount = reBlockCount.captured(1).toLongLong();
|
||||
|
||||
qint64 blockSize = -1;
|
||||
QRegExp rxBlockSize(QStringLiteral("Blocksize: (\\d+)"));
|
||||
re.setPattern(QStringLiteral("Blocksize: (\\d+)"));
|
||||
QRegularExpressionMatch reBlockSize = re.match(cmd.output());
|
||||
|
||||
if (rxBlockSize.indexIn(cmd.output()) != -1)
|
||||
blockSize = rxBlockSize.cap(1).toLongLong();
|
||||
if (reBlockSize.hasMatch())
|
||||
blockSize = reBlockSize.captured(1).toLongLong();
|
||||
|
||||
qint64 freeBlocks = -1;
|
||||
QRegExp rxFreeBlocks(QStringLiteral("Free blocks[^:]+: (\\d+)"));
|
||||
re.setPattern(QStringLiteral("Free blocks[^:]+: (\\d+)"));
|
||||
QRegularExpressionMatch reFreeBlocks = re.match(cmd.output());
|
||||
|
||||
if (rxFreeBlocks.indexIn(cmd.output()) != -1)
|
||||
freeBlocks = rxFreeBlocks.cap(1).toLongLong();
|
||||
if (reFreeBlocks.hasMatch())
|
||||
freeBlocks = reFreeBlocks.captured(1).toLongLong();
|
||||
|
||||
if (blockCount > -1 && blockSize > -1 && freeBlocks > -1)
|
||||
return (blockCount - freeBlocks) * blockSize;
|
||||
|
@ -166,7 +169,7 @@ bool reiserfs::resize(Report& report, const QString& deviceNode, qint64 length)
|
|||
|
||||
bool reiserfs::updateUUID(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
const QString uuid = QUuid::createUuid().toString().remove(QRegExp(QStringLiteral("\\{|\\}")));
|
||||
const QString uuid = QUuid::createUuid().toString().remove(QRegularExpression(QStringLiteral("\\{|\\}")));
|
||||
ExternalCommand cmd(report, QStringLiteral("reiserfstune"), { QStringLiteral("--uuid"), uuid, deviceNode });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#include "util/capacity.h"
|
||||
#include "util/report.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
@ -102,24 +102,27 @@ qint64 xfs::readUsedCapacity(const QString& deviceNode) const
|
|||
{
|
||||
ExternalCommand cmd(QStringLiteral("xfs_db"), { QStringLiteral("-c"), QStringLiteral("sb 0"), QStringLiteral("-c"), QStringLiteral("print"), deviceNode });
|
||||
|
||||
if (cmd.run()) {
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
qint64 dBlocks = -1;
|
||||
QRegExp rxDBlocks(QStringLiteral("dblocks = (\\d+)"));
|
||||
QRegularExpression re(QStringLiteral("dblocks = (\\d+)"));
|
||||
QRegularExpressionMatch reDBlocks = re.match(cmd.output());
|
||||
|
||||
if (rxDBlocks.indexIn(cmd.output()) != -1)
|
||||
dBlocks = rxDBlocks.cap(1).toLongLong();
|
||||
if (reDBlocks.hasMatch())
|
||||
dBlocks = reDBlocks.captured(1).toLongLong();
|
||||
|
||||
qint64 blockSize = -1;
|
||||
QRegExp rxBlockSize(QStringLiteral("blocksize = (\\d+)"));
|
||||
re.setPattern(QStringLiteral("blocksize = (\\d+)"));
|
||||
QRegularExpressionMatch reBlockSize = re.match(cmd.output());
|
||||
|
||||
if (rxBlockSize.indexIn(cmd.output()) != -1)
|
||||
blockSize = rxBlockSize.cap(1).toLongLong();
|
||||
if (reBlockSize.hasMatch())
|
||||
blockSize = reBlockSize.captured(1).toLongLong();
|
||||
|
||||
qint64 fdBlocks = -1;
|
||||
QRegExp rxFdBlocks(QStringLiteral("fdblocks = (\\d+)"));
|
||||
re.setPattern(QStringLiteral("fdblocks = (\\d+)"));
|
||||
QRegularExpressionMatch reFdBlocks = re.match(cmd.output());
|
||||
|
||||
if (rxFdBlocks.indexIn(cmd.output()) != -1)
|
||||
fdBlocks = rxFdBlocks.cap(1).toLongLong();
|
||||
if (reFdBlocks.hasMatch())
|
||||
fdBlocks = reFdBlocks.captured(1).toLongLong();
|
||||
|
||||
if (dBlocks > -1 && blockSize > -1 && fdBlocks > -1)
|
||||
return (dBlocks - fdBlocks) * blockSize;
|
||||
|
|
Loading…
Reference in New Issue