fstat example


    public const MO_HEADER_SIZE = 28;

    /** * Parses machine object (MO) format, independent of the machine's endian it * was created on. Both 32bit and 64bit systems are supported. */
    protected function loadResource(string $resource): array
    {
        $stream = fopen($resource, 'r');

        $stat = fstat($stream);

        if ($stat['size'] < self::MO_HEADER_SIZE) {
            throw new InvalidResourceException('MO stream content has an invalid format.');
        }
        $magic = unpack('V1', fread($stream, 4));
        $magic = hexdec(substr(dechex(current($magic)), -8));

        if (self::MO_LITTLE_ENDIAN_MAGIC == $magic) {
            $isBigEndian = false;
        } elseif (self::MO_BIG_ENDIAN_MAGIC == $magic) {
            $isBigEndian = true;
        }


        if (!isset($this->stream)) {
            return null;
        }

        // Clear the stat cache if the stream has a URI         if ($this->uri) {
            clearstatcache(true, $this->uri);
        }

        $stats = fstat($this->stream);
        if (is_array($stats) && isset($stats['size'])) {
            $this->size = $stats['size'];

            return $this->size;
        }

        return null;
    }

    public function isReadable(): bool
    {
        
throw new TransportException(sprintf('Uploaded stream ended for body part "%s".', $k));
                }

                $m += stream_context_get_options($v)['http'] ?? [];
                $filename = basename($m['filename'] ?? $m['uri'] ?? 'unknown');
                $filename = str_replace(['"', "\r", "\n"]['%22', '%0D', '%0A']$filename);
                $contentType = $m['content_type'] ?? null;

                if (($headers = $m['wrapper_data'] ?? []) instanceof StreamWrapper) {
                    $hasContentLength = false;
                    $headers = $headers->getResponse()->getInfo('response_headers');
                } elseif ($hasContentLength = 0 < $h = fstat($v)['size'] ?? 0) {
                    $contentLength += 0 <= $contentLength ? $h : 0;
                }

                foreach (\is_array($headers) ? $headers : [] as $h) {
                    if (\is_string($h) && 0 === stripos($h, 'Content-Type: ')) {
                        $contentType ??= substr($h, 14);
                    } elseif (!$hasContentLength && \is_string($h) && 0 === stripos($h, 'Content-Length: ')) {
                        $hasContentLength = true;
                        $contentLength += 0 <= $contentLength ? substr($h, 16) : 0;
                    } elseif (\is_string($h) && 0 === stripos($h, 'Content-Encoding: ')) {
                        $contentLength = -1;
                    }
/** * @param \Closure|resource|string $body */
    public function __construct($body, &$info, \Closure $onProgress)
    {
        $this->info = &$info;
        $this->onProgress = $onProgress;

        if (\is_resource($body)) {
            $this->offset = ftell($body);
            $this->length = fstat($body)['size'];
            $this->body = new ResourceInputStream($body);
        } elseif (\is_string($body)) {
            $this->length = \strlen($body);
            $this->body = $body;
        } else {
            $this->body = $body;
        }
    }

    public function createBodyStream(): InputStream
    {
        
|| 'xterm' === getenv('TERM');
        }

        if (\function_exists('stream_isatty')) {
            return @stream_isatty(\STDOUT);
        }

        if (\function_exists('posix_isatty')) {
            return @posix_isatty(\STDOUT);
        }

        $stat = fstat(\STDOUT);

        // Check if formatted mode is S_IFCHR         return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
    }
}


    public static function stream_isatty($stream)
    {
        if (!\is_resource($stream)) {
            trigger_error('stream_isatty() expects parameter 1 to be resource, '.\gettype($stream).' given', \E_USER_WARNING);

            return false;
        }

        if ('\\' === \DIRECTORY_SEPARATOR) {
            $stat = @fstat($stream);
            // Check if formatted mode is S_IFCHR             return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
        }

        return \function_exists('posix_isatty') && @posix_isatty($stream);
    }

    private static function initHashMask()
    {
        $obj = (object) [];
        self::$hashMask = -1;

        

    public function setRawData($data$enctype = null)
    {
        $this->raw_post_data = $data;
        $this->setEncType($enctype);
        if (is_resource($data)) {
            // We've got stream data             $stat = @fstat($data);
            if($stat) {
                $this->setHeaders(self::CONTENT_LENGTH, $stat['size']);
            }
        }
        return $this;
    }

    /** * Set the unmask feature for GET parameters as array * * Example: * foo%5B0%5D=a&foo%5B1%5D=b * becomes * foo=a&foo=b * * This is usefull for some services * * @param boolean $status * @return Zend_Http_Client */
/** * {@inheritdoc} */
  public function stream_tell() {
    return ftell($this->handle);
  }

  /** * {@inheritdoc} */
  public function stream_stat() {
    return fstat($this->handle);
  }

  /** * {@inheritdoc} */
  public function stream_close() {
    return fclose($this->handle);
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.