1
0
mirror of https://github.com/php/php-src.git synced 2026-04-13 02:52:48 +02:00
Files
archived-php-src/ext/fileinfo/fileinfo.php
Peter Kokot 02294f0c84 Make PHP development tools files and scripts executable
This patch makes several scripts and PHP development tools files
executable and adds more proper shebangs to the PHP scripts.

The `#!/usr/bin/env php` shebang provides running the script via
`./script.php` and uses env to find PHP script location on the system.
At the same time it still provides running the script with a user
defined PHP location using `php script.php`.
2018-08-29 20:58:17 +02:00

31 lines
884 B
PHP
Executable File

#!/usr/bin/env php
<?php
if(!extension_loaded('fileinfo')) {
dl('fileinfo.' . PHP_SHLIB_SUFFIX);
}
if(!extension_loaded('fileinfo')) {
die("fileinfo extension is not available, 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";
}
?>