private static string DetectConverterFromArchiveEntries(IEnumerable entries, string outerPath) { var exts = new HashSet(StringComparer.OrdinalIgnoreCase); bool hasTopLevelDocKml = false; foreach (var e in entries ?? Enumerable.Empty()) { if (string.IsNullOrWhiteSpace(e)) continue; var ext = Path.GetExtension(e); if (!string.IsNullOrEmpty(ext)) exts.Add(ext.ToLowerInvariant()); // top-level doc.kml heuristic (KMZ convention) var normalized = e.Replace('\\', '/').Trim('/'); if (normalized.Equals("doc.kml", StringComparison.OrdinalIgnoreCase)) hasTopLevelDocKml = true; // detect .gdb folder markers foreach (var seg in normalized.Split('/')) if (seg.EndsWith(".gdb", StringComparison.OrdinalIgnoreCase)) exts.Add(".gdb"); } // KMZ guard: prefer real KMZ if (Path.GetExtension(outerPath).Equals(".kmz", StringComparison.OrdinalIgnoreCase) || hasTopLevelDocKml) { Log.Debug("KMZ guard passed (outer .kmz or top-level doc.kml)."); return "Kmz"; } // strict requirement match foreach (var kv in _s_archiveRequirements) if (kv.Value.All(exts.Contains)) return kv.Key; Log.Debug("No archive-based converter match found."); return null;