<commit_before><?php

namespace Isaac\Services\Filesystem;

use League\Flysystem\Plugin\AbstractPlugin;

/**
 * Grants the ability to copy a directory in its entirety.
 */
class CopyDirectory extends AbstractPlugin
{
    /**
     * Get the method name.
     *
     * @return string
     */
    public function getMethod()
    {
        return 'copyDirectory';
    }

    /**
     * Copies a directory someplace else.
     *
     * @param string $from
     * @param string $to
     */
    public function handle(string $from, string $to)
    {
        // Unify slashes
        $from = str_replace('\\', '/', $from);
        $to = str_replace('\\', '/', $to);

        $contents = $this->filesystem->listContents($from, true);
        foreach ($contents as $file) {
            $destination = str_replace($from, $to, $file['path']);

            if ($file['type'] === 'file') {
                $this->filesystem->forceCopy($file['path'], $destination);
            } else {
                $this->filesystem->createDir($destination);
            }
        }
    }
}<commit_msg>Fix path uniformization in backup<commit_after><?php

namespace Isaac\Services\Filesystem;

use League\Flysystem\Plugin\AbstractPlugin;
use League\Flysystem\Util;

/**
 * Grants the ability to copy a directory in its entirety.
 */
class CopyDirectory extends AbstractPlugin
{
    /**
     * Get the method name.
     *
     * @return string
     */
    public function getMethod()
    {
        return 'copyDirectory';
    }

    /**
     * Copies a directory someplace else.
     *
     * @param string $from
     * @param string $to
     */
    public function handle(string $from, string $to)
    {
        // Unify slashes
        $from = Util::normalizePath($from);
        $to = Util::normalizePath($to);

        $contents = $this->filesystem->listContents($from, true);
        foreach ($contents as $file) {
            $destination = str_replace($from, $to, $file['path']);

            if ($file['type'] === 'file') {
                $this->filesystem->copy($file['path'], $destination);
            } else {
                $this->filesystem->createDir($destination);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.14409881061299176, 'fraction_numerical': 0.0, 'mean_word_length': 2.084626234132581, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3736041', 'n_tokens_mistral': 627, 'n_tokens_neox': 612, 'n_words': 150}