gzread()

Reads maximum "len" bytes from the file "path" into the variable "content".

Synopsis

int gzread(string path, string | blob &content, int len[, int offset]);

Parameters

Parameter Description
path Describes the file. If the file does not end with ".gz", The function adds ".gz" to the file name.
content The function reads the bytes from the file into the variable content. The variable has to be of type string or blob. Anytype and mixed are not allowed.
len The function reads maximum of len compressed bytes.
offset The function reads as of the position offset, the compressed data.

Return value

Number of bytes the function read.

0 if the function does not read any bytes,

-1 in case of an error.

Error

The function returns -1 in case of errors.

Description

Reads maximum "len"; bytes from the file "path"; into the variable "content";.

Example

The function gzwrite() compresses the content and writes the result into the file test2.txt. The function gzread() reads 30 bytes from the file test2.txt into the variable tar.

#uses "CtrlZlib"
main()
{
  string cont = "Hello this is the second test";
  string filPath = "c:/test2.txt";
  gzwrite(filPath, cont);
  DebugN("Compressed content", filPath);
  int retVal;
  string tar;
  int len = 30;
  retVal = gzread(filPath, tar, len);
  DebugN("Return value:", retVal, "Content", tar);
}

Assignment

File function

Availability

CTRL