mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
Added an option to ignore the case when getting an entry inside a zip file with ZipFile::getEntry
This commit is contained in:
parent
cfdd849b66
commit
842634cd80
2 changed files with 11 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue