From 4b6a1a260468728f545f67771da0d624bf3a8aad Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 19 Apr 2012 20:45:12 +0100 Subject: Change fz_document_open to assume PDF format by default. Previously, we would only open files with the correct extension. Until such time as we get file type detection by contents working assume that any file that doesn't end in .xps or .cbz is a pdf file. --- fitz/doc_document.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'fitz') diff --git a/fitz/doc_document.c b/fitz/doc_document.c index 095a7fb5..15ad4b62 100644 --- a/fitz/doc_document.c +++ b/fitz/doc_document.c @@ -27,14 +27,22 @@ fz_document * fz_open_document(fz_context *ctx, char *filename) { char *ext = strrchr(filename, '.'); - if (ext && !fz_strcasecmp(ext, ".pdf")) - return (fz_document*) pdf_open_document(ctx, filename); if (ext && !fz_strcasecmp(ext, ".xps")) return (fz_document*) xps_open_document(ctx, filename); if (ext && !fz_strcasecmp(ext, ".cbz")) return (fz_document*) cbz_open_document(ctx, filename); +#if 0 + /* We used to only open pdf files if they ended in .pdf. For now, + * until we move to detecting filetypes by their content, we disable + * this code, and assume that any file that hasn't matched an + * extension already, is a PDF. */ + if (ext && !fz_strcasecmp(ext, ".pdf")) + return (fz_document*) pdf_open_document(ctx, filename); fz_throw(ctx, "unknown document type: '%s'", filename); return NULL; +#else + return (fz_document*) pdf_open_document(ctx, filename); +#endif } void -- cgit v1.2.3