/* Check if given extension exists in a list of extensions.  */
bool isExtensionMatching(const char *extension, const char *pattern, char *match)
/* Check if given extension exists in a list of extensions.  */
bool isExtensionMatching(const char *extension, const char *pattern, char *match)
{
  const char *ext;
  uint8_t extlen, fnlen;
  int plen;
  ext = getFileExtension(pattern, 0, 0, &fnlen, &extlen);
  plen = (int)fnlen;
  while (plen > 0 && ext) {
    if (!strncasecmp(extension, ext, extlen)) {
      if (match != nullptr) strncat(&(match[0]='\0'), ext, extlen);
      return true;
    }
    plen -= extlen;
    if (plen > 0) {
      ext = getFileExtension(pattern, plen, 0, nullptr, &extlen);
    }
  }
  return false;
}