# skbio.util.create_dir

`skbio.util.``create_dir`(dir_name, fail_on_exist=False, handle_errors_externally=False)

  Create a directory safely and fail meaningfully

  State: Experimental as of 0.4.0.

  Parameters:

  dir_name: string

  > name of directory to create

  fail_on_exist: bool, optional

  > if true raise an error if `dir_name` already exists

  handle_errors_externally: bool, optional

  > if True do not raise Errors, but return failure codes. This allows to handle errors locally and e.g. hint the user at a –force_overwrite options.

  Returns:

  return_value : int

  > These values are only returned if no error is raised:

  > - `0`: directory was safely created
  > - `1`: directory already existed
  > - `2`: a file with the same name exists
  > - `3`: any other unspecified `OSError`

  Notes

  Depending of how thorough we want to be we could add tests, e.g. for testing actual write permission in an existing dir.

  Examples

      >>> from skbio.util import create_dir
      >>> from os.path import exists, join
      >>> from tempfile import gettempdir
      >>> from os import rmdir
      >>> new_dir = join(gettempdir(), 'scikitbio')
      >>> create_dir(new_dir)
      0
      >>> exists(new_dir)
      True
      >>> rmdir(new_dir)