FilePath: Return optional bytearray from device hooks

For differentiating between "error" and "empty file".

Change-Id: I1806bb7386f5e7db28489f9f7e685648bfc20110
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2022-09-09 14:25:36 +02:00
parent f5c22a42ae
commit e7ddd8a5b7
12 changed files with 67 additions and 35 deletions

View File

@@ -958,7 +958,9 @@ void DockerDevice::iterateDirectory(const FilePath &filePath,
FileUtils::iterateLsOutput(filePath, entries, filter, callBack);
}
QByteArray DockerDevice::fileContents(const FilePath &filePath, qint64 limit, qint64 offset) const
std::optional<QByteArray> DockerDevice::fileContents(const FilePath &filePath,
qint64 limit,
qint64 offset) const
{
QTC_ASSERT(handlesFile(filePath), return {});
updateContainerAccess();
@@ -976,6 +978,8 @@ QByteArray DockerDevice::fileContents(const FilePath &filePath, qint64 limit, qi
proc.start();
proc.waitForFinished();
if (proc.result() != ProcessResult::FinishedWithSuccess)
return {};
QByteArray output = proc.readAllStandardOutput();
return output;
}