Rev 54876 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/tempfile.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2008 R Core Development Team% Distributed under GPL 2 or later\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(), fileext = "")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}\item{fileext}{a non-empty character vector giving the file extension}}\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.#ifdef windowsBoth will use backslash as the path separator.#endif}\details{The length of the result is the maximum of the lengths of the threearguments; values of shorter arguments are recycled.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.The file name is made by concatenating the path given by \code{tmpdir},the \code{pattern} string, a random string inhex, and a suffix of \code{fileext}.By default, \code{tmpdir} will be the directory given by\code{tempdir()}. This will be a subdirectory of the temporarydirectory found by the following rule. The environment variables\env{TMPDIR}, \env{TMP} and \env{TEMP} are checked in turn and thefirst found which points to a writable directory is used:#ifdef unixif none succeeds \file{/tmp} is used.#endif#ifdef windowsif none succeeds the value of \env{R_USER} (see\code{\link{Rconsole}}) is used. If the path to the directorycontains a space in any of the components, the path returned will usethe shortnames version of the path.#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{\donttest{tempfile(c("ab", "a b c")) # give file name with spaces in!tempfile("plot", fileext=c(".ps", ".pdf"))tempdir() # works on all platforms with a platform-dependent result}}\keyword{file}