Create an empty directory

@param   string  directory where to create new dir
@param   string  dirname
@param   int     (octal) file permissions
@param   string|File_Area|null  file area name, object or null for non-specific
@return  bool
162903
public static function create_dir($basepath, $name, $chmod = null, $area = null)
	{
		$basepath	= rtrim(static::instance($area)->get_path($basepath), '\\/').DS;
		$new_dir	= static::instance($area)->get_path($basepath.trim($name,'\\/'));
		is_null($chmod) and $chmod = \Config::get('file.chmod.folders', 0777);

		if ( ! is_dir($basepath) or ! is_writable($basepath))
		{
			throw new \InvalidPathException('Invalid basepath: "'.$basepath.'", cannot create directory at this location.');
		}
		elseif (is_dir($new_dir))
		{
			throw new \FileAccessException('Directory: "'.$new_dir.'" exists already, cannot be created.');
		}

		// unify the path separators, and get the part we need to add to the basepath
		$new_dir = substr(str_replace(array('\\', '/'), DS, $new_dir), strlen($basepath));

		// recursively create the directory. we can't use mkdir permissions or recursive
		// due to the fact that mkdir is restricted by the current users umask
		$basepath = rtrim($basepath, DS);
		foreach (explode(DS, $new_dir) as $dir)
		{
			$basepath .= DS.$dir;
			if ( ! is_dir($basepath))
			{
				try
				{
					if ( ! mkdir($basepath))
					{
						return false;
					}
					chmod($basepath, $chmod);
				}
				catch (\PHPErrorException $e)
				{
					return false;
				}
			}
		}

		return true;
	}
890210
public function makeDirectory($dirname, $mode = 0777)
    {
        $connection = $this->getConnection();

        $directories = explode('/', $dirname);

        foreach ($directories as $directory) {
            if (false === $this->makeActualDirectory($directory, $mode)) {
                $this->setConnectionRoot();
                return false;
            }
            ftp_chdir($connection, $directory);
        }

        $this->setConnectionRoot();

        return true;
    }
740875
public static function create($dirname, $mode = 0755, $recursive = false) {
        if (true === file_exists($dirname)) {
            return null;
        }
        return mkdir($dirname, $mode, $recursive);
    }
79873
public static boolean createOrCleanDirectory(String directory) {
    // if the directory does not exist, create it.
    if (!FileUtils.isDirectoryExists(directory)) {
      LOG.fine("The directory does not exist; creating it.");
      if (!FileUtils.createDirectory(directory)) {
        LOG.severe("Failed to create directory: " + directory);
        return false;
      }
    }

    // Cleanup the directory
    if (!FileUtils.cleanDir(directory)) {
      LOG.severe("Failed to clean directory: " + directory);
      return false;
    }

    return true;
  }
594301
protected function createDirectory($directory)
    {
        if (!@mkdir($directory, $this->mode, true) && !is_dir($directory)) {
            throw new \RuntimeException(sprintf('The directory \'%s\' could not be created.', $directory));
        }
    }
974946
public function emptyDir($directory)
    {
        [$fs, $directory] = $this->getFilesystemAndPath($directory);

        $fs->emptyDir($directory);
    }
1029017
protected function mkDir($dir)
    {
        if (!file_exists($dir)) {
            mkdir($dir, self::DIR_MODE, true);
            chmod($dir, self::DIR_MODE);
        }
        if (!is_dir($dir)) {
            throw new \Exception("Failed to create directory: $dir");
        }
    }
988259
private function createDirectory($dir)
    {
        if (file_exists($dir)) {
            return $this;
        }
        if (false === @mkdir($dir, 0777, true)) {
            throw new \RuntimeException(sprintf('Unable to create directory "%s"', $dir));
        }
        return $this;
    }
477261
public function createDir($dir)
    {
        $oldMask = umask(0);
        @mkdir($dir, self::PERMISSION, true);
        umask($oldMask);
    }
1221998
public static function autocreate_directory($directory)
    {
        if (!file_exists($directory)) {
            mkdir($directory, 0777, true);
        }

        if (!is_writable($directory)) {
            throw new \Exception("Directory \"{$directory}\" is not writable");
        }
    }
399370
public static function safeMakeDirectory($directory, $permissions = 0755)
    {
        // make the directory if it doesnt exist
        if (!is_dir($directory)) {
            echo "Directory {$directory} does not exist, attempting to create...\n";
            mkdir($directory, $permissions, true);
            chmod($directory, $permissions);
            // or pitch a fit if that fails
            if (!is_dir($directory)) {
                throw new \Exception("Failed to create {$directory} directory");
            }

            return true;
        }

        return false;
    }
92647
protected function _createDirectory($dir)
    {
        $old = umask(0);
        // @codingStandardsIgnoreStart
        $result = @mkdir($dir, 0755, true);
        // @codingStandardsIgnoreEnd
        umask($old);

        if ($result) {
            $this->out('Created directory ' . $dir);

            return true;
        }

        $this->err('Failed creating directory ' . $dir);

        return false;
    }
974032
static function create_directory($directory_path, $perms = 0777)
    {
        echo ("Creating the directory: ".$directory_path.PHP_EOL);
        if (!file_exists($directory_path)) {
            mkdir($directory_path, $perms, true);
        } else {
            self::error_out('Error: directory already exists or cannot be written.');
        }
    }
1338523
protected void createDir(String dir) throws StatefulStorageException {
    Path path = new Path(dir);

    try {
      fileSystem.mkdirs(path);
      if (!fileSystem.exists(path)) {
        throw new StatefulStorageException("Failed to create dir: " + dir);
      }
    } catch (IOException e) {
      throw new StatefulStorageException("Failed to create dir: " + dir, e);
    }
  }
1048942
protected function checkDirectory(string $directory, bool $create = false)
    {
        if (!file_exists($directory) &&
            ($create === false || (!@mkdir($directory, 0777, true) && !is_dir($directory)))
        ) {
            throw new ParserConfigurationException(
                "Directory '$directory' does not exist and could not be created.",
                1458974127
            );
        }
    }
504963
protected function _makeDirectory( $directory )
    {
        try
        {
            if ( !is_dir( $directory ) && !is_file( $directory ) && !is_link( $directory ) )
            {
                mkdir( $directory, 0755, true );
            }
        }
        catch ( \Exception $e )
        {
            $this->error( $e->getMessage() );
            die;
        }
    }
575147
private function getDirectories($dir, $directoryName = null)
    {
        $finder = new Finder();
        $finder->directories()->in($dir);

        if (null !== $directoryName) {
            $finder->name($directoryName);
        }

        if (iterator_count($finder) > 0) {
            return iterator_to_array($finder);
        }

        return false;
    }