Debian Codegraph @

man/file_temp.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/temp.R
3 \name{file_temp}
4 \alias{file_temp}
5 \alias{file_temp_push}
6 \alias{file_temp_pop}
7 \alias{path_temp}
8 \title{Create names for temporary files}
9 \usage{
10 file_temp(pattern = "file", tmp_dir = tempdir(), ext = "")
11
12 file_temp_push(path)
13
14 file_temp_pop()
15
16 path_temp(...)
17 }
18 \arguments{
19 \item{pattern}{A character vector with the non-random portion of the name.}
20
21 \item{tmp_dir}{The directory the file will be created in.}
22
23 \item{ext}{The file extension of the temporary file.}
24
25 \item{path}{A character vector of one or more paths.}
26
27 \item{...}{Additional paths appended to the temporary directory by \code{path()}.}
28 }
29 \description{
30 \code{file_temp()} returns the name which can be used as a temporary file.
31 }
32 \details{
33 \code{file_temp_push()} can be used to supply deterministic entries in the
34 temporary file stack. This can be useful for reproducibility in like example
35 documentation and vignettes.
36
37 \code{file_temp_pop()} can be used to explicitly remove an entry from the
38 internal stack, however generally this is done instead by calling
39 \code{file_temp()}.
40
41 \code{path_temp()} constructs a path within the session temporary directory.
42 }
43 \examples{
44 \dontshow{file_temp_push("/tmp/filedd461c46df20")}
45
46 path_temp()
47 path_temp("does-not-exist")
48
49 file_temp()
50 file_temp(ext = "png")
51 file_temp("image", ext = "png")
52
53
54 # You can make the temp file paths deterministic
55 file_temp_push(letters)
56 file_temp()
57 file_temp()
58
59 # Or explicitly remove values
60 while (!is.null(file_temp_pop())) next
61 file_temp_pop()
62 }