Creates a directory, yields to the caller, and removes that directory
       if an exception is thrown.
490117
def remove_on_exception(dirname, remove=True):
    """"""
    os.makedirs(dirname)
    try:
        yield
    except:
        if remove:
            shutil.rmtree(dirname, ignore_errors=True)
        raise
1176112
final AbstractSingleFileObjectStore.Directory makeDirectory(int minimumNodeSize,
                                                                long directoryRootByteAddress,
                                                                long directoryRootLength)
                    throws ObjectManagerException {
        return new Directory(minimumNodeSize,
                             directoryRootByteAddress,
                             directoryRootLength);
    }
272716
public final void removeDirectory(final File directory) {
        try {
            FileUtils.deleteDirectory(directory);
        } catch (IOException e) {
            LOGGER.error("Unable to delete directory '{}'", directory);
        }
    }
497376
public static void checkDirectory(File directory) {
        if (!(directory.exists() || directory.mkdirs())) {
            throw new ReportGenerationException(
                    String.format("Can't create data directory <%s>", directory.getAbsolutePath())
            );
        }
    }
520790
public function rmdirR($dir)
    {
        $finder = $this->finder->create();
        $files = $finder->notRecursive()->find($dir);
        foreach ($files as $file) {
            if (! $file->isExists()) continue;

            if ($file->isDir()) {
                $this->rmdirR("{$file}/*");
                if ($file->isWritable()) {
                    rmdir($file);
                } else {
                    throw new Exception("Can not delete this directory. -> {$file}");
                }
            } else {
                if ($file->isWritable()) {
                    unlink($file);
                } else {
                    throw new Exception("Can not delete this file. -> {$file}");
                }
            }
        }
    }
145839
public static void recursivelyDeleteDirectory(File directory) throws IOException {
    if (!directory.exists()) {
      return;
    }
    checkArgument(directory.isDirectory(), "Cannot recursively delete a non-directory");
    walkFileTree(directory.toPath(), new DeletionFileVisitor());
  }
238374
public static void createDirectory( File directory ) throws IOException {

		if( ! directory.exists()
				&& ! directory.mkdirs())
			throw new IOException( "The directory " + directory + " could not be created." );
	}
720485
private static void createDirectory(Path path) throws IOException {
		try {
			Files.createDirectory(path);
		} catch (FileAlreadyExistsException e) {
			if (!Files.isDirectory(path)) {
				throw e;
			}
		}
	}
441675
def ensure_dir(dirname):
  
  try:
    # Tries to create the directory
    os.makedirs(dirname)
  except OSError:
    # Check that the directory exists
    if os.path.isdir(dirname): pass
    else: raise
33905
public static FileCreationState newDirectory(final File dir)
	{
		FileCreationState fileCreationState = FileCreationState.ALREADY_EXISTS;
		// If the directory does not exists
		if (!dir.exists())
		{ // then
			fileCreationState = FileCreationState.FAILED;
			// create it...
			if (dir.mkdir())
			{
				fileCreationState = FileCreationState.CREATED;
			}
		}
		return fileCreationState;
	}
1092244
public static void createDirectory(Path dir, String dirDesc)
    {
        try
        {
            Files.createDirectories(dir);
        }
        catch (IOException ex)
        {
            throw new WindupException("Error creating " + dirDesc + " folder: " + dir.toString() + " due to: " + ex.getMessage(), ex);
        }
    }
48767
def create_dir_unless_exists(*args):
    """"""
    path = os.path.join(*args)
    if not os.path.isdir(path):
        os.makedirs(path)
536155
def create_output_directory(cls, outdir):
        """"""
        cls.PATH = outdir
        try:
            os.mkdir(outdir)
        except FileExistsError:
            pass
1353157
def create_files(filedef, cleanup=True):
    
    cwd = os.getcwd()
    tmpdir = tempfile.mkdtemp()
    try:
        Filemaker(tmpdir, filedef)
        if not cleanup:  # pragma: nocover
            pass
            # print("TMPDIR =", tmpdir)
        os.chdir(tmpdir)
        yield tmpdir
    finally:
        os.chdir(cwd)
        if cleanup:  # pragma: nocover
            shutil.rmtree(tmpdir, ignore_errors=True)
35413
function createDir (directoryToCreate) {
  return new Promise((resolve, reject) => {
    mkdirp(directoryToCreate, (err) => {
      if (err) {
        return reject(new Error(err));
      }

      return resolve();
    });
  });
}
1127625
protected function wipeExistingDirectory()
    {
        if ($this->wipe === true && $this->directory != '/' && is_dir($this->directory)) {
            $cmd = 'rm -Rf "%s*"';
            $success = $this->phpci->executeCommand($cmd, $this->directory);

            if (!$success) {
                throw new \Exception(Lang::get('failed_to_wipe', $this->directory));
            }
        }
    }
428048
function() {
        var items = _utils.getArgArray(arguments);
        if (items.length === 0) {
            throw new Error('no folders specified to create');
        }
        items.forEach(function(item) {
            try {
                _fs.mkdirSync(item);
            } catch (e) {
                // Eat the exception.
            }
        });
    }