forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user