pike.git / src / modules / Gz / module.pmod.in

version» Context lines:

pike.git/src/modules/Gz/module.pmod.in:1: - // $Id: module.pmod.in,v 1.6 2002/11/25 11:51:51 grubba Exp $ + // $Id: module.pmod.in,v 1.7 2002/11/25 14:52:40 grubba Exp $   #pike __REAL_VERSION__      inherit @module@;      #if constant(@module@._file)      //! Allows the user to open a Gzip archive and read and write   //! it's contents in an uncompressed form, emulating the @[Stdio.File]   //! interface.   //! @note
pike.git/src/modules/Gz/module.pmod.in:83:    open_mode = lower_case(mode);    }       is_open = ::open(file, open_mode);    return is_open;    }       //! Reads data from the file.    //! If no argument is given, the whole file is read.    int|string read(void|int length) { -  string ret = ""; -  +     if (!is_open) {    return 0;    }       if (!zero_type(length))    return ::read(length); -  else -  while(!eof()) { -  ret += ::read(1024*64); +  +  String.Buffer buf = String.Buffer(); +  do { +  string data; +  +  if (!(data = ::read(1024*64))) break; +  buf->add(data); +  } while (sizeof(data)); +  return (string)buf;    } -  return ret; +    } - } +       #endif /* constant(@module@._file) */