unlink
deletes the file(s) or directories specified by x
.
unlink(x, recursive = FALSE, force = FALSE)
path.expand
) is done on x
. If recursive = FALSE
directories are not deleted,
not even empty ones.
unix
On most platforms file includes symbolic links, fifos and
sockets. Prior to R 2.15.0 unlink(x, recursive = TRUE)
would
delete the contents of a directory target of a symbolic link: it now
only deletes the symbolic link (as unlink(x, recursive = FALSE)
always has).
Wildcard expansion is done by the internal code of
Sys.glob
. Wildcards never match a leading . in
the filename, and files . and .. will never be
considered for deletion.
unix
Wildcards will only be expanded if the system supports it. Most
systems will support not only * and ? but also character
classes such as [a-z] (see the man
pages for the system
call glob
on your OS). The metacharacters * ? [
can
occur in Unix filenames, and this makes it difficult to use
unlink
to delete such files (see file.remove
),
although escaping the metacharacters by backslashes usually works. If
a metacharacter matches nothing it is considered as a literal
character.
recursive = TRUE
might not be supported on all platforms, when it
will be ignored, with a warning: however there are no known current
examples.
Windows
Character classes such as [a-z] are supported. The
metacharacter [
can occur in Windows filenames, and this makes
it difficult to use unlink
to delete such files (see
file.remove
). If a wildcard matches
nothing it is considered as a literal character.
Windows cannot remove the current working directory, nor any file which is open nor any directory containing such a file.
UTF-8-encoded paths not valid in the current locale can be used.
file.remove
.