Writes output to file

@param string $destination Absolute file path to write to
@param bool $create Create file if it does not exist (if true)
@param string $html Html to write
@return bool
489017
public function write($destination, $create = true, $html = null)
    {
        $output = $this->output($html);
        $File = new File($destination, $create);

        return $File->write($output) && $File->close();
    }
177825
public static function copyRecursive($source, $destination)
    {
        if (is_dir($source)) {
            $dir_handle = opendir($source);

            while ($file = readdir($dir_handle)) {
                if ($file != "." && $file != "..") {
                    self::mkDir($destination);

                    if (is_dir($source . "/" . $file)) {
                        if (!is_dir($destination . "/" . $file)) {
                            mkdir($destination . "/" . $file);
                        }
                        self::copyRecursive($source . "/" . $file, $destination . "/" . $file);
                    } else {
                        copy($source . "/" . $file, $destination . "/" . $file);
                    }
                }
            }
            closedir($dir_handle);
        } else {
            copy($source, $destination);
        }

        return true;
    }
944091
private function move($destination, $tmp, $filename)
    {
        if (!is_dir($destination)) {
            // We can either create it automatically
            if ($this->destinationAutoCreate === true) {
                // Then make a directory (recursively if needed)
                @mkdir($destination, 0777, true);
                
            } else {
                // Destination doesn't exist, and we shouldn't be creating it
                throw new RuntimeException(sprintf(
                    'Destination folder does not exist', $destination
                ));
            }
        }

        $target = sprintf('%s/%s', $destination, $filename);

        // If Remote file exists and we don't want to override it, so let's stop here
        if (is_file($target)) {
            if (!$this->override) {
                return true;
            }
        }

        return move_uploaded_file($tmp, $target);
    }
154773
public function savePage($target, $html)
    {
        $fs = new Filesystem();
        $fs->dumpFile($this->target . DIRECTORY_SEPARATOR . $target, $html);
    }
743478
function Write($h, $txt, $currentx = 0, $link = '', $directionality = 'ltr', $align = '', $fill = 0)
	{
		if (empty($this->directWrite)) {
			$this->directWrite = new DirectWrite($this, $this->otl, $this->sizeConverter, $this->colorConverter);
		}

		$this->directWrite->Write($h, $txt, $currentx, $link, $directionality, $align, $fill);
	}
1141784
public function save($destination)
    {
        $fh = fopen($destination, 'wb');
        if (!$fh) {
            throw new FileOpenException('failed to open destination file: '.$destination);
        }

        if (!flock($fh, LOCK_EX | LOCK_NB, $blocked)) {
            // @codeCoverageIgnoreStart
            if ($blocked) {
                // Concurrent request has requested a lock.
                // File is being processed at the moment.
                // Warning: lock is not checked in windows.
                return false;
            }
            // @codeCoverageIgnoreEnd

            throw new FileLockException('failed to lock file: '.$destination);
        }

        $totalChunks = $this->request->getTotalChunks();

        try {
            $preProcessChunk = $this->config->getPreprocessCallback();

            for ($i = 1; $i <= $totalChunks; $i++) {
                $file = $this->getChunkPath($i);
                $chunk = fopen($file, "rb");

                if (!$chunk) {
                    throw new FileOpenException('failed to open chunk: '.$file);
                }

                if ($preProcessChunk !== null) {
                    call_user_func($preProcessChunk, $chunk);
                }

                stream_copy_to_stream($chunk, $fh);
                fclose($chunk);
            }
        } catch (\Exception $e) {
            flock($fh, LOCK_UN);
            fclose($fh);
            throw $e;
        }

        if ($this->config->getDeleteChunksOnSave()) {
            $this->deleteChunks();
        }

        flock($fh, LOCK_UN);
        fclose($fh);

        return true;
    }
507813
public function write($file, $content = "", $mode = "w+")
    {

        $stream = $this->getFileStream($file, $mode);

        //Write the contents
        fwrite($stream, $content);
        fclose($stream);

        return true;
    }
