summaryrefslogtreecommitdiff
path: root/ext/fileinfo/fileinfo.php
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/fileinfo/fileinfo.php
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/fileinfo/fileinfo.php')
-rw-r--r--ext/fileinfo/fileinfo.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/fileinfo/fileinfo.php b/ext/fileinfo/fileinfo.php
new file mode 100644
index 0000000..1ee9efb
--- /dev/null
+++ b/ext/fileinfo/fileinfo.php
@@ -0,0 +1,29 @@
+<?php
+if(!extension_loaded('fileinfo')) {
+ dl('fileinfo.' . PHP_SHLIB_SUFFIX);
+}
+if(!extension_loaded('fileinfo')) {
+ die("fileinfo extension is not avaliable, please compile it.\n");
+}
+
+// normal operation
+$res = finfo_open(FILEINFO_MIME); /* return mime type ala mimetype extension */
+$files = glob("*");
+foreach ($files as $file) {
+ echo finfo_file($res, $file) . "\n";
+}
+finfo_close($res);
+
+// OO mode
+/*
+ * FILEINFO_PRESERVE_ATIME - if possible preserve the original access time
+ * FILEINFO_SYMLINK - follow symlinks
+ * FILEINFO_DEVICES - look at the contents of blocks or character special devices
+ * FILEINFO_COMPRESS - decompress compressed files
+ */
+$fi = new finfo(FILEINFO_PRESERVE_ATIME|FILEINFO_SYMLINK|FILEINFO_DEVICES|FILEINFO_COMPRESS);
+$files = glob("*");
+foreach ($files as $file) {
+ echo $fi->buffer(file_get_contents($file)) . "\n";
+}
+?>