Exceptions
5 days ago
apache.php
5 days ago
apcu.php
5 days ago
array.php
5 days ago
bzip2.php
5 days ago
calendar.php
5 days ago
classobj.php
5 days ago
com.php
5 days ago
cubrid.php
5 days ago
curl.php
5 days ago
datetime.php
5 days ago
dir.php
5 days ago
eio.php
5 days ago
errorfunc.php
5 days ago
exec.php
5 days ago
fileinfo.php
5 days ago
filesystem.php
5 days ago
filter.php
5 days ago
fpm.php
5 days ago
ftp.php
5 days ago
funchand.php
5 days ago
functionsList.php
5 days ago
gmp.php
5 days ago
gnupg.php
5 days ago
hash.php
5 days ago
ibase.php
5 days ago
ibmDb2.php
5 days ago
iconv.php
5 days ago
image.php
5 days ago
imap.php
5 days ago
info.php
5 days ago
ingres-ii.php
5 days ago
inotify.php
5 days ago
json.php
5 days ago
ldap.php
5 days ago
libxml.php
5 days ago
lzf.php
5 days ago
mailparse.php
5 days ago
mbstring.php
5 days ago
misc.php
5 days ago
msql.php
5 days ago
mysql.php
5 days ago
mysqli.php
5 days ago
mysqlndMs.php
5 days ago
mysqlndQc.php
5 days ago
network.php
5 days ago
oci8.php
5 days ago
opcache.php
5 days ago
openssl.php
5 days ago
outcontrol.php
5 days ago
password.php
5 days ago
pcntl.php
5 days ago
pcre.php
5 days ago
pdf.php
5 days ago
pgsql.php
5 days ago
posix.php
5 days ago
ps.php
5 days ago
pspell.php
5 days ago
readline.php
5 days ago
rpminfo.php
5 days ago
rrd.php
5 days ago
sem.php
5 days ago
session.php
5 days ago
shmop.php
5 days ago
simplexml.php
5 days ago
sockets.php
5 days ago
sodium.php
5 days ago
solr.php
5 days ago
spl.php
5 days ago
sqlsrv.php
5 days ago
ssdeep.php
5 days ago
ssh2.php
5 days ago
stream.php
5 days ago
strings.php
5 days ago
swoole.php
5 days ago
uodbc.php
5 days ago
uopz.php
5 days ago
url.php
5 days ago
var.php
5 days ago
xdiff.php
5 days ago
xml.php
5 days ago
xmlrpc.php
5 days ago
yaml.php
5 days ago
yaz.php
5 days ago
zip.php
5 days ago
zlib.php
5 days ago
fileinfo.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePressVendor\Safe; |
| 4 | |
| 5 | use ProfilePressVendor\Safe\Exceptions\FileinfoException; |
| 6 | /** |
| 7 | * This function closes the resource opened by finfo_open. |
| 8 | * |
| 9 | * @param resource $finfo Fileinfo resource returned by finfo_open. |
| 10 | * @throws FileinfoException |
| 11 | * |
| 12 | */ |
| 13 | function finfo_close($finfo): void |
| 14 | { |
| 15 | error_clear_last(); |
| 16 | $result = \finfo_close($finfo); |
| 17 | if ($result === \false) { |
| 18 | throw FileinfoException::createFromPhpError(); |
| 19 | } |
| 20 | } |
| 21 | /** |
| 22 | * Procedural style |
| 23 | * |
| 24 | * Object oriented style (constructor): |
| 25 | * |
| 26 | * This function opens a magic database and returns its resource. |
| 27 | * |
| 28 | * @param int $options One or disjunction of more Fileinfo |
| 29 | * constants. |
| 30 | * @param string $magic_file Name of a magic database file, usually something like |
| 31 | * /path/to/magic.mime. If not specified, the |
| 32 | * MAGIC environment variable is used. If the |
| 33 | * environment variable isn't set, then PHP's bundled magic database will |
| 34 | * be used. |
| 35 | * |
| 36 | * Passing NULL or an empty string will be equivalent to the default |
| 37 | * value. |
| 38 | * @return resource (Procedural style only) |
| 39 | * Returns a magic database resource on success. |
| 40 | * @throws FileinfoException |
| 41 | * |
| 42 | */ |
| 43 | function finfo_open(int $options = \FILEINFO_NONE, string $magic_file = "") |
| 44 | { |
| 45 | error_clear_last(); |
| 46 | $result = \finfo_open($options, $magic_file); |
| 47 | if ($result === \false) { |
| 48 | throw FileinfoException::createFromPhpError(); |
| 49 | } |
| 50 | return $result; |
| 51 | } |
| 52 | /** |
| 53 | * Returns the MIME content type for a file as determined by using |
| 54 | * information from the magic.mime file. |
| 55 | * |
| 56 | * @param string $filename Path to the tested file. |
| 57 | * @return string Returns the content type in MIME format, like |
| 58 | * text/plain or application/octet-stream. |
| 59 | * @throws FileinfoException |
| 60 | * |
| 61 | */ |
| 62 | function mime_content_type(string $filename): string |
| 63 | { |
| 64 | error_clear_last(); |
| 65 | $result = \mime_content_type($filename); |
| 66 | if ($result === \false) { |
| 67 | throw FileinfoException::createFromPhpError(); |
| 68 | } |
| 69 | return $result; |
| 70 | } |
| 71 |