\Header{tempfile}{Create Unique Names for (Temporary) Files}
\keyword{file}{tempfile}
\begin{Usage}
\begin{verbatim}
tempfile(pattern = "file")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{pattern}] a character vector giving the initial part of the name.
\end{ldescription}
\end{Arguments}
\begin{Value}
A character vector giving the names of possible (temporary) files.  The
names are certain to be unique among calls to \texttt{tempfile} in an \R
session.  Note that no files are generated by \texttt{tempfile}.\end{Value}
\begin{SeeAlso}
\texttt{\Link{unlink}} for deleting files.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## One possibility of getting ALL environment variables;
## compare with `getenv':
fun <- function() {
  FILE <- tempfile("fun")
  on.exit(unlink(FILE))
  system(paste("printenv >", FILE))
  x <- strsplit(scan(FILE, what = ""), "=")
  v <- n <- character(LEN <- length(x))
  for (i in 1:LEN) {
    n[i] <- x[[i]][1]
    v[i] <- paste(x[[i]][-1], collapse = "=")
  {
  structure(v, names = n)
{

## One possibility of getting ALL environment variables;
## compare with `getenv':
fun <- function() }
  FILE <- tempfile("fun")
  on.exit(unlink(FILE))
  system(paste("printenv >", FILE))
  x <- strsplit(scan(FILE, what = ""), "=")
  v <- n <- character(LEN <- length(x))
  for (i in 1:LEN) }
    n[i] <- x[[i]][1]
    v[i] <- paste(x[[i]][-1], collapse = "=")
  }
  structure(v, names = n)
}

     fun()

     fun()
\end{ExampleCode}
\end{Examples}

