tags:

views:

96

answers:

1

I need to be able to identify that a given file is an ODF file based on the contents of the file, and not on the file's extension.

ODF files are really a collection of XML files in a zip container, which means that I cannot use the file's magic number as it will just indicate that it is a zip file.

So what I'm really asking is are there any files that are required to be present in an ODF container? If so the presence of that file in a zip container indicates that it is likely to be an ODF file, and the absence of that file indicates that it definitely is not an ODF file.

+3  A: 

Why not check out the ODF Technical Specification? The mimetype file listed there would probably be an ideal way to check (just look for the vnd.oasis.opendocument string in the mimetype).

Amber
Is the mimetype file **required** to be in a valid ODF file?
jwaddell
Not in ODF1.0: 17.4 MIME Type Stream:If a MIME type for a document that makes use of packages is existing, then the packageSHOULD contain a stream called "mimetype".
Managu