Reads entire file into a string

@param int     $offset The offset where the reading starts on the original stream.
@param int     $maxlen Maximum length of data read
348689
public function fileGetContents($offset = -1, $maxlen = null)
	{
		return is_int($maxlen) ? file_get_contents(
			$this->_fhandle,
			$this->use_include_path,
			null,
			$offset,
			$maxlen
		) : file_get_contents(
			$this->_fhandle,
			$this->use_include_path,
			null,
			$offset
		);
	}
688249
public function decode(string $input, int $maxSize) { /* : ?array */
        $headers = [];
        $off = 0;
        $inputLength = \strlen($input);
        $size = 0;

        // dynamic $table as per 2.3.2
        while ($off < $inputLength) {
            $index = \ord($input[$off++]);

            if ($index & 0x80) {
                // range check
                if ($index <= self::LAST_INDEX + 0x80) {
                    if ($index === 0x80) {
                        return null;
                    }

                    list($name, $value) = $headers[] = self::TABLE[$index - 0x81];
                } else {
                    if ($index == 0xff) {
                        $index = self::decodeDynamicInteger($input, $off) + 0xff;
                    }

                    $index -= 0x81 + self::LAST_INDEX;
                    if (!isset($this->headers[$index])) {
                        return null;
                    }

                    list($name, $value) = $headers[] = $this->headers[$index];
                }
            } elseif (($index & 0x60) !== 0x20) { // (($index & 0x40) || !($index & 0x20)): bit 4: never index is ignored
                $dynamic = (bool) ($index & 0x40);

                if ($index & ($dynamic ? 0x3f : 0x0f)) { // separate length
                    if ($dynamic) {
                        if ($index === 0x7f) {
                            $index = self::decodeDynamicInteger($input, $off) + 0x3f;
                        } else {
                            $index &= 0x3f;
                        }
                    } else {
                        $index &= 0x0f;
                        if ($index === 0x0f) {
                            $index = self::decodeDynamicInteger($input, $off) + 0x0f;
                        }
                    }

                    if ($index <= self::LAST_INDEX) {
                        $header = self::TABLE[$index - 1];
                    } else {
                        $header = $this->headers[$index - 1 - self::LAST_INDEX];
                    }
                } else {
                    $len = \ord($input[$off++]);
                    $huffman = $len & 0x80;
                    $len &= 0x7f;

                    if ($len === 0x7f) {
                        $len = self::decodeDynamicInteger($input, $off) + 0x7f;
                    }

                    if ($inputLength - $off < $len || $len <= 0) {
                        return null;
                    }

                    if ($huffman) {
                        $header = [self::huffmanDecode(\substr($input, $off, $len))];
                    } else {
                        $header = [\substr($input, $off, $len)];
                    }

                    $off += $len;
                }

                if ($off === $inputLength) {
                    return null;
                }

                $len = \ord($input[$off++]);
                $huffman = $len & 0x80;
                $len &= 0x7f;

                if ($len === 0x7f) {
                    $len = self::decodeDynamicInteger($input, $off) + 0x7f;
                }

                if ($inputLength - $off < $len || $len < 0) {
                    return null;
                }

                if ($huffman) {
                    $header[1] = self::huffmanDecode(\substr($input, $off, $len));
                } else {
                    $header[1] = \substr($input, $off, $len);
                }

                $off += $len;

                if ($dynamic) {
                    \array_unshift($this->headers, $header);
                    $this->size += 32 + \strlen($header[0]) + \strlen($header[1]);
                    if ($this->maxSize < $this->size) {
                        $this->resizeTable();
                    }
                }

                list($name, $value) = $headers[] = $header;
            } else { // if ($index & 0x20) {
                if ($index === 0x3f) {
                    $index = self::decodeDynamicInteger($input, $off) + 0x40;
                }

                if ($index > 4096) { // initial limit … may be adjusted??
                    return null;
                }

                $name = $value = '';
                $this->resizeTable($index);
            }

            $size += \strlen($name) + \strlen($value);

            if ($size > $maxSize) {
                return null;
            }
        }

        return $headers;
    }
802679
public static function load( $fileName, $offset = NULL, $limit = NULL )
	{
		$file	= new FS_File_Reader( $fileName );
		$lines	= $file->readArray();
		if( $offset !== NULL && $limit !== NULL && (int) $limit !==  0 )
			$lines	= array_slice( $lines, abs( (int) $offset ), (int) $limit );
		else if( $offset !== NULL && (int) $offset !== 0 )
			$lines	= array_slice( $lines, (int) $offset );
		return $lines;
	}
1302854
function setMaxFileSize($bytes = 0)
    {
        if ($bytes > 0) {
            $this->_maxFileSize = $bytes;
        }
        if (!$this->elementExists('MAX_FILE_SIZE')) {
            $this->addElement('hidden', 'MAX_FILE_SIZE', $this->_maxFileSize);
        } else {
            $el =& $this->getElement('MAX_FILE_SIZE');
            $el->updateAttributes(array('value' => $this->_maxFileSize));
        }
    }
1325608
private function max($value, $max)
    {
        if (is_string($value)) {
            $value = strlen($value);
        }

        return $value <= $max;
    }
175513
private void setString(int offset, int maxLength, String theString) {
        byte[] stringBytes = theString.getBytes(StandardCharsets.ISO_8859_1);
        int length = Math.min(stringBytes.length, maxLength);
        System.arraycopy(stringBytes, 0, buffer, offset, length);
        buffer[offset + length] = 0;
    }
