src/Viserio/Component/Filesystem/FilesystemAdapter.php
public function copy($originFile, $targetFile, $override = false): bool
    {
        if (! $this->has($originFile)) {
            throw new FileNotFoundException($originFile);
        }

        if (\method_exists($this->driver, 'applyPathPrefix')) {
            $orginal = $this->driver->applyPathPrefix($originFile);
            $target  = $this->driver->applyPathPrefix($targetFile);
        } else {
            $orginal = $originFile;
            $target  = $targetFile;
        }

        // https://bugs.php.net/bug.php?id=64634
        if (@\fopen($orginal, 'r') === false) {
            throw new ViserioIOException(\sprintf(
                'Failed to copy [%s] to [%s] because source file could not be opened for reading.',
                $orginal,
                $target
            ), 0, null, $orginal);
        }

        // Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default
        if (@\fopen($target, 'w', false, \stream_context_create(['ftp' => ['overwrite' => true]])) === false) {
            throw new ViserioIOException(\sprintf(
                'Failed to copy [%s] to [%s] because target file could not be opened for writing.',
                $orginal,
                $target
            ), 0, null, $orginal);
        }

        $this->driver->copy($originFile, $targetFile);

        if (! \is_file($target)) {
            throw new ViserioIOException(\sprintf(
                'Failed to copy [%s] to [%s].',
                $originFile,
                $target
            ), 0, null, $originFile);
        }

        return true;
    }
public function copy($originFile, $targetFile, $override = false): bool
    {
        if (! $this->has($originFile)) {
            throw new FileNotFoundException($originFile);
        }

        if (\method_exists($this->driver, 'applyPathPrefix')) {
            $orginal = $this->driver->applyPathPrefix($originFile);
            $target  = $this->driver->applyPathPrefix($targetFile);
        } else {
            $orginal = $originFile;
            $target  = $targetFile;
        }

        // https://bugs.php.net/bug.php?id=64634
        if (@\fopen($orginal, 'r') === false) {
            throw new ViserioIOException(\sprintf(
                'Failed to copy [%s] to [%s] because source file could not be opened for reading.',
                $orginal,
                $target
            ), 0, null, $orginal);
        }

        // Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default
        if (@\fopen($target, 'w', false, \stream_context_create(['ftp' => ['overwrite' => true]])) === false) {
            throw new ViserioIOException(\sprintf(
                'Failed to copy [%s] to [%s] because target file could not be opened for writing.',
                $orginal,
                $target
            ), 0, null, $orginal);
        }

        $this->driver->copy($originFile, $targetFile);

        if (! \is_file($target)) {
            throw new ViserioIOException(\sprintf(
                'Failed to copy [%s] to [%s].',
                $originFile,
                $target
            ), 0, null, $originFile);
        }

        return true;
    }
{@inheritdoc}