From 9cc3fca7d020c300dd71817be9a629a4af106e6f Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 2 Jul 2020 17:25:03 +0100 Subject: [PATCH] RangedDirectoryIterator: Allow querying the estimated progress --- modules/juce_core/files/juce_RangedDirectoryIterator.cpp | 9 +++++++++ modules/juce_core/files/juce_RangedDirectoryIterator.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/modules/juce_core/files/juce_RangedDirectoryIterator.cpp b/modules/juce_core/files/juce_RangedDirectoryIterator.cpp index 7841dcdf8a..43eac299ab 100644 --- a/modules/juce_core/files/juce_RangedDirectoryIterator.cpp +++ b/modules/juce_core/files/juce_RangedDirectoryIterator.cpp @@ -23,6 +23,14 @@ namespace juce { +float DirectoryEntry::getEstimatedProgress() const +{ + if (auto it = iterator.lock()) + return it->getEstimatedProgress(); + + return 0.0f; +} + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996) @@ -37,6 +45,7 @@ RangedDirectoryIterator::RangedDirectoryIterator (const File& directory, wildCard, whatToLookFor)) { + entry.iterator = iterator; increment(); } diff --git a/modules/juce_core/files/juce_RangedDirectoryIterator.h b/modules/juce_core/files/juce_RangedDirectoryIterator.h index 1995181343..416217f7f6 100644 --- a/modules/juce_core/files/juce_RangedDirectoryIterator.h +++ b/modules/juce_core/files/juce_RangedDirectoryIterator.h @@ -53,7 +53,13 @@ public: /** True if the item is read-only, false otherwise. */ bool isReadOnly() const { return readOnly; } + /** The estimated proportion of the range that has been visited + by the iterator, from 0.0 to 1.0. + */ + float getEstimatedProgress() const; + private: + std::weak_ptr iterator; File file; Time modTime; Time creationTime;