263493
public function read($offset, $length = 1)
    {
        $ret = '';
        $segno = floor($offset / $this->segsize);
        $sOffset = $offset % $this->segsize;
        while (true) {
            if (!isset($this->segments[$segno])) {
                if (!$this->open($segno)) {
                    goto ret;
                }
            }

            $ret .= shmop_read($this->segments[$segno], $sOffset, min($length - mb_orig_strlen($ret), $this->segsize));

            if (mb_orig_strlen($ret) >= $length) {
                goto ret;
            }

            ++$segno;

            $sOffset = 0;
        }
        ret:

        return $ret === '' ? false : $ret;
    }
874973
public function read($n, $offset = 0)
    {
        if ($this->length < $offset + $n) {
            throw new BufferUnderflowException();

        } elseif ($offset === 0 && $this->length === $offset + $n) {
            return $this->buffer;

        } else {
            return substr($this->buffer, $offset, $n);
        }
    }
629336
public static function length($val, $minLen = 0, $maxLen = null): bool
    {
        if (!\is_string($val) && !\is_array($val)) {
            return false;
        }

        return self::size($val, $minLen, $maxLen);
    }
972033
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->initialize();
            $this->setInitialized(true);
        }

        // note, if buffer contains fewer lines than
        // $this->_lines this code will not work.

        if ($this->linesRead < $this->lines) {
            $buffer = $this->in->read($len);

            if ($buffer === -1) {
                return -1;
            }

            // now grab first X lines from buffer

            $lines = explode("\n", $buffer);

            $linesCount = count($lines);

            // must account for possibility that the num lines requested could
            // involve more than one buffer read.
            $len = ($linesCount > $this->lines ? $this->lines - $this->linesRead : $linesCount);
            $filtered_buffer = implode("\n", array_slice($lines, $this->skip, $len));
            $this->linesRead += $len;

            return $filtered_buffer;
        }

        return -1; // EOF, since the file is "finished" as far as subsequent filters are concerned.
    }
787290
public static function readfile($full, $fsencoding = '') {
        $full = self::conv_to($full, $fsencoding);
        $mime_type = self::get_mime($full);
        if ($mime_type !== null) {
            header('Content-Type: ' . $mime_type);
            readfile($full);
        }
    }
821946
public function read($n)
    {
        if ($this->offset >= strlen($this->buffer)) {
            if (!($rv = $this->populateBuffer())) {
                return $rv;
            }
        }
        return $this->readBuffer($n);
    }
1023251
protected static function _gzdecode($gzdata, $maxlen = null)
    {
        #-- decode header
        $len = strlen($gzdata);
        if ($len < 20) {
            return;
        }
        $head                                   = substr($gzdata, 0, 10);
        $head                                   = unpack('n1id/C1cm/C1flg/V1mtime/C1xfl/C1os', $head);
        list($ID, $CM, $FLG, $MTIME, $XFL, $OS) = array_values($head);
        $FTEXT                                  = 1 << 0;
        $FHCRC                                  = 1 << 1;
        $FEXTRA                                 = 1 << 2;
        $FNAME                                  = 1 << 3;
        $FCOMMENT                               = 1 << 4;
        $head                                   = unpack('V1crc/V1isize', substr($gzdata, $len - 8, 8));
        list($CRC32, $ISIZE)                    = array_values($head);

        #-- check gzip stream identifier
        if (0x1f8b != $ID) {
            trigger_error('gzdecode: not in gzip format', E_USER_WARNING);
            return;
        }
        #-- check for deflate algorithm
        if (8 != $CM) {
            trigger_error('gzdecode: cannot decode anything but deflated streams', E_USER_WARNING);
            return;
        }
        #-- start of data, skip bonus fields
        $s = 10;
        if ($FLG & $FEXTRA) {
            $s += $XFL;
        }
        if ($FLG & $FNAME) {
            $s = strpos($gzdata, "\000", $s) + 1;
        }
        if ($FLG & $FCOMMENT) {
            $s = strpos($gzdata, "\000", $s) + 1;
        }
        if ($FLG & $FHCRC) {
            $s += 2; // cannot check
        }

        #-- get data, uncompress
        $gzdata = substr($gzdata, $s, $len - $s);
        if ($maxlen) {
            $gzdata = gzinflate($gzdata, $maxlen);
            return ($gzdata); // no checks(?!)
        } else {
            $gzdata = gzinflate($gzdata);
        }

        #-- check+fin
        $chk = crc32($gzdata);
        if ($CRC32 != $chk) {
            trigger_error("gzdecode: checksum failed (real$chk != comp$CRC32)", E_USER_WARNING);
        } elseif (strlen($gzdata) != $ISIZE) {
            trigger_error('gzdecode: stream size mismatch', E_USER_WARNING);
        } else {
            return ($gzdata);
        }
    }
458179
public int read(long fileOffset, byte []buffer, int offset, int length)
    throws IOException
  {
    _file.seek(fileOffset);
    
    return _file.read(buffer, offset, length);
  }
464788
public function read(int $offset, int $length) {
        if ($this->swoole_buffer) {
            return $this->swoole_buffer->read($offset, $length);
        }
        return false;
    }
365289
public static function truncate(string $s, int $maxLen, string $append = "\xE2\x80\xA6"): string
    {
        if (\mb_strlen($s) > $maxLen) {
            $maxLen -= \mb_strlen($append);
            if ($maxLen < 1) {
                return $append;
            }

            if ($matches = static::match($s, '#^.{1,' . $maxLen . '}(?=[\s\x00-/:-@\[-`{-~])#us')) {
                return $matches[0] . $append;
            }

            return \mb_substr($s, 0, $maxLen) . $append;
        }

        return $s;
    }
408319
public function eatCSpan($mask, $maxLength = null)
    {
        if (null === $maxLength) {
            $maxLength = $this->getRemainingByteCount();
        }

        return $this->read(strcspn($this->data, $mask, $this->offset, $maxLength));
    }