parent
31921c59fa
commit
a5bdd5a4eb
|
@ -47,7 +47,8 @@ ntfs::ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr
|
||||||
|
|
||||||
void ntfs::init()
|
void ntfs::init()
|
||||||
{
|
{
|
||||||
m_Shrink = m_Grow = m_Check = m_GetUsed = findExternal(QStringLiteral("ntfsresize")) ? cmdSupportFileSystem : cmdSupportNone;
|
m_Shrink = m_Grow = m_Check = findExternal(QStringLiteral("ntfsresize")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||||
|
m_GetUsed = findExternal(QStringLiteral("ntfsinfo")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||||
m_GetLabel = cmdSupportCore;
|
m_GetLabel = cmdSupportCore;
|
||||||
m_SetLabel = findExternal(QStringLiteral("ntfslabel")) ? cmdSupportFileSystem : cmdSupportNone;
|
m_SetLabel = findExternal(QStringLiteral("ntfslabel")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||||
m_Create = findExternal(QStringLiteral("mkfs.ntfs")) ? cmdSupportFileSystem : cmdSupportNone;
|
m_Create = findExternal(QStringLiteral("mkfs.ntfs")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||||
|
@ -97,18 +98,27 @@ int ntfs::maxLabelLength() const
|
||||||
|
|
||||||
qint64 ntfs::readUsedCapacity(const QString& deviceNode) const
|
qint64 ntfs::readUsedCapacity(const QString& deviceNode) const
|
||||||
{
|
{
|
||||||
ExternalCommand cmd(QStringLiteral("ntfsresize"), { QStringLiteral("--info"), QStringLiteral("--force"), QStringLiteral("--no-progress-bar"), deviceNode });
|
ExternalCommand cmd(QStringLiteral("ntfsinfo"), { QStringLiteral("--mft"), QStringLiteral("--force"), deviceNode });
|
||||||
|
|
||||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||||
|
QRegularExpression re(QStringLiteral("Cluster Size: (\\d+)"));
|
||||||
|
QRegularExpressionMatch reClusterSize = re.match(cmd.output());
|
||||||
|
qint64 clusterSize = reClusterSize.hasMatch() ? reClusterSize.captured(1).toLongLong() : -1;
|
||||||
|
|
||||||
|
QRegularExpression re2(QStringLiteral("Free Clusters: (\\d+)"));
|
||||||
|
QRegularExpressionMatch reFreeClusters = re2.match(cmd.output());
|
||||||
|
qint64 freeClusters = reFreeClusters.hasMatch() ? reFreeClusters.captured(1).toLongLong() : -1;
|
||||||
|
|
||||||
|
QRegularExpression re3(QStringLiteral("Volume Size in Clusters: (\\d+)"));
|
||||||
|
QRegularExpressionMatch reVolumeSize = re3.match(cmd.output());
|
||||||
|
qint64 volumeSize = reVolumeSize.hasMatch() ? reVolumeSize.captured(1).toLongLong() : -1;
|
||||||
|
|
||||||
qint64 usedBytes = -1;
|
qint64 usedBytes = -1;
|
||||||
QRegularExpression re(QStringLiteral("resize at (\\d+) bytes"));
|
qDebug () << volumeSize << freeClusters << clusterSize;
|
||||||
QRegularExpressionMatch reUsedBytes = re.match(cmd.output());
|
if (clusterSize > -1 && freeClusters > -1 && volumeSize > -1) {
|
||||||
|
usedBytes = (volumeSize - freeClusters) * clusterSize;
|
||||||
if (reUsedBytes.hasMatch())
|
}
|
||||||
usedBytes = reUsedBytes.captured(1).toLongLong();
|
return usedBytes;
|
||||||
|
|
||||||
if (usedBytes > -1)
|
|
||||||
return usedBytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -74,6 +74,7 @@ QStringLiteral("nilfs-resize"),
|
||||||
QStringLiteral("ntfsresize"),
|
QStringLiteral("ntfsresize"),
|
||||||
QStringLiteral("mkfs.ntfs"),
|
QStringLiteral("mkfs.ntfs"),
|
||||||
QStringLiteral("ntfsclone"),
|
QStringLiteral("ntfsclone"),
|
||||||
|
QStringLiteral("ntfsinfo"),
|
||||||
QStringLiteral("ntfslabel"),
|
QStringLiteral("ntfslabel"),
|
||||||
QStringLiteral("fsck.ocfs2"),
|
QStringLiteral("fsck.ocfs2"),
|
||||||
QStringLiteral("mkfs.ocfs2"),
|
QStringLiteral("mkfs.ocfs2"),
|
||||||
|
|
Loading…
Reference in New Issue