Create all required directories an check whether they are writeable or not.

@return string The action output.
339111
public function actionIndex()
    {
        $error = false;

        @chdir(Yii::getAlias('@app'));

        $this->output('The directory the health commands is applying to: ' . Yii::getAlias('@app'));
        
        foreach ($this->folders as $folder => $writable) {
            $mode = ($writable) ? 0777 : 0775;
            if (!file_exists($folder)) {
                if (FileHelper::createDirectory($folder, $mode)) {
                    $this->outputSuccess("$folder: successfully created directory");
                } else {
                    $error = true;
                    $this->outputError("$folder: unable to create directory");
                }
            } else {
                $this->outputInfo("$folder: directory exists already");
            }
            
            if ($writable && !is_writable($folder)) {
                $this->outputInfo("$folder: is not writeable, try to set mode '$mode'.");
                @chmod($folder, $mode);
            }

            if ($writable) {
                if (!is_writable($folder)) {
                    $error = true;
                    $this->outputError("$folder: is not writable, please change permissions.");
                }
            }
        }

        foreach ($this->files as $file) {
            if (file_exists($file)) {
                $this->outputInfo("$file: file exists.");
            } else {
                $error = true;
                $this->outputError("$file: file does not exists!");
            }
        }
        
        return $error ? $this->outputError('Health check found errors!') : $this->outputSuccess('O.K.');
    }
1006422
public function createDirectories()
    {
        if (!file_exists($this->getDomainPath())) {
            mkdir($this->getDomainPath(), 0777);
        }

        if (!file_exists($this->getInfrastructurePath())) {
            mkdir($this->getInfrastructurePath(), 0777);
        }

        if (!file_exists($this->getTestPath())) {
            mkdir($this->getTestPath(), 0777);
        }

        if (!$this->option('without-abstracts')) {
            $this->copyAbstractClasses();
        }

        $this->setDomainPath($this->getDomainPath(DIRECTORY_SEPARATOR.$this->getDirectory()));
        $this->setInfrastructurePath($this->getInfrastructurePath(DIRECTORY_SEPARATOR.$this->getDirectory()));
        $this->setTestPath($this->getTestPath(DIRECTORY_SEPARATOR.$this->getDirectory()));

        if (!file_exists($this->getDomainPath())) {
            mkdir($this->getDomainPath(), 0777);
            mkdir($this->getDomainPath('/Contracts'), 0777);
        }

        if (!file_exists($this->getInfrastructurePath())) {
            mkdir($this->getInfrastructurePath(), 0777);
            mkdir($this->getInfrastructurePath('/Contracts'), 0777);
        }

        if (!file_exists($this->getTestPath())) {
            mkdir($this->getTestPath(), 0777);
        }

        return true;
    }
676447
protected function doSetupDirectories() {
    $destination = $this->getInstallationDirectory();
    $this->write('Prepare custom projects directory at <comment>%s</comment>', $this->shortenDirectory($destination));
    $this->fs->emptyDirectory($destination);

    $destination = $this->getDefaultDirectory();
    $this->write('Make <comment>%s</comment> writable', $this->shortenDirectory($destination));
    chmod($destination, 0755);
  }
1132384
protected function prepareDefaultDirectory() : Directory {
        $path = $this->finder->setWorkingDirectory('/');

        return new Directory($this->factory, $this->finder, $path);
    }
84672
public function generate ()
	{
		$startTime = microtime (true);

		if (!is_dir($this->reportDir)) 
		{
			echo "Creating new directory {$this->reportDir}... ";
			mkdir ($this->reportDir);	
			echo "OK\n";
		}

		echo "Generating CSV report to {$this->reportDir} ... ";

		$this->generateCsvForDirectory ($this->report);
		foreach ($this->report->getChildrenRecursively(new DirectorySpecification) as $item) 
		{
			$this->generateCsvForDirectory ($item);
		}

		$totalTime = number_format (microtime(true) - $startTime, 2);
		echo "OK ({$totalTime}s).\n";
	}
647588
public function actionFolderCreate()
    {
        $this->checkRouteAccess(self::PERMISSION_ROUTE);
        
        $folderName = Yii::$app->request->post('folderName', null);
        $parentFolderId = Yii::$app->request->post('parentFolderId', 0);
        $response = Yii::$app->storage->addFolder($folderName, $parentFolderId);
        $this->flushApiCache();
        
        return $response;
    }
454837
public function dir()
    {
        $this->_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid($this->_prefix);
        if (!mkdir($this->_name)) {
            throw new \Exception('Cannot create temporary directory');
        }
        return $this;
    }
343345
def prepare_writeable_dir(tree):
    '''  '''

    if tree != '/':
        tree = os.path.realpath(os.path.expanduser(tree))
    if not os.path.exists(tree):
        try:
            os.makedirs(tree)
        except (IOError, OSError), e:
            exit("Could not make dir %s: %s" % (tree, e))
    if not os.access(tree, os.W_OK):
        exit("Cannot write to path %s" % tree)
467287
protected function createDirectoryStructure()
    {
        $this->output->writeLn("Ensuring correct directory structure.");

        $count = 0;
        foreach ($this->directoryStructure as $dir) {
            $label = $this->tree(++$count >= count($this->directoryStructure));
            if (!is_dir($dir)) {
                if (mkdir($dir)) {
                    $this->output->writeLn($label . $this->ok($dir));
                } else {
                    $this->output->writeLn($label . $this->fail($dir));
                    $this->flagFailing();
                }
            } else {
                $this->output->writeLn($label . $this->skip($dir));
            }
        }

        $this->nl();
    }
