GZFile
GZFile
Properties
level
private int $level = -1
encoding
private int $encoding = 'FORCE_GZIP'
handle
private mixed $handle
Methods
__construct
public __construct(mixed $file, ?Manager $manager): void
Parameters
Parameter | Type | Description |
---|---|---|
$file | mixed | |
$manager | Manager |
setCompressionLevel
Sets the level of compression.
public setCompressionLevel(int $level): 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(): 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): bool
Parameters
Parameter | Type | Description |
---|---|---|
$encoding | int |
getEncoding
Returns the current gzencode encoding.
public getEncoding(): int
open
Open gz-file.
public open(string $mode = 'r'): mixed
Parameters
Parameter | Type | Description |
---|---|---|
$mode | string |
close
Close an open gz-file pointer.
public close(): bool
read
Binary-safe gz-file read.
public read(int $length): 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): 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(): string
gets
Returns a line from the file pointer.
public gets(?int $length): string
Parameters
Parameter | Type | Description |
---|---|---|
$length | int |
getss
Returns a line from the file pointer and strips HTML tags.
public getss(string $allowable_tags): string
Parameters
Parameter | Type | Description |
---|---|---|
$allowable_tags | string |
seek
Seeks to a position in the file.
public seek(int $offset, int $whence = 'SEEK_SET'): 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(): int
rewind
Rewind the position of a file pointer.
public rewind(): 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(): bool
get_contents
Returns the current contents of the file.
public get_contents(int $offset = -1, NULL $maxlen): void
Parameters
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): ?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 = false): ?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