forked from qt-creator/qt-creator
ProjectExplorer: Implement (Docker)Device::exists(filePath)
While the original plan was to use more specific functions like 'isReadableFile' to cut down the number of accesses, it is unrealistic to re-write all occurrences in reasonable time. So make the basic building blocks accessible, too. Change-Id: I2586ebd19e1e7ae2c884fd2a4180869421293e3a Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -688,6 +688,22 @@ bool DockerDevice::createDirectory(const FilePath &filePath) const
|
||||
return exitCode == 0;
|
||||
}
|
||||
|
||||
bool DockerDevice::exists(const FilePath &filePath) const
|
||||
{
|
||||
QTC_ASSERT(handlesFile(filePath), return false);
|
||||
tryCreateLocalFileAccess();
|
||||
if (hasLocalFileAccess()) {
|
||||
const FilePath localAccess = mapToLocalAccess(filePath);
|
||||
const bool res = localAccess.exists();
|
||||
LOG("Exists? " << filePath.toUserOutput() << localAccess.toUserOutput() << res);
|
||||
return res;
|
||||
}
|
||||
const QString path = filePath.path();
|
||||
const CommandLine cmd("test", {"-e", path});
|
||||
const int exitCode = d->runSynchronously(cmd);
|
||||
return exitCode == 0;
|
||||
}
|
||||
|
||||
QList<FilePath> DockerDevice::directoryEntries(const FilePath &filePath,
|
||||
const QStringList &nameFilters,
|
||||
QDir::Filters filters) const
|
||||
|
||||
Reference in New Issue
Block a user