483896
private function doSetPermissions(): void
    {
        $permissionMethod = $this->getConfig(Option::permissionMethod);
        $writableDirs = implode(' ', $this->getConfig(Option::writableDirs));
        $this->log(sprintf('<h2>Setting permissions for writable dirs using the "%s" method</>', $permissionMethod));

        if ('chmod' === $permissionMethod) {
            $this->runRemote(sprintf('chmod -R %s %s', $this->getConfig(Option::permissionMode), $writableDirs));

            return;
        }

        if ('chown' === $permissionMethod) {
            $this->runRemote(sprintf('sudo chown -RL %s %s', $this->getConfig(Option::permissionUser), $writableDirs));

            return;
        }

        if ('chgrp' === $permissionMethod) {
            $this->runRemote(sprintf('sudo chgrp -RH %s %s', $this->getConfig(Option::permissionGroup), $writableDirs));

            return;
        }

        if ('acl' === $permissionMethod) {
            $this->runRemote(sprintf('sudo setfacl -RL -m u:"%s":rwX -m u:`whoami`:rwX %s', $this->getConfig(Option::permissionUser), $writableDirs));
            $this->runRemote(sprintf('sudo setfacl -dRL -m u:"%s":rwX -m u:`whoami`:rwX %s', $this->getConfig(Option::permissionUser), $writableDirs));

            return;
        }

        throw new InvalidConfigurationException(sprintf('The "%s" permission method is not valid. Select one of the supported methods.', $permissionMethod));
    }
348582
public function
	Build() {
	/*//
	compile the files down to the final form.
	//*/

		if($this->Print) {
			header(sprintf(
				"Content-type: %s",
				$this->GetFullContentType()
			));
		}

		$ds = DIRECTORY_SEPARATOR;
		$source = '';
		$filelist = $this->FindTheFiles();
		$outfile = sprintf(
			"%s{$ds}%s{$ds}%s",
			$this->OutputDir,
			$this->DistDir,
			$this->OutputFile
		);

		if($this->AddScriptHeader) $this->AppendScriptHeader(
			$filelist,
			$source
		);

		foreach($filelist as $filepath)
		$this->AppendFile($filepath,$source);

		if($this->OutputFile) {
			if(!$this->WriteToDisk($outfile,$source)) {
				echo $this->GetComment(
					$this->Print,
					"INFO: output was unchanged with this build.",
					$source
				);

				if($this->Print)
				echo PHP_EOL;
			}
		}

		if($this->Print) {
			echo $source, PHP_EOL;
		}

		return $this;
	}
1320516
protected function _writeFiles()
    {
        $overwriteAll = false;
        if (!empty($this->params['overwrite'])) {
            $overwriteAll = true;
        }
        foreach ($this->_storage as $domain => $sentences) {
            $output = $this->_writeHeader();
            foreach ($sentences as $sentence => $header) {
                $output .= $header . $sentence;
            }

            // Remove vendor prefix if present.
            $slashPosition = strpos($domain, '/');
            if ($slashPosition !== false) {
                $domain = substr($domain, $slashPosition + 1);
            }

            $filename = str_replace('/', '_', $domain) . '.pot';
            $File = new File($this->_output . $filename);
            $response = '';
            while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
                $this->out();
                $response = $this->in(
                    sprintf('Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename),
                    ['y', 'n', 'a'],
                    'y'
                );
                if (strtoupper($response) === 'N') {
                    $response = '';
                    while (!$response) {
                        $response = $this->in('What would you like to name this file?', null, 'new_' . $filename);
                        $File = new File($this->_output . $response);
                        $filename = $response;
                    }
                } elseif (strtoupper($response) === 'A') {
                    $overwriteAll = true;
                }
            }
            $File->write($output);
            $File->close();
        }
    }
1052649
public function canWrite()
    {
        $ht = $this->getHTaccessFilename();
        $fs = $this->getFilesystem();

        return (bool) (@$fs->isFile($ht) ? @$fs->isWritable($ht) : @$fs->isWritable(@dirname($ht)));
    }
40427
public function createChunkDir()
    {
        $directoryName = date('Y/m/d/H/i/', time());
        $dir = $this->getDir() . $directoryName;

        if (!$this->filesystem->exists($dir)) {
            $this->filesystem->mkdir($dir, 0755);
        }

        return $directoryName;
    }
661021
public function write()
    {
        $filename = $this->isFileWritable() ? $this->filename : $this->getCacheFilename();

        return file_put_contents($filename, $this->render());
    }
1122383
protected function make()
	{
		if (count($this->templateFiles) > 0)
		{
			foreach ($this->templateFiles as $template)
			{
				if (is_dir($template['path']))
				{
					if (!Filesystem::copyDirectory($template['path'], $template['destination']))
					{
						$this->output->error("Error: an problem occured copying {$template['path']} to {$template['destination']}.");
					}

					// Get folder contents
					$this->scanFolder($template['destination']);
				}
				elseif (is_file($template['path']))
				{
					if (!copy($template['path'], $template['destination']))
					{
						$this->output->error("Error: an problem occured copying {$template['path']} to {$template['destination']}.");
					}

					// Get template contents
					$contents = file_get_contents($template['destination']);
					$contents = $this->doReplacements($contents);

					// Write file
					$this->putContents($template['destination'], $contents);
				}
			}
		}
	}
536155
def create_output_directory(cls, outdir):
        """"""
        cls.PATH = outdir
        try:
            os.mkdir(outdir)
        except FileExistsError:
            pass