/** * @deprecated Moved to puzzle_stream_Utils::open() */ function puzzle_stream_safe_open($filename, $mode) { return puzzle_stream_Utils::open($filename, $mode); }
/** * Drain the stream into the destination stream */ private function getSaveToBody(puzzle_message_RequestInterface $request, puzzle_stream_StreamInterface $stream) { $config = $request->getConfig(); if ($saveTo = $config['save_to']) { // Stream the response into the destination stream $saveTo = is_string($saveTo) ? new puzzle_stream_Stream(puzzle_stream_Utils::open($saveTo, 'r+')) : puzzle_stream_Stream::factory($saveTo); } else { // Stream into the default temp stream $saveTo = puzzle_stream_Stream::factory(); } puzzle_stream_Utils::copyToStream($stream, $saveTo); $saveTo->seek(0); $stream->close(); return $saveTo; }
/** * Creates the underlying stream lazily when required. * * @return puzzle_stream_StreamInterface */ protected function createStream() { return puzzle_stream_Stream::factory(puzzle_stream_Utils::open($this->filename, $this->mode)); }
/** * @expectedException RuntimeException * @expectedExceptionMessage Unable to open /path/to/does/not/exist using mode r */ public function testThrowsExceptionNotWarning() { puzzle_stream_Utils::open('/path/to/does/not/exist', 'r'); }