unlink2: Safe file deletion

Description Usage Arguments Details Value See Also Examples

View source: R/unlink2.R

Description

Delete files or directories with an error message if it does not succeed.

Usage

1
unlink2(x, recursive = TRUE, force = TRUE, ...)

Arguments

x, recursive, force, ...

Further arguments to pass to unlink.

Details

This is primarily necessary to avoid incomprehensible errors when a directory containing a stale environment or installation is not successfully deleted. We set recursive=TRUE by default for convenience; we also set force=TRUE by default to avoid difficulties due to rogue permissions.

Value

Either all x are successfully deleted or an error is raised. NULL is invisibly returned.

See Also

dir.create2, for a similarly safe directory creation function.

Examples

1
2
3
4
5
out <- tempfile()
unlink2(out) # no error from deleting non-existent file.

write(file=out, "whee")
unlink2(out)

LTLA/basilisk.utils documentation built on June 10, 2021, 8:41 p.m.