FSNode *FSDirectory::lookupCache(NodeCache &cache, const String &name) const { // make caching as lazy as possible if (!name.empty()) { ensureCached(); if (cache.contains(name)) return &cache[name]; } return 0; }
int FSDirectory::listMembers(ArchiveMemberList &list) const { if (!_node.isDirectory()) return 0; // Cache dir data ensureCached(); int files = 0; for (NodeCache::const_iterator it = _fileCache.begin(); it != _fileCache.end(); ++it) { list.push_back(ArchiveMemberPtr(new FSNode(it->_value))); ++files; } return files; }
int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) { if (!_node.isDirectory()) return 0; // Cache dir data ensureCached(); String lowercasePattern(pattern); lowercasePattern.toLowercase(); int matches = 0; NodeCache::iterator it = _fileCache.begin(); for ( ; it != _fileCache.end(); ++it) { if (it->_key.matchString(lowercasePattern, true)) { list.push_back(ArchiveMemberPtr(new FSNode(it->_value))); matches++; } } return matches; }
int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const { if (!_node.isDirectory()) return 0; // Cache dir data ensureCached(); // need to match lowercase key, since all entries in our file cache are // stored as lowercase. String lowercasePattern(pattern); lowercasePattern.toLowercase(); int matches = 0; NodeCache::const_iterator it = _fileCache.begin(); for ( ; it != _fileCache.end(); ++it) { if (it->_key.matchString(lowercasePattern, false, true)) { list.push_back(ArchiveMemberPtr(new FSNode(it->_value))); matches++; } } return matches; }