Retruns the instance document contents as named memory stream file
@return boolean|string
197248
public function getInstanceDocumentAsMemoryFile()
	{
		// If this returns null there is no instance document
		$xbrl = $this->getInstanceDocument( false );
		if ( ! $xbrl ) return false;

		$instanceFilename = "mem://{$this->instanceDocument}";

		if ( ! class_exists("MemoryStream", true ) )
		{
			/**
			 * Load the dictionary class
			 */
			$utiltiesPath = isset( $_ENV['UTILITY_LIBRARY_PATH'] )
				? $_ENV['UTILITY_LIBRARY_PATH']
				: ( defined( 'UTILITY_LIBRARY_PATH' ) ? UTILITY_LIBRARY_PATH : __DIR__ . "/../utilities" );
			require_once "$utiltiesPath/MemoryStream.php";
		}

		$f = fopen( $instanceFilename, "w+" );
		fwrite( $f, $xbrl );
		fclose( $f );

		return $instanceFilename;
	}
516967
public function getContentStream()
    {
        if (!$this->objectId || !$this->getStreamId()) {
            return null;
        }

        return $this->session->getBinding()->getObjectService()->getContentStream(
            $this->session->getRepositoryInfo()->getId(),
            $this->objectId,
            $this->getStreamId()
        );
    }
492543
public function getContents()
    {
        if (!\is_resource($this->stream)) {
            throw new \TypeError();
        }
        if (!$this->isReadable() || ($contents = \stream_get_contents($this->stream)) === false) {
            throw new \RuntimeException('Could not get contents of stream');
        }
        if (!isset($contents)) {
            $contents = '';
        }

        return (string) $contents;
    }
1298333
private function write()
    {
        $cache = serialize($this->records);
        flock($this->file, LOCK_EX);
        rewind($this->file);
        ftruncate($this->file, 0);
        $bytes = fwrite($this->file, $cache);
        flock($this->file, LOCK_UN);

        return $bytes === strlen($cache);
    }
1369775
protected function get_file_record() {
        $file = $this->get_sourcefile();

        if (!$file) {
            // If the source file was removed before we completed, we must return early.
            return false;
        }

        return [
            'contextid' => \context_system::instance()->id,
            'component' => 'core',
            'filearea'  => 'documentconversion',
            'itemid'    => 0,
            'filepath'  => "/" . $this->get('targetformat') . "/",
            'filename'  => $file->get_contenthash(),
        ];
    }
280101
function getContents()
    {
        if (!$this->isReadable())
            throw new \RuntimeException('Stream is not readable.');

        $content = '';
        while (!$this->eof()) {
            $buf = $this->read(1048576);
            // match on '' and false by loose equal
            if ($buf == null)
                break;

            $content .= $buf;
        }

        return $content;
    }
1261920
public function getContent()
    {
        if ($this->content === null) {
            fseek($this->stream, 0);
            while (($buf = $this->read()) !== false) {
                $this->content .= $buf;
            }
        }

        return $this->content;
    }
398877
public function getStubBannerFromFile()
    {
        if (null !== ($path = $this->getStubBannerPath())) {
            $path = $this->getBasePath() . DIRECTORY_SEPARATOR . $path;

            if (false === ($contents = @file_get_contents($path))) {
                $errors = error_get_last();
                if ($errors === null) {
                    $errors = array('message' => 'failed to get contents of \''.$path.'\'');
                }

                throw new RuntimeException($errors['message']);
            }

            return $contents;
        }

        return null;
    }
1357504
public function toStream()
    {
        if (!\is_resource($this->process)) {
            $this->process = \proc_open('/usr/bin/env tar c .', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, $this->directory);
            $this->stream = $pipes[1];
        }

        return $this->stream;
    }
1322929
public function stream_flush()
    {
        if (!$this->getResource()) {
            return false;
        }

        $buffer = $this->getDataBuffer();
        $bufferWritten = $buffer;
        $retVal = true;
        if (!empty($buffer)) {

            $object = $this->getResource()->getObject();
            $mimetype = $this->getService()->guessFileType($this->getResource()->getResourceName());
            $object->content_type = $mimetype;
            $object->setData($buffer);
            $object->Create();
        }

       if (strlen($bufferWritten) ==  strlen($buffer)) {
            $this->setDataBuffer(null);
        } else {
            $this->setDataBuffer($buffer);
        }
        $this->setDataBuffer(null);

        return $retVal;
    }
661422
public function getFileContent()
    {
        $filepath = $this->getFilePath();

        if (is_file($filepath)) {
            $wordsArray = include $filepath;
            asort($wordsArray);

            return $wordsArray;
        }

        return false;
    }
976712
protected function getArchive()
    {
        if (($fileData = $this->getRemoteContent(self::ARCHIVE_URL)) === false) {
            return false;
        }

        $fileName = Yii::getAlias('@runtime') . DIRECTORY_SEPARATOR . substr(strrchr(self::ARCHIVE_URL, '/'), 1);
        if (@file_put_contents($fileName, $fileData) !== false) {
            return $fileName;
        }

        return false;
    }
779871
public function getStream()
    {
        if (!$this->_stream instanceof StreamInterface) {
            if ($this->_stream === null) {
                if ($this->getError() !== UPLOAD_ERR_OK) {
                    throw new \RuntimeException('Unable to create file stream due to upload error: ' . $this->getError());
                }
                $stream = [
                    '__class' => FileStream::class,
                    'filename' => $this->tempFilename,
                    'mode' => 'r',
                ];
            } elseif ($this->_stream instanceof \Closure) {
                $stream = \call_user_func($this->_stream, $this);
            } else {
                $stream = $this->_stream;
            }

            $this->_stream = Yii::ensureObject($stream, StreamInterface::class);
        }
        return $this->_stream;
    }
1366383
public function retrieveFilenameOfCurrentClass()
    {
        // Inline cache [expensive]
        if (null === $this->getFilenameOfCurrentClass()) {

            // Inline cache [expensive]
            if (null === $debugBacktrace = $this->getDebugBacktrace()) {
                $debugBacktrace = debug_backtrace();

                $this->setDebugBacktrace(
                    $debugBacktrace
                );
            }

            // Some security by retrieving path by path
            $this->filenameOfCurrentClass = filename($debugBacktrace[0]['file']);
        }

        return $this->filenameOfCurrentClass;
    }
730617
public function getContents()
    {
        set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
        $content = file_get_contents($this->getPathname());
        restore_error_handler();
        if (false === $content) {
            throw new \RuntimeException($error);
        }

        return $content;
    }
609263
public function stream_flush()
    {
        // If the stream wasn't opened for writing, just return false
        if (!$this->_writeBuffer) {
            return false;
        }
        $ret = $this->_oss->putObject(AliyunOSS::getBucket(), $this->_objectName, $this->_objectBuffer);
        $this->_objectBuffer = null;

        return $ret;
    }
756222
public function getStream()
    {
        if ($this->stream instanceof \Closure) {
            $this->stream = $this->stream->__invoke();
        }
        if (is_resource($this->stream)) {
            $meta = stream_get_meta_data($this->stream);
            if ($meta['seekable']) {
                rewind($this->stream);
            }
        }
        return $this->stream;
    }