tempfile
Create Unique Names for Files
Description
Returns a vector of character strings that are virtually certain to be
unique filenames.
Usage
tempfile(pattern = "file", tmpdir = tempdir(), fileext = "")
tempdir()
Arguments
pattern |
a vector of character strings to form the beginnings of the returned
filenames.
|
tmpdir |
the base directory for the filenames.
|
fileext |
A string containing the filename extension.
|
Details
Remember that no file is created by function the tempfile.
The length of the vector in the result of tempfile depends on
the maximum value of the length of pattern and tmpdir.
Value
tempfile | returns a vector of character strings containing
the names of files that can be used as temporary files. (pattern
sets the first character(s) in each file name, and then each name is
appended by a generated number.) The names are virtually certain to be
unique from one call to the next. |
tempdir | returns the name of a directory in which
temporary file names are written. This directory is created at the
start of the session and at the end of the session, this directory is removed
along with all temporary files in it.
|
See Also
Examples
# Create a directory
tmpdir <- tempfile('foo')
dir.create(tmpdir)
# Create a file in that directory
tmpfile <- tempfile('bar', tmpdir)
cat('hello', file=tmpfile)