Rev 26326 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{tempfile}\alias{tempfile}\alias{tempdir}\title{Create Names for Temporary Files}\description{\code{tempfile} returns a vector of character strings which can be used asnames for temporary files.}\usage{tempfile(pattern = "file", tmpdir = tempdir())tempdir()}\arguments{\item{pattern}{a non-empty character vector giving the initial partof the name.}\item{tmpdir}{a non-empty character vector giving the directory name}}\value{For \code{tempfile} a character vector giving the names of possible(temporary) files. Note that no files are generated by\code{tempfile}.For \code{tempdir}, the path of the per-session temporary directory.}\details{If \code{pattern} has length greater than one then the result is of thesame length giving a temporary file name for each component of\code{pattern}.The names are very likely to be unique among calls to \code{tempfile}in an \R session and across simultaneous \R sessions. The filenames areguaranteed not to be currently in use.#ifdef unixThe file name is made of the pattern, the process number in hex and arandom suffix in hex. By default, the filenames will be in thedirectory given by \code{tempdir()}. This will be a subdirectory ofthe directory given by the environment variable \env{TMPDIR} if set,otherwise \code{"/tmp"}.#endif#ifdef windowsBy default, \code{tempdir()} gives a subdirectory of the first foundof the environment variables \env{TMP}, \env{TEMP} and \env{R\_USER}(see \code{\link{Rconsole}}) which points to a writeable directory.If the path to the directory contains a space in any of thecomponents, the path returned will use the shortnames version of thepath.#endif}\references{Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\emph{The New S Language}.Wadsworth \& Brooks/Cole.}\seealso{\code{\link{unlink}} for deleting files.}\examples{tempfile(c("ab", "a b c")) # give file name with spaces in!}\keyword{file}