Branch: Tag:

2002-11-25

2002-11-25 14:52:40 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Now supports zlib's which lack the eof() function.

Rev: src/modules/Gz/module.pmod.in:1.7

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@;
90:    //! 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) */