Horde_Vfs_Base::readFile PHP Метод

readFile() публичный Метод

This function provides a file on local disk with the data of a VFS file in it. This file cannot be modified! The behavior if you do modify it is undefined. It will be removed at the end of the request.
public readFile ( string $path, string $name ) : string
$path string The pathname to the file.
$name string The filename to retrieve.
Результат string A local filename.
    public function readFile($path, $name)
    {
        // Create a temporary file and register it for deletion at the
        // end of this request.
        if (!($localFile = Horde_Util::getTempFile('vfs'))) {
            throw new Horde_Vfs_Exception('Unable to create temporary file.');
        }
        if (is_callable(array($this, 'readStream'))) {
            // Use a stream from the VFS if possible, to avoid reading all data
            // into memory.
            $stream = $this->readStream($path, $name);
            if (!($localStream = fopen($localFile, 'w'))) {
                throw new Horde_Vfs_Exception('Unable to open temporary file.');
            }
            stream_copy_to_stream($stream, $localStream);
            fclose($localStream);
        } else {
            // We have to read all of the data in one shot.
            $data = $this->read($path, $name);
            file_put_contents($localFile, $data);
        }
        // $localFile now has $path/$name's data in it.
        return $localFile;
    }