forked from qt-creator/qt-creator
Linuxdevice: Add FilePathInfo functions
::filePathInfo and iterateDirectory(..., IterateDirWithInfoCallback, ...) allow for faster info retrieval by the fsengine, making the listing of large directories like /bin a lot faster. Change-Id: I2a21e019e05f5bb08459483747ba2be4530929f4 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1288,7 +1288,7 @@ bool LinuxDevice::setPermissions(const FilePath &filePath, QFileDevice::Permissi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LinuxDevice::iterateDirectory(const FilePath &filePath,
|
void LinuxDevice::iterateDirectory(const FilePath &filePath,
|
||||||
const std::function<bool(const FilePath &)> &callBack,
|
const FilePath::IterateDirCallback &callBack,
|
||||||
const FileFilter &filter) const
|
const FileFilter &filter) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(handlesFile(filePath), return);
|
QTC_ASSERT(handlesFile(filePath), return);
|
||||||
@@ -1296,6 +1296,22 @@ void LinuxDevice::iterateDirectory(const FilePath &filePath,
|
|||||||
FileUtils::iterateUnixDirectory(filePath, filter, &d->m_useFind, runInShell, callBack);
|
FileUtils::iterateUnixDirectory(filePath, filter, &d->m_useFind, runInShell, callBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinuxDevice::iterateDirectory(const FilePath &filePath,
|
||||||
|
const FilePath::IterateDirWithInfoCallback &callBack,
|
||||||
|
const FileFilter &filter) const
|
||||||
|
{
|
||||||
|
QTC_ASSERT(handlesFile(filePath), return);
|
||||||
|
auto runInShell = [this](const CommandLine &cmd) { return d->runInShell(cmd); };
|
||||||
|
FileUtils::iterateUnixDirectory(filePath, filter, &d->m_useFind, runInShell, callBack);
|
||||||
|
}
|
||||||
|
|
||||||
|
FilePathInfo LinuxDevice::filePathInfo(const FilePath &filePath) const
|
||||||
|
{
|
||||||
|
QTC_ASSERT(handlesFile(filePath), return {});
|
||||||
|
const RunResult stat = d->runInShell({"stat", {"-L", "-c", "%f %Y %s", filePath.path()}});
|
||||||
|
return FileUtils::filePathInfoFromTriple(QString::fromLatin1(stat.stdOut));
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<QByteArray> LinuxDevice::fileContents(const FilePath &filePath,
|
std::optional<QByteArray> LinuxDevice::fileContents(const FilePath &filePath,
|
||||||
qint64 limit,
|
qint64 limit,
|
||||||
qint64 offset) const
|
qint64 offset) const
|
||||||
|
|||||||
@@ -53,7 +53,10 @@ public:
|
|||||||
bool renameFile(const Utils::FilePath &filePath, const Utils::FilePath &target) const override;
|
bool renameFile(const Utils::FilePath &filePath, const Utils::FilePath &target) const override;
|
||||||
Utils::FilePath symLinkTarget(const Utils::FilePath &filePath) const override;
|
Utils::FilePath symLinkTarget(const Utils::FilePath &filePath) const override;
|
||||||
void iterateDirectory(const Utils::FilePath &filePath,
|
void iterateDirectory(const Utils::FilePath &filePath,
|
||||||
const std::function<bool(const Utils::FilePath &)> &callBack,
|
const Utils::FilePath::IterateDirCallback &callBack,
|
||||||
|
const Utils::FileFilter &filter) const override;
|
||||||
|
void iterateDirectory(const Utils::FilePath &filePath,
|
||||||
|
const Utils::FilePath::IterateDirWithInfoCallback &callBack,
|
||||||
const Utils::FileFilter &filter) const override;
|
const Utils::FileFilter &filter) const override;
|
||||||
std::optional<QByteArray> fileContents(const Utils::FilePath &filePath,
|
std::optional<QByteArray> fileContents(const Utils::FilePath &filePath,
|
||||||
qint64 limit,
|
qint64 limit,
|
||||||
@@ -61,6 +64,7 @@ public:
|
|||||||
bool writeFileContents(const Utils::FilePath &filePath,
|
bool writeFileContents(const Utils::FilePath &filePath,
|
||||||
const QByteArray &data,
|
const QByteArray &data,
|
||||||
qint64 offset) const override;
|
qint64 offset) const override;
|
||||||
|
Utils::FilePathInfo filePathInfo(const Utils::FilePath &filePath) const override;
|
||||||
QDateTime lastModified(const Utils::FilePath &filePath) const override;
|
QDateTime lastModified(const Utils::FilePath &filePath) const override;
|
||||||
Utils::ProcessInterface *createProcessInterface() const override;
|
Utils::ProcessInterface *createProcessInterface() const override;
|
||||||
ProjectExplorer::FileTransferInterface *createFileTransferInterface(
|
ProjectExplorer::FileTransferInterface *createFileTransferInterface(
|
||||||
|
|||||||
Reference in New Issue
Block a user