- // libmagic does not distinguish eps and ps.
- // Therefore we need to use our own detection here, but only if it
- // recognizes either ps or eps. Otherwise the libmagic guess will
- // be better (bug 9146).
- string const format = guessFormatFromContents(filename);
- if (!psformat.empty()) {
- if (isPostScriptFileFormat(format))
+ string const ext = getExtension(filename.absFileName());
+ if (format.empty()) {
+ // libmagic does not distinguish eps and ps.
+ // Therefore we need to use our own detection here, but only if it
+ // recognizes either ps or eps. Otherwise the libmagic guess will
+ // be better (bug 9146).
+ format = guessFormatFromContents(filename);
+ if (!psformat.empty()) {
+ if (isPostScriptFileFormat(format))
+ return format;
+ else
+ return psformat;
+ }
+
+ if (isZippedFileFormat(format) && !ext.empty()) {
+ string const & fmt_name = formats.getFormatFromExtension(ext);
+ if (!fmt_name.empty()) {
+ Format const * p_format = formats.getFormat(fmt_name);
+ if (p_format && p_format->zippedNative())
+ return p_format->name();
+ }
+ }
+ // Don't simply return latex (bug 9244).
+ if (!format.empty() && format != "latex")