forked from r-lib/fs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.Rd
63 lines (55 loc) · 1.66 KB
/
delete.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/delete.R
\name{delete}
\alias{delete}
\alias{file_delete}
\alias{dir_delete}
\alias{link_delete}
\title{Delete files, directories, or links}
\usage{
file_delete(path)
dir_delete(path)
link_delete(path)
}
\arguments{
\item{path}{A character vector of one or more paths.}
}
\value{
The deleted paths (invisibly).
}
\description{
\code{file_delete()} and \code{link_delete()} delete file and links. Compared to
\link{file.remove} they always fail if they cannot delete the object rather than
changing return value or signalling a warning. If any inputs are
directories, they are passed to \code{dir_delete()}, so \code{file_delete()} can
therefore be used to delete any filesystem object.
\code{dir_delete()} will first delete the contents of the directory, then remove
the directory. Compared to \link{unlink} it will always throw an error if the
directory cannot be deleted rather than being silent or signalling a warning.
}
\examples{
\dontshow{.old_wd <- setwd(tempdir())}
# create a directory, with some files and a link to it
dir_create("dir")
files <- file_create(path("dir", letters[1:5]))
link <- link_create(path_abs("dir"), "link")
# All files created
dir_exists("dir")
file_exists(files)
link_exists("link")
file_exists(link_path("link"))
# Delete a file
file_delete(files[1])
file_exists(files[1])
# Delete the directory (which deletes the files as well)
dir_delete("dir")
file_exists(files)
dir_exists("dir")
# The link still exists, but what it points to does not.
link_exists("link")
dir_exists(link_path("link"))
# Delete the link
link_delete("link")
link_exists("link")
\dontshow{setwd(.old_wd)}
}