File magic class proposal
| From: | Tomas V.V.Cox | Date: | Sat, 15 Sep 2001 11:00:18 +0000 |
| Subject: | File magic class proposal | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-1929@lists.php.net to get a copy of this message | ||
Hi guys,
I'm interesting in hear opinions about file-magic class handler for
Pear. What's that? It's a system for doing real detections of file
types, by reading its contents and comparing them with the "magic
numbers" listed in a special file called magic. You could get a better
idea calling the "file" command at a unix prompt and viewing the
contents of the "/usr/share/magic" file.
My idea is to provide two different methods for detecting file types:
1) Reading file contents (safe)
2) By file extension
and provide two different kinds of returned information:
1) Human redeable description (in several languages)
2) Mime type
To be a little standar I chose to use the gnome-vfs files for doing that
(http://cvs.gnome.org/lxr/source/gnome-vfs/data/mime/):
gnome-vfs-mime-magic (magic numbers)
gnome-vfs.mime (file name extensions)
gnome-vfs.keys.in (descriptions)
Utilities of that? For example, to autodetect mime types while creating
attachments, to restrict valid http file uploads by a browser supported
image format, to find what kind of file is stored in a DB blob, to
assign different applications to attachments in a web mail, etc.
Do you find it good? More ideas?
Tomas V.V.Cox