From 1864180ea75d4760f208c10eb9d15220f1a70878 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 28 Oct 2013 08:08:11 -0500 Subject: [PATCH] Teach Finder to find more than just the first matching element When the system class path contains more than one .jar, it is quite concievable that, say, 'META-INF/MANIFEST.MF' can be found in multiple class path elements. This commit teaches the working horse of class path inspection, the Finder class, how to continue the search at a given state. Signed-off-by: Johannes Schindelin --- src/avian/finder.h | 1 + src/finder.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/avian/finder.h b/src/avian/finder.h index cf92044b72..c7fdbd547b 100644 --- a/src/avian/finder.h +++ b/src/avian/finder.h @@ -168,6 +168,7 @@ class Finder { unsigned* length, bool tryDirectory = false) = 0; virtual const char* urlPrefix(const char* name) = 0; + virtual const char* nextUrlPrefix(const char* name, void *&finderElementPtr) = 0; virtual const char* sourceUrl(const char* name) = 0; virtual const char* path() = 0; virtual void dispose() = 0; diff --git a/src/finder.cpp b/src/finder.cpp index b170abc6e7..27969321ba 100644 --- a/src/finder.cpp +++ b/src/finder.cpp @@ -908,7 +908,16 @@ class MyFinder: public Finder { } virtual const char* urlPrefix(const char* name) { - for (Element* e = path_; e; e = e->next) { + void *finderElementPtr = NULL; + return nextUrlPrefix(name, finderElementPtr); + } + + virtual const char* nextUrlPrefix(const char* name, + void *&finderElementPtr) + { + Element *&e = reinterpret_cast(finderElementPtr); + e = e ? e->next : path_; + for (; e; e = e->next) { unsigned length; System::FileType type = e->stat(name, &length, true); if (type != System::TypeDoesNotExist) {