GZFile
GZFile
Represent g z file.
class GZFile extends \Hazaar\FileExtends: Hazaar\File
Properties
level
Store the level.
private int $level = -1Type: int
encoding
Store the encoding.
private int $encoding = 'FORCE_GZIP'Type: int
handle
private mixed $handleType: mixed
Methods
__construct
Create a new instance.
public __construct(mixed $file, ?Manager $manager): voidParameters
| Parameter | Type | Description |
|---|---|---|
$file | mixed | |
$manager | Hazaar\File\Manager |
setCompressionLevel
Sets the level of compression.
public setCompressionLevel(int $level): voidReturns: void
Can be given as 0 for no compression up to 9 for maximum compression.
If -1 is used, the default compression of the zlib library is used which is 6.
Parameters
| Parameter | Type | Description |
|---|---|---|
$level | int |
getCompressionLevel
Returns the current compression level setting.
public getCompressionLevel(): intReturns: int
Can be a value of 0 for no compression up to 9 for maximum compression.
If the value is -1, the default compression of the zlib library is being used, which is 6.
setEncoding
Set the current encoding for compress.
public setEncoding(int $encoding): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$encoding | int |
getEncoding
Returns the current gzencode encoding.
public getEncoding(): intReturns: int
open
Open gz-file.
public open(string $mode = 'r'): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$mode | string |
close
Close an open gz-file pointer.
public close(): boolReturns: bool
read
Binary-safe gz-file read.
public read(int $length): false|stringReturns: false|string
File::read() reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met:
- length bytes have been read
- EOF (end of file) is reached
- a packet becomes available or the socket timeout occurs (for network streams)
- if the stream is read buffered and it does not represent a plain file, at most one read of up to a number of bytes equal to the chunk size (usually 8192) is made; depending on the previously buffered data, the size of the returned data may be larger than the chunk size.
Parameters
| Parameter | Type | Description |
|---|---|---|
$length | int | up to length number of bytes read |
write
Binary-safe gz-file write.
public write(string $string, ?int $length): false|intReturns: false|int
File::write() writes the contents of string to the file stream pointed to by handle.
Parameters
| Parameter | Type | Description |
|---|---|---|
$string | string | the string that is to be written |
$length | int | If the length argument is given, writing will stop after length bytes have been written or the end of string is reached, whichever comes first. Note that if the length argument is given, then the magic_quotes_runtime configuration option will be ignored and no slashes will be stripped from string. |
getc
Returns a character from the file pointer.
public getc(): false|stringReturns: false|string
gets
Returns a line from the file pointer.
public gets(?int $length): false|stringReturns: false|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$length | int |
getss
Returns a line from the file pointer and strips HTML tags.
public getss(array|string|null $allowableTags): false|stringReturns: false|string
Parameters
| Parameter | Type | Description |
|---|---|---|
$allowableTags | array | string |
seek
Seeks to a position in the file.
public seek(int $offset, int $whence = 'SEEK_SET'): intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | int | The offset. To move to a position before the end-of-file, you need to pass a negative value in offset and set whence to SEEK_END. |
$whence | int | whence values are: SEEK_SET - Set position equal to offset bytes. SEEK_CUR - Set position to current location plus offset. SEEK_END - Set position to end-of-file plus offset. |
tell
Returns the current position of the file read/write pointer.
public tell(): false|intReturns: false|int
rewind
Rewind the position of a file pointer.
public rewind(): boolReturns: bool
Sets the file position indicator for handle to the beginning of the file stream.
eof
Tests for end-of-file on a file pointer.
public eof(): boolReturns: bool
get_contents
Returns the current contents of the file.
public get_contents(int $offset = -1, null $maxlen): voidParameters
| Parameter | Type | Description |
|---|---|---|
$offset | int | |
$maxlen | null |
putContents
Put contents directly writes data to the storage manager without storing it in the file object itself.
public putContents(string $data, bool $overwrite = true): ?intReturns: int
NOTE: This function is called internally to save data that has been updated in the file object.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | string | |
$overwrite | bool |
saveAs
Saves this file objects content to another file name.
public saveAs(string $filename, bool $overwrite): ?intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$filename | string | The filename to save as |
$overwrite | bool | Boolean flag to indicate that the destination should be overwritten if it exists |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000