diff --git a/modules/juce_core/zip/juce_ZipFile.cpp b/modules/juce_core/zip/juce_ZipFile.cpp index 77b2e83001..87e461f14f 100644 --- a/modules/juce_core/zip/juce_ZipFile.cpp +++ b/modules/juce_core/zip/juce_ZipFile.cpp @@ -263,18 +263,23 @@ const ZipFile::ZipEntry* ZipFile::getEntry (const int index) const noexcept return nullptr; } -int ZipFile::getIndexOfFileName (const String& fileName) const noexcept +int ZipFile::getIndexOfFileName (const String& fileName, bool ignoreCase) const noexcept { for (int i = 0; i < entries.size(); ++i) - if (entries.getUnchecked (i)->entry.filename == fileName) + { + auto& entryFilename = entries.getUnchecked (i)->entry.filename; + + if (ignoreCase ? entryFilename.equalsIgnoreCase (fileName) + : entryFilename == fileName) return i; + } return -1; } -const ZipFile::ZipEntry* ZipFile::getEntry (const String& fileName) const noexcept +const ZipFile::ZipEntry* ZipFile::getEntry (const String& fileName, bool ignoreCase) const noexcept { - return getEntry (getIndexOfFileName (fileName)); + return getEntry (getIndexOfFileName (fileName, ignoreCase)); } InputStream* ZipFile::createStreamForEntry (const int index) diff --git a/modules/juce_core/zip/juce_ZipFile.h b/modules/juce_core/zip/juce_ZipFile.h index d8d95da567..ca83230577 100644 --- a/modules/juce_core/zip/juce_ZipFile.h +++ b/modules/juce_core/zip/juce_ZipFile.h @@ -95,7 +95,7 @@ public: @see ZipFile::ZipEntry */ - int getIndexOfFileName (const String& fileName) const noexcept; + int getIndexOfFileName (const String& fileName, bool ignoreCase = false) const noexcept; /** Returns a structure that describes one of the entries in the zip file. @@ -104,7 +104,7 @@ public: @see ZipFile::ZipEntry */ - const ZipEntry* getEntry (const String& fileName) const noexcept; + const ZipEntry* getEntry (const String& fileName, bool ignoreCase = false) const noexcept; /** Sorts the list of entries, based on the filename. */ void sortEntriesByFilename();