Safely copies wallet.dat to $destination

The destination can be a directory or a path with filename.

@param  string $destination The destination directory or file
@return bool
161875
public function backup($destination)
    {
        $args = [
            (string)$destination
        ];
        return null === $this->rpc->query("backupWallet", $args);
    }
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));
		}
	}
1075221
public function upload($filename, $destination)
    {
        if (isset($this[$filename])) {
            $file = $this[$filename];
            if (is_uploaded_file($file[static::TMP_NAME])) {
                try {
                    return move_uploaded_file($file[static::TMP_NAME], $destination);
                } catch (\Exception $e) {
                    var_dump($e->getMessage());
                    exit();
                }
            }
        }
        return false;
    }
1214663
public function digipolisMirrorDir($dir, $destination)
    {
        if (!is_dir($dir)) {
            return;
        }
        $task = $this->taskFilesystemStack();
        $task->mkdir($destination);

        $directoryIterator = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
        $recursiveIterator = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($recursiveIterator as $item) {
            $destinationFile = $destination . DIRECTORY_SEPARATOR . $recursiveIterator->getSubPathName();
            if (file_exists($destinationFile)) {
                continue;
            }
            if (is_link($item)) {
                if ($item->getRealPath() !== false) {
                    $task->symlink($item->getLinkTarget(), $destinationFile);
                }
                continue;
            }
            if ($item->isDir()) {
                $task->mkdir($destinationFile);
                continue;
            }
            $task->copy($item, $destinationFile);
        }
        return $task;
    }
498800
protected function copyDir(array $paths, /*# string */ $destination)
    {
        foreach ($paths as $path) {
            $dest = $this->mergePath($destination, basename($path));
            if (!$this->copy($path, $dest)) {
                return false;
            }
        }
        return true;
    }
358141
public static function xCopy($source, $destination, $child = 1)
    {
        if (!is_dir($source)) {
            echo("Error:the $source is not a direction!");
            return 0;
        }
        if (!is_dir($destination)) {
            mkdir($destination, 0777);
        }
        $handle = dir($source);
        while ($entry = $handle->read()) {
            if (($entry != ".") && ($entry != "..")) {
                if (is_dir($source . "/" . $entry)) {
                    if ($child) self::xCopy($source . "/" . $entry, $destination . "/" . $entry, $child);
                } else {
                    copy($source . "/" . $entry, $destination . "/" . $entry);
                }
            }
        }
        return 1;
    }
292003
public function export( $destination, $overwriteIfExists = false )
    {

        if( !is_string( $destination ) ){
            throw new \RuntimeException(sprintf(
                'Expected $destination to be a string, got type: %s',
                gettype($destination)
            ));
        }

        if( file_exists( $destination ) and !$overwriteIfExists ) {
            throw new \RuntimeException( sprintf( "File '%s' already exists.", $destination ) );
        }

        if( !is_writable( dirname( $destination ) ) ){
            throw new \RuntimeException( sprintf( "File '%s' is not writable.", $destination ) );
        }

        if( isset( $this->filePath ) ) {
            return copy( $this->filePath, $destination );
        }

        $pg = $this->oid->pg;;

        $pg->query( new Query( 'BEGIN' ) );

        $result = pg_lo_export( $pg->resource->get(), $this->oid->oid, $destination );

        $pg->query( new Query( 'COMMIT' ) );

        return $result;

    }
351564
public function unzip($source, $destination)
    {
        @mkdir($destination, 0777, true);

        foreach ((array) glob($source.'/*.zip') as $key => $value) {
            if ($this->zip->open(str_replace('//', '/', $value)) === true) {
                $this->zip->extractTo($destination);
                echo $this->ZipStatusString($this->zip);
                $this->zip->close();
            }
        }
    }
476004
public function move($origin, $destination)
    {
        if (!$this->fileExists($origin)) {
            return;
        }

        return $this->fromTo('mv', $origin, $destination);
    }
857528
public function move(Dir $destination) {
    $ret = @rename((string) $this,(string) $destination);

    $errInfo = 'Kann Verzeichnis '.$this.' nicht nach '.$destination.' verschieben / umbenennen.';
    
    if (!$ret) {
      if ($destination->exists())
        throw new Exception($errInfo.' Das Zielverzeichnis existiert.');

      if (!$this->exists())
        throw new Exception($errInfo.' Das Quellverzeichnis existiert nicht.');
      else 
        throw new Exception($errInfo);
    }


    /* wir übernehmen die Pfade von $destination */
    $this->path = $destination->getPathArray();
    return $this;
  }
387290
public function saveFromCache($ID, $Destination)
    {
        /* Get the raw picture from the cache */
        $Picture = $this->getFromCache($ID);

        /* Do we have a hit? */
        if ($Picture == null) {
            return false;
        }

        /* Flush the picture to a file */
        $Handle = fopen($Destination, "w");
        fwrite($Handle, $Picture);
        fclose($Handle);

        /* All went fine */
        return true;
    }
296582
public function unpack($source, $destination)
    {
        $this->_setCurrentFile($source)
            ->_setCurrentPath($source);

        $this->_initReader();
        $this->_unpackCurrentTar($destination);
        $this->_destroyReader();

        return $destination;
    }
846773
public function extract($file, $destination = false)
    {
        $archive = $this->getArchiver()->open($file);
        if ($archive) {
            $this->getArchiver()->extractTo($destination);
            return $this->getArchiver()->close();
        }
    }
143347
public function copyDirectory($directory, $destination)
    {
        $files = $this->fileSystem->allFiles($directory);
        $fileDeployed = false;
        $this->fileSystem->copyDirectory($directory, $destination);

        foreach ($files as $file) {
            $fileContents = $this->fileSystem->get($file);
            $fileDeployed = $this->fileSystem->put($destination.'/'.$file->getRelativePathname(), $fileContents);
        }

        return $fileDeployed;
    }
694723
private function formatDestinationRequest($destination, array $options)
    {
        if (!is_string($destination) && !($destination instanceof Bucket)) {
            throw new \InvalidArgumentException(
                '$destination must be either a string or an instance of Bucket.'
            );
        }

        $destAcl = isset($options['predefinedAcl']) ? $options['predefinedAcl'] : null;
        $destObject = isset($options['name']) ? $options['name'] : $this->identity['object'];

        unset($options['name']);
        unset($options['predefinedAcl']);

        return array_filter([
            'destinationBucket' => $destination instanceof Bucket ? $destination->name() : $destination,
            'destinationObject' => $destObject,
            'destinationPredefinedAcl' => $destAcl,
            'sourceBucket' => $this->identity['bucket'],
            'sourceObject' => $this->identity['object'],
            'sourceGeneration' => $this->identity['generation'],
            'userProject' => $this->identity['userProject'],
        ]) + $this->formatEncryptionHeaders($options + $this->encryptionData);
    }
1367718
public function copy(string $destination, $overwrite = false) : bool
    {
        $copied = false;

        if ($this->isFile()) {
            $exists = file_exists($destination);
            if (!$exists || ($exists && $overwrite)) {
                $copied = copy($this->realPath, $destination);
            }
        }

        return $copied;
    }
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;
    }