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
bzip2.php
90 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePressVendor\Safe; |
| 4 | |
| 5 | use ProfilePressVendor\Safe\Exceptions\Bzip2Exception; |
| 6 | /** |
| 7 | * Closes the given bzip2 file pointer. |
| 8 | * |
| 9 | * @param resource $bz The file pointer. It must be valid and must point to a file |
| 10 | * successfully opened by bzopen. |
| 11 | * @throws Bzip2Exception |
| 12 | * |
| 13 | */ |
| 14 | function bzclose($bz): void |
| 15 | { |
| 16 | error_clear_last(); |
| 17 | $result = \bzclose($bz); |
| 18 | if ($result === \false) { |
| 19 | throw Bzip2Exception::createFromPhpError(); |
| 20 | } |
| 21 | } |
| 22 | /** |
| 23 | * Forces a write of all buffered bzip2 data for the file pointer |
| 24 | * bz. |
| 25 | * |
| 26 | * @param resource $bz The file pointer. It must be valid and must point to a file |
| 27 | * successfully opened by bzopen. |
| 28 | * @throws Bzip2Exception |
| 29 | * |
| 30 | */ |
| 31 | function bzflush($bz): void |
| 32 | { |
| 33 | error_clear_last(); |
| 34 | $result = \bzflush($bz); |
| 35 | if ($result === \false) { |
| 36 | throw Bzip2Exception::createFromPhpError(); |
| 37 | } |
| 38 | } |
| 39 | /** |
| 40 | * bzread reads from the given bzip2 file pointer. |
| 41 | * |
| 42 | * Reading stops when length (uncompressed) bytes have |
| 43 | * been read or EOF is reached, whichever comes first. |
| 44 | * |
| 45 | * @param resource $bz The file pointer. It must be valid and must point to a file |
| 46 | * successfully opened by bzopen. |
| 47 | * @param int $length If not specified, bzread will read 1024 |
| 48 | * (uncompressed) bytes at a time. A maximum of 8192 |
| 49 | * uncompressed bytes will be read at a time. |
| 50 | * @return string Returns the uncompressed data. |
| 51 | * @throws Bzip2Exception |
| 52 | * |
| 53 | */ |
| 54 | function bzread($bz, int $length = 1024): string |
| 55 | { |
| 56 | error_clear_last(); |
| 57 | $result = \bzread($bz, $length); |
| 58 | if ($result === \false) { |
| 59 | throw Bzip2Exception::createFromPhpError(); |
| 60 | } |
| 61 | return $result; |
| 62 | } |
| 63 | /** |
| 64 | * bzwrite writes a string into the given bzip2 file |
| 65 | * stream. |
| 66 | * |
| 67 | * @param resource $bz The file pointer. It must be valid and must point to a file |
| 68 | * successfully opened by bzopen. |
| 69 | * @param string $data The written data. |
| 70 | * @param int $length If supplied, writing will stop after length |
| 71 | * (uncompressed) bytes have been written or the end of |
| 72 | * data is reached, whichever comes first. |
| 73 | * @return int Returns the number of bytes written. |
| 74 | * @throws Bzip2Exception |
| 75 | * |
| 76 | */ |
| 77 | function bzwrite($bz, string $data, int $length = null): int |
| 78 | { |
| 79 | error_clear_last(); |
| 80 | if ($length !== null) { |
| 81 | $result = \bzwrite($bz, $data, $length); |
| 82 | } else { |
| 83 | $result = \bzwrite($bz, $data); |
| 84 | } |
| 85 | if ($result === \false) { |
| 86 | throw Bzip2Exception::createFromPhpError(); |
| 87 | } |
| 88 | return $result; |
| 89 | } |
| 90 |