//----------------------------------------------------------------------- FileInfoListPtr ZipArchive::findFileInfo(const String& pattern, bool recursive) { FileInfoListPtr ret = FileInfoListPtr(new FileInfoList()); FileInfoList::iterator i, iend; iend = mFileList.end(); for (i = mFileList.begin(); i != iend; ++i) { if (recursive || i->path.empty()) { // Check name matches pattern (zip is case insensitive) if (StringUtil::match(i->basename, pattern, false)) { ret->push_back(*i); } } else { // Check full name if (StringUtil::match(i->filename, pattern, false)) { ret->push_back(*i); } } } return ret; }
//----------------------------------------------------------------------- FileInfoListPtr ZipArchive::listFileInfo(bool recursive, bool dirs) const { OGRE_LOCK_AUTO_MUTEX; FileInfoList* fil = OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(); FileInfoList::const_iterator i, iend; iend = mFileList.end(); for (i = mFileList.begin(); i != iend; ++i) if ((dirs == (i->compressedSize == size_t (-1))) && (recursive || i->path.empty())) fil->push_back(*i); return FileInfoListPtr(fil, SPFM_DELETE_T); }
//----------------------------------------------------------------------- FileInfoListPtr ZipArchive::listFileInfo(bool recursive) { FileInfoList* fil = new FileInfoList(); FileInfoList::const_iterator i, iend; iend = mFileList.end(); for (i = mFileList.begin(); i != iend; ++i) { if (recursive || i->path.empty()) { fil->push_back(*i); } } return FileInfoListPtr(fil); }
//----------------------------------------------------------------------- FileInfoListPtr ZipArchive::findFileInfo(const String& pattern, bool recursive, bool dirs) const { OGRE_LOCK_AUTO_MUTEX; FileInfoListPtr ret = FileInfoListPtr(OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T); // If pattern contains a directory name, do a full match bool full_match = (pattern.find ('/') != String::npos) || (pattern.find ('\\') != String::npos); bool wildCard = pattern.find("*") != String::npos; FileInfoList::const_iterator i, iend; iend = mFileList.end(); for (i = mFileList.begin(); i != iend; ++i) if ((dirs == (i->compressedSize == size_t (-1))) && (recursive || full_match || wildCard)) // Check name matches pattern (zip is case insensitive) if (StringUtil::match(full_match ? i->filename : i->basename, pattern, false)) ret->push_back(*i); return ret; }