linuxdevice: Fix ::bytesAvailable

DeviceShell does not support piping commands at the moment.

To continue to support ::bytesAvailable the parsing of the
output from "df" is moved to FileUtils::bytesAvailableFromDFOutput.

Change-Id: Ia229208748aa6c572b99899e6ae042bdd5654f4a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-09-14 14:19:59 +02:00
parent 704fb9c0e6
commit ed46f1f002
4 changed files with 55 additions and 6 deletions

View File

@@ -1273,13 +1273,9 @@ qint64 LinuxDevice::bytesAvailable(const FilePath &filePath) const
QTC_ASSERT(handlesFile(filePath), return -1);
CommandLine cmd("df", {"-k"});
cmd.addArg(filePath.path());
cmd.addArgs("|tail -n 1 |sed 's/ */ /g'|cut -d ' ' -f 4", CommandLine::Raw);
const QByteArray output = d->outputForRunInShell(cmd);
bool ok = false;
const qint64 size = output.toLongLong(&ok);
if (ok)
return size * 1024;
return -1;
return FileUtils::bytesAvailableFromDFOutput(output);
}
QFileDevice::Permissions LinuxDevice::permissions(const FilePath &filePath) const