<commit_before><?php

namespace Droid\Plugin\Fs\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Droid\Lib\Plugin\Command\CheckableTrait;
use Droid\Plugin\Fs\Utils;
use RuntimeException;

class FsMkdirCommand extends Command
{
    use CheckableTrait;

    public function configure()
    {
        $this->setName('fs:mkdir')
            ->setDescription('Creates a directory')
            ->addArgument(
                'directory',
                InputArgument::REQUIRED,
                'Directory name to create'
            )
            ->addOption(
                'mode',
                'm',
                InputOption::VALUE_REQUIRED,
                'Permission filemode'
            )
            ->addOption(
                'force',
                'f',
                InputOption::VALUE_NONE,
                'Force'
            )
        ;
        $this->configureCheckMode();
    }

    public function execute(InputInterface $input, OutputInterface $output)
    {
        $this->activateCheckMode($input);
        $directory = $input->getArgument('directory');
        $directory = Utils::normalizePath($directory);
        $output->writeLn("Fs mkdir: $directory");
        if (!$input->getOption('force')) {
            if (file_exists($directory)) {
                throw new RuntimeException("Directory already exists: " . $directory);
            }
        }
        $mode = $input->getOption('mode');
        if (!$mode) {
            $mode = 0777;
        } else {
            $mode = octdec($mode);
        }
        $this->markChange();
        if (!$this->checkMode()) {
            @mkdir($directory, $mode, true);<commit_msg>Consider mkdir on existing directory a noop<commit_after><?php

namespace Droid\Plugin\Fs\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Droid\Lib\Plugin\Command\CheckableTrait;
use Droid\Plugin\Fs\Utils;
use RuntimeException;

class FsMkdirCommand extends Command
{
    use CheckableTrait;

    public function configure()
    {
        $this->setName('fs:mkdir')
            ->setDescription('Creates a directory')
            ->addArgument(
                'directory',
                InputArgument::REQUIRED,
                'Directory name to create'
            )
            ->addOption(
                'mode',
                'm',
                InputOption::VALUE_REQUIRED,
                'Permission filemode'
            )
            ->addOption(
                'force',
                'f',
                InputOption::VALUE_NONE,
                'Force'
            )
        ;
        $this->configureCheckMode();
    }

    public function execute(InputInterface $input, OutputInterface $output)
    {
        $this->activateCheckMode($input);
        $directory = $input->getArgument('directory');
        $directory = Utils::normalizePath($directory);
        $output->writeLn("Fs mkdir: $directory");
        if (!$input->getOption('force')) {
            if (file_exists($directory)) {
                $this->reportChange($output);
                return;
            }
        }
        $mode = $input->getOption('mode');
        if (!$mode) {
            $mode = 0777;
        } else {
            $mode = octdec($mode);
        }
        $this->markChange();
        if (!$this->checkMode()) {
            @mkdir($directory, $mode, true);
{'fraction_non_alphanumeric': 0.12283967030045201, 'fraction_numerical': 0.002127093858016485, 'mean_word_length': 1.8916218293620293, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '3688707', 'n_tokens_mistral': 1021, 'n_tokens_neox': 984, 'n_words': 181}