dir.create2: Safe directory construction

Description Usage Arguments Details Value See Also Examples

View source: R/unlink2.R

Description

Create a directory with an error message if it does not succeed.

Usage

1
dir.create2(path, recursive = TRUE, ...)

Arguments

path, recursive, ...

Further arguments to pass to dir.create.

Details

This is primarily necessary to avoid incomprehensible errors when a directory cannot be created, usually due to insufficient permissions. We set recursive=TRUE by default for convenience.

Note that the presence of an existing directory at path will cause this function to fail. This is usually desirable in the context of basilisk.utils as stale directories should be unlink2ed beforehand.

Value

Either path is created or an error is raised. NULL is invisibly returned.

See Also

unlink2, for a similarly safe deletion function.

Examples

1
2
out <- tempfile()
dir.create2(out)

basilisk.utils documentation built on Jan. 29, 2021, 2 a.m.