private static boolean filenameMatchesPrefixOrType(String fileName,
                                                     String prefix,
                                                     FileType[] suitableFileTypes,
                                                     int invocationCount) {
    boolean prefixMatched = prefix.length() == 0 || StringUtil.startsWithIgnoreCase(fileName, prefix);
    if (prefixMatched && (suitableFileTypes.length == 0 || invocationCount > 2)) return true;

    if (prefixMatched) {
      String extension = FileUtilRt.getExtension(fileName);
      if (extension.length() == 0) return false;

      for (FileType fileType : suitableFileTypes) {
        for (FileNameMatcher matcher : FileTypeManager.getInstance().getAssociations(fileType)) {
          if (matcher.acceptsCharSequence(fileName)) return true;
        }
      }
    }

    return false;
  }
private static boolean filenameMatchesPrefixOrType(String fileName,
                                                     String prefix,
                                                     FileType[] suitableFileTypes,
                                                     int invocationCount)