Create directory

@param string $directory Directory path to create

@throws \Webiny\Component\Storage\StorageException
484579
protected function createDirectory($directory)
    {
        $umask = umask(0);
        $created = mkdir($directory, 0777, true);
        umask($umask);

        if (!$created) {
            throw new StorageException(StorageException::DIRECTORY_COULD_NOT_BE_CREATED, [$directory]);
        }
    }
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
            );
        }
    }
383835
public function ensureDirectory($directory)
	{
		if(!is_dir($directory))
		{
			$this->ensureDirectory(dirname($directory));
			echo "      mkdir ".strtr($directory,'\\','/')."\n";
			mkdir($directory);
		}
	}
523218
protected function createDir($dir)
    {
        if (!is_dir($dir) && !mkdir($dir, 0755, true)) {
            throw new \RuntimeException(
                sprintf('Unable to create cache directory %s, check permissions', $dir)
            );
        }

        if (!is_writable($dir)) {
            throw new BadPermissionException(
                sprintf('Cache directory %s is not writable, check permissions', $dir)
            );
        }
    }
775560
private function createDirectory($directory, $entry_name = NULL)
	{
		$directory = str_replace(DIRECTORY_SEPARATOR, '/', $directory);
		$directory = str_replace('\\', '/', $directory);
		$directory = str_replace('/',  '/', $directory);
		$directory = rtrim($directory, '/\\' . DIRECTORY_SEPARATOR);

		if (!file_exists($directory)) {
			$this->createDirectory(
				pathinfo($directory, PATHINFO_DIRNAME),
				$entry_name
			);

			if (!mkdir($directory)) {
				throw new \Exception(sprintf(
					'Cannot install, failure while creating requisite directory "%s"',
					$directory
				));
			}

		} else {
			if (!is_dir($directory)) {
				throw new \Exception(sprintf(
					'Cannot install, requisite path "%s" exists, but is not a directory',
					$directory
				));
			}

			if (!is_writable($directory)) {
				throw new \Exception(sprintf(
					'Cannot install, requisite directory "%s" is not writable',
					$directory
				));
			}
		}

		$this->map($directory, $entry_name);
	}
525110
public function loadDirectory($directory) {
        $iterator = new DirectoryIterator($directory);
        foreach($iterator as $file) {
            if($file->isFile() && ends_with($file->getFilename(), '.php')) {
                require $directory . '/' . $file->getFilename();
            }
        }
    }
133256
public function createDirectory($directory)
    {
        $result = @ftp_mkdir($this->connection, $directory);
        
        if ($result === false) {
            throw new Exception('Unable to create directory');
        }

        return $this;
    }
1094689
public static function setDirectoryCache($directory, $fileExtension = DirectoryCache::DEFAULT_EXTENSION)
    {
        self::$cacheImplementation = new DirectoryCache($directory, $fileExtension);
        self::$hasBeenCleared      = false;
    }
1138548
public function setDirectory ($directory) {
        if (strpos($directory, '/') !== 0) {
            throw new Exception\InvalidArgumentException('Directory name must be an absolute path.');
        }

        if (!is_dir($directory)) {
            throw new Exception\LogicException('Template directory does not exist.');
        }

        $this->directory = realpath($directory);
    }
1368369
public function setDataDirectory(string $directory)
    {
        if (!is_dir($directory)) {
            $exception = new StorageException(sprintf(StorageException::DIRECTORY_NOT_FOUND, $directory));
            $exception->setDirectory($exception);
            $exception->setProvider(static::class);
            throw $exception;
        }

        $this->dataDirectory = $directory;
    }
1175420
protected function createDirectory($directory)
    {
        $isCreated = file_exists($directory) || is_dir($directory) || mkdir($directory, 0777, true);
        
        if (!$isCreated)
            throw new RuntimeException('Cannot create directory ":dir" for generated classed', ['dir' => $directory]);
        
        return $this;
    }
238374
public static void createDirectory( File directory ) throws IOException {

		if( ! directory.exists()
				&& ! directory.mkdirs())
			throw new IOException( "The directory " + directory + " could not be created." );
	}
462807
protected function makeDirs($directory)
	{
		foreach ($directory as $path) {
			if (!$this->files->isDirectory($this->getPath($path))){
				$this->files->makeDirectory($this->getPath($path), 0777, true);
			}
		}
	}
876140
public static void mkdirs(File directory) throws CreateDirectoryException {
    if (directory.exists()) {
      // file exists and *is* a directory
      if (directory.isDirectory()) {
        return;
      }

      // file exists, but is not a directory - delete it
      if (!directory.delete()) {
        throw new CreateDirectoryException(
            directory.getAbsolutePath(),
            new FileDeleteException(directory.getAbsolutePath()));
      }
    }

    // doesn't exist. Create one
    if (!directory.mkdirs() && !directory.isDirectory()) {
      throw new CreateDirectoryException(directory.getAbsolutePath());
    }
  }
974946
public function emptyDir($directory)
    {
        [$fs, $directory] = $this->getFilesystemAndPath($directory);

        $fs->emptyDir($directory);
    }
1261626
protected function makeDir($directory)
	{
		if ( ! $this->files->isDirectory($this->getPath($directory)))
		{
			$this->files->makeDirectory($this->getPath($directory), 0777, true);
		}
	}
248094
def create_directory(directory):
    
    try:
        os.makedirs(directory)
    except OSError, e:
        if e.errno == errno.EEXIST and os.path.isdir(directory):
            pass

    return directory