unlink2: Safe file deletion

View source: R/unlink2.R

unlink2R Documentation

Safe file deletion

Description

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

Usage

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

out <- tempfile()
unlink2(out) # no error from deleting non-existent file.

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


LTLA/basilisk.utils documentation built on June 26, 2022, 4:06 a.m.