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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2013-10-28 08:08:11 -05:00
parent 6c46fe3f1a
commit 1864180ea7
2 changed files with 11 additions and 1 deletions

View File

@ -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;

View File

@ -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<Element*&>(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) {