forked from qt-creator/qt-creator
ProjectExplorer: Funnel environment fetching through device access
Easier nowadays. It's synchronous now, so conceptually worse, but 'env' is not worse than 'ls', and this is used regularly all over the place also for larger data sets without being a problem. Change-Id: I2c2b1db8c07ff5c128700d4a1deefd710967568a Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -179,6 +179,12 @@ void DeviceFileAccess::iterateDirectory(const FilePath &filePath,
|
||||
QTC_CHECK(false);
|
||||
}
|
||||
|
||||
Environment DeviceFileAccess::deviceEnvironment() const
|
||||
{
|
||||
QTC_CHECK(false);
|
||||
return {};
|
||||
}
|
||||
|
||||
expected_str<QByteArray> DeviceFileAccess::fileContents(const FilePath &filePath,
|
||||
qint64 limit,
|
||||
qint64 offset) const
|
||||
@@ -534,6 +540,11 @@ void DesktopDeviceFileAccess::iterateDirectory(const FilePath &filePath,
|
||||
}
|
||||
}
|
||||
|
||||
Environment DesktopDeviceFileAccess::deviceEnvironment() const
|
||||
{
|
||||
return Environment::systemEnvironment();
|
||||
}
|
||||
|
||||
expected_str<QByteArray> DesktopDeviceFileAccess::fileContents(const FilePath &filePath,
|
||||
qint64 limit,
|
||||
qint64 offset) const
|
||||
@@ -1077,4 +1088,11 @@ void UnixDeviceFileAccess::iterateDirectory(const FilePath &filePath,
|
||||
iterateLsOutput(filePath, entries, filter, callBack);
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
Environment UnixDeviceFileAccess::deviceEnvironment() const
|
||||
{
|
||||
const RunResult result = runInShell({"env", {}, OsType::OsTypeLinux});
|
||||
const QString out = QString::fromUtf8(result.stdOut);
|
||||
return Environment(out.split('\n', Qt::SkipEmptyParts), OsTypeLinux);
|
||||
}
|
||||
|
||||
} // Utils
|
||||
|
||||
Reference in New Issue
Block a user