]> granicus.if.org Git - php/commitdiff
Depercating mime_magic in favor of PECL::fileinfo
authorHartmut Holzgraefe <hholzgra@php.net>
Thu, 22 Apr 2004 01:24:12 +0000 (01:24 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Thu, 22 Apr 2004 01:24:12 +0000 (01:24 +0000)
ext/mime_magic/DEPRECATED [new file with mode: 0644]
ext/mime_magic/EXPERIMENTAL
ext/mime_magic/config.m4

diff --git a/ext/mime_magic/DEPRECATED b/ext/mime_magic/DEPRECATED
new file mode 100644 (file)
index 0000000..d4d42e6
--- /dev/null
@@ -0,0 +1,36 @@
+This extension is deprecated, please use the fileinfo extension
+from PECL instead.
+
+Back when i implemented mime_magic there was no library interface
+to the file utilities functionality. The only way to get the 
+functionality in place was to get the file sources and replace
+the input and output routines within with code interfacing to
+your own stuff. This work was originally done by the developers
+of apache mod_magic, the mime_magic extension just replaced the
+apache specific parts with their PHP counterparts.
+
+Now that the codebase of the file utilities is cleanly devided 
+into the libmagic library and the file utility built upon it
+the original hack is no longer needed. Using libmagic and the
+fileinfo extension does not only provide a cleaner interface
+to files functionality but also additional functionality so 
+that theres no reason to keep around mime_magic anymore.
+
+To keep existing code originaly coded for mime_magic without
+changes you may add the following compatibility wrapper function
+to your codebase:
+
+function mime_content_type($file) {
+    static $finfo = false;
+
+    if ($finfo === false) {
+        $finfo = finfo_open(MAGIC_MIME);
+    }
+
+       if (is_resource($file)) {
+               $buf = fread($fp, 65536);
+               return finfo_buffer($buf);
+    } else {
+           return finfo_file($file);
+    }
+}
\ No newline at end of file
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..add2b3b7e6d41d780987a4deeb8c6dc60e1d07bd 100644 (file)
@@ -0,0 +1,2 @@
+this extension never left the "experimental" status
+and is now superseded by PECL::fileinfo
index 1682399501ac44f04236a6c58aabbedb8e368572..0e53bc5d56a72bea96a5f52f37ac27c16d4f4744 100644 (file)
@@ -4,8 +4,7 @@ dnl
 
 PHP_ARG_WITH(mime-magic, whether to include mime_magic support,
 [  --with-mime-magic[=FILE]  
-                          Include mime_magic support. FILE is the optional
-                          pathname to the magic.mime file.])
+                          Include mime_magic support (deprecated)])
 
 if test "$PHP_MIME_MAGIC" != "no"; then