1153268
public function copy(TemporaryFile $source, string $destination): bool
    {
        $readStream = $source->readStream();

        if (realpath($destination)) {
            $tempStream = fopen($destination, 'rb+');
            $success    = stream_copy_to_stream($readStream, $tempStream) !== false;

            if (is_resource($tempStream)) {
                fclose($tempStream);
            }
        } else {
            $success = $this->put($destination, $readStream);
        }

        if (is_resource($readStream)) {
            fclose($readStream);
        }

        return $success;
    }
1153059
public function linkTo($destination) {
		$target = new FileDescriptor($destination);
		$targetDir = new Directory($target->getDirname());
		$targetDir->make();

		$ok = false;
		if ($target->isLink()) {
			if (!$target->getLinkTarget()->equals($this->pathname)) {
				$target->delete();
			} else {
				$ok = true;
			}
		}

		if (!$ok && @symlink($this->pathname, $target->getPathname()) !== true) {
			$report = error_get_last();
			if (is_array($report) && DIRECTORY_SEPARATOR === '\\' && strpos($report['message'], 'error code(1314)') !== false) {
				throw new FileException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?');
			}
			throw new FileException(sprintf('Failed to create symbolic link from %s to %s', $this->pathname, $targetDir));
		}
	}
1268303
public function autoOutput($ID, $Destination = "output.png")
    {
        if (php_sapi_name() == "cli") {
            $this->saveFromCache($ID, $Destination);
        } else {
            $this->strokeFromCache($ID);
        }
    }
315266
public function write($content, $filename, $pathToFile = null, $mode = "w")
    {
        if ($pathToFile == null) {
            $pathToFile = $this->_filePath;
        }

        $this->createDir($pathToFile);

        $fileHandle = fopen($pathToFile."/".$filename, $mode);
        $success = fwrite($fileHandle, $content);
        fclose($fileHandle);

        return $success;
    }
217332
public function copy($source, $destination)
    {
        $contents = $this('file', $source)->getContent();

        $template = $this->engine->compile($contents);
        $code = $template($this->schema);
        $code = str_replace('\\\\', '\\', $code);
        $code = str_replace('\}', '}', $code);
        $code = str_replace('\{', '{', $code);
        $code = str_replace('{ ', '{', $code);
		$code = preg_replace('/\n\s*\n\s*\n/', "\n\n", $code);

        Index::info('Installing to' . $destination);

        $this('file', $destination)->setContent($code);

        return $this;
    }
106477
public static function write(string $file = '', string $data = '', bool $doAppend = false): bool
    {
        $result = false;
        $file = static::normalizePath($file);
        if (static::verifyPath($file) && Directory::create(\dirname($file))) {
            $flags = $doAppend ? FILE_APPEND : 0;
            $flags |= static::$writeLocks ? LOCK_EX : 0;

            $result = @\file_put_contents($file, $data, $flags) !== false;
            @\chmod($file, static::$newFileMode);
        }
        return $result;
    }
105423
public function copy($destination) {
		$destination = $this->getDestination($destination);

		if (!@copy($this->getPathname(), $destination)) {
			throw new FileException(sprintf('Failed to copy %s to %s', $this->pathname, $destination));
		}
	}
719967
public function put(string $destination, $contents): bool
    {
        return $this->disk->put($destination, $contents, $this->diskOptions);
    }
1169628
public static function extract($file = false, $destination = false) {

        if($file) {

            if(!$destination) {
                $destination = __DIR__;
            }

            if(!Folder::isFolder($destination)) {
                if(!Folder::create($destination)) {
                    return false;
                }
            }

            $zip = new \ZipArchive;
            $res = $zip->open($file);
            if ($res === true) {
              $zip->extractTo($destination);
              $zip->close();
              return true;
            } 
        }

        return false;
    }
892376
public function save($destination = null, $newName = null)
    {
        $fileName = $this->_prepareDestination($destination, $newName);
        $pathInfo = pathinfo($fileName);
        if (!key_exists('extension', $pathInfo) || !in_array($pathInfo['extension'], $this->settings->getExtraFiletypes())) {
            parent::save($destination, $newName);
        }
    }