Create the target directory recursively if needed

@param string $path
@param int $chmod default 0644

@return void
@throws Exception
@throws \Koldy\Config\Exception
@throws \Koldy\Exception
@example $chmod 0777, 0755, 0700
507014
public static function mkdir(string $path, $chmod = null): void
    {
        if (!is_dir($path)) {
            if ($chmod === null) {
                $chmod = Application::getConfig('application')->getArrayItem('filesystem', 'default_chmod', 0644);
            }

            if (!mkdir($path, $chmod, true)) {
                throw new FilesystemException("Can not create directory on path={$path}");
            }
        }
    }
239929
public function create($path)
    {
        $folders = explode('/', trim(preg_replace('#/+#', '/', $path), '/'));
        $lastFolderId = self::ROOT_DIR_ID;

        foreach ($folders as $name) {

            $command = new CreateFolder($name, $lastFolderId);
            $response = ResponseFactory::getResponse($this->contentClient, $command);

            if ($response instanceof SuccessResponse) {

                if ($response->getStatusCode() == 201) {
                    $lastFolderId = $response->json()['id'];
                    usleep(250);
                    continue;
                }

            } elseif ($response instanceof ErrorResponse) {

                if ($response->getStatusCode() == 409) {
                    $lastFolderId = reset($response->json()['context_info']['conflicts'])['id'];
                    usleep(250);
                    continue;
                }

                throw new \Exception($response->getStatusCode() . (string)$response->getBody());
            }
        }

        if (is_null($lastFolderId)) {
            throw new \Exception();
        }

        return $lastFolderId;
    }
1081528
public function chmodR($path, $filemode)
    {

        if (!$this->isFolder($path)) {
            return $this->chmod($path, $filemode);
        }

        $dirh = @opendir($path);
        while ($file = readdir($dirh)) {
            if ($file != '.' && $file != '..') {
                $fullpath = $path . '/' . $file;
                if (!$this->isFolder($fullpath)) {
                    if (!$this->chmod($fullpath, $filemode)) {
                        return false;
                    }
                } else {
                    if (!$this->chmodR($fullpath, $filemode)) {
                        return false;
                    }
                }
            }
        }

        closedir($dirh);

        if ($this->chmod($path, $filemode)) {
            return true;
        } else {
            return false;
        }
    }
380247
protected function recursiveCreateDir($path)
    {
        if ($this->isDirectory($path)) {
            return;
        }

        $directories = explode($this->pathSeparator, $path);
        if (count($directories) > 1) {
            $parentDirectories = array_splice($directories, 0, count($directories) - 1);
            $this->recursiveCreateDir(implode($this->pathSeparator, $parentDirectories));
        }

        $location = $this->applyPathPrefix($path);

        $this->share->mkdir($location);
    }
1134769
function mkdir( $path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false ) {
		$path = trailingslashit( $path );

		$parent_node = $this->locate_parent_node( $path );
		if ( ! $parent_node ) {
			$dirname = str_replace( '\\', '/', dirname( $path ) );
			$this->mkdir( $dirname );
			$parent_node = $this->locate_parent_node( $path );
			if ( ! $parent_node )
				return false;
		}

		$node = new MockFS_Directory_Node( $path );

		$parent_node->children[ $node->name ] = $node;
		$this->fs_map[ $path ] = $node;

		return true;
	}
210494
protected function makeDir($path)
    {
        if (! file_exists(dirname($path))) {
            $this->makeDir(dirname($path));
        }

        if (! file_exists($path)) {
            mkdir($path);
        }
    }
145224
private function createFeatureDirectory($path)
    {
        mkdir($path, 0777, true);

        if ($this->logger) {
            $this->logger->directoryCreated($path, 'place your *.feature files here');
        }
    }
312767
protected function createDir($path) {
        if (!is_dir($path)) {
            $this->log->info('Create directory %s', $path);

            $status = mkdir($path, 0775, true);

            if ($status === false) {
                throw new Exception(sprintf(
                    'Unable to create directory %s',
                    $path
                ), ExitApp::RUNTIME_ERROR);
            }
        }

        return $this;
    }
841684
protected function makeDirectory($path)
    {
        if (! $this->getFiles()->isDirectory(dirname($path))) {
            
            $this->getFiles()->makeDirectory(dirname($path), 0777, true, true);
        }
    }
1150335
public function makeDir($path)
    {
        if (empty($path)) return false;
        $dir = explode("/", $path);
        $path = ftp_pwd($this->linkid) . '/';
        $ret = true;
        for ($i=0; $i<count($dir); $i++) {
            $path = $path . $dir[$i] . '/';
            if (!@ftp_chdir($this->linkid, $path)) {
                if (!@ftp_mkdir($this->linkid, $dir[$i])) {
                    $ret = false;
                    break;
                }
            }
            @ftp_chdir($this->linkid, $path);
        } 
        if (!$ret) return false;
        return true;
    }
188456
public function folderChmod(ConsoleIo $io, $path, $chmod = 0777)
    {
        if (!(new Folder())->chmod($path, $chmod, true)) {
            $io->error(__d('me_tools', 'Failed to set permissions on `{0}`', rtr($path)));

            return false;
        }

        $io->verbose(__d('me_tools', 'Setted permissions on `{0}`', rtr($path)));

        return true;
    }
1314367
protected function createTargetDirectory($path)
    {
        $directory = dirname($path);
        if (!file_exists($directory)) {
            if (!is_writeable($this->getExistingPath($directory))) {
                throw new Exception('The directory "' . $directory . '" isn\'t writeable!');
            }
            
            mkdir($directory, 0755, true);
        }
    }
239413
public function createDirectory($directory, $chmod = null, $recurisve = true)
    {
        $chmod     = $chmod ?: $this->chmod;
        $directory = sprintf('%s/%s', $this->rootDir, trim($directory, '/'));

        if (!$this->fileSystem->exists($directory)) {
            try {
                $this->fileSystem->mkdir($directory);
            } catch (FsIOException $e) {
                throw new IOException($e->getMessage(), $e->getCode(), $e);
            }
        }

        return true;
    }
51581
public static function chmod($path, $mode = null)
  {
    if ($mode) {
      return chmod($path, $mode);
    }

    return substr(sprintf('%o', fileperms($path)), -4);
  }
32368
public static function mkdir(string $path)
    {
        if (!is_dir($path))
        {
            mkdir($path, self::$dir_mode, true);
        }
    }
290273
public function save($chmod = null)
    {
        if ($this->modified) {
            if (false === @file_put_contents($this->filename, $this->generateIni())) {
                throw new \Exception('Impossible to write into '.$this->filename);
            } elseif ($chmod) {
                chmod($this->filename, $chmod);
            }
            $this->modified = false;
        }
    }
227764
public function mkdir($path, $permission = null, $recursive = false)
    {
        $fullPath = $this->concatPaths($path);

        if (file_exists($fullPath) && is_dir($path)) {
            return true;
        }

        $defaultPermissions = $this->getPermissionUtils()->getDefaultPermissions();

        if (!isset($permission)) {
            $permission = (string) $defaultPermissions['dir'];
            $permission = base_convert($permission, 8, 10);
        }

        try {
            $result = mkdir($fullPath, $permission, true);

            if (!empty($defaultPermissions['user'])) {
                $this->getPermissionUtils()->chown($fullPath);
            }

            if (!empty($defaultPermissions['group'])) {
                $this->getPermissionUtils()->chgrp($fullPath);
            }
        } catch (\Exception $e) {
            $GLOBALS['log']->critical('Permission denied: unable to create the folder on the server - '.$fullPath);
        }

        return isset($result) ? $result : false;
    }