getwd.Rd 1.6 KB
Newer Older
Radford Neal's avatar
Radford Neal committed
1 2
% File src/library/base/man/getwd.Rd
% Part of the R package, http://www.R-project.org
3
% Copyright 1995-2011 R Core Team
Radford Neal's avatar
Radford Neal committed
4 5 6 7 8 9 10 11 12 13 14
% Distributed under GPL 2 or later

\name{getwd}
\alias{getwd}
\alias{setwd}
\title{Get or Set Working Directory}
\usage{
getwd()
setwd(dir)
}
\arguments{
Radford Neal's avatar
Radford Neal committed
15
  \item{dir}{A character string: \link{tilde expansion} will be done.}
Radford Neal's avatar
Radford Neal committed
16 17
}
\description{
Radford Neal's avatar
Radford Neal committed
18
  \code{getwd} returns an absolute filepath representing the current
Radford Neal's avatar
Radford Neal committed
19 20 21 22
  working directory of the \R process; \code{setwd(dir)} is used to set
  the working directory to \code{dir}.
}
\note{
Radford Neal's avatar
Radford Neal committed
23 24 25 26 27
  Note that the return value is said to be \strong{an} absolute
  filepath: there can be more than one representation of the path to a
  directory and on some OSes the value returned can differ after
  changing directories and changing back to the same directory (for
  example if symbolic links have been traversed).
Radford Neal's avatar
Radford Neal committed
28
}
Radford Neal's avatar
Radford Neal committed
29

Radford Neal's avatar
Radford Neal committed
30 31
\seealso{
  \code{\link{list.files}} for the \emph{contents} of a directory.
Radford Neal's avatar
Radford Neal committed
32 33
  
  \code{\link{normalizePath}} for a \sQuote{canonical} path name.
Radford Neal's avatar
Radford Neal committed
34
}
Radford Neal's avatar
Radford Neal committed
35

Radford Neal's avatar
Radford Neal committed
36
\value{
Radford Neal's avatar
Radford Neal committed
37
  \code{getwd} returns a character string or \code{NULL} if the working
Radford Neal's avatar
Radford Neal committed
38
  directory is not available.
Radford Neal's avatar
Radford Neal committed
39 40 41
  On Windows the path returned will use \code{/} as the path separator
  and be encoded in UTF-8.  The path will not have a trailing \code{/}
  unless it is the root directory (of a drive or share on Windows).
Radford Neal's avatar
Radford Neal committed
42 43
  
  \code{setwd} returns the current directory before the change,
Radford Neal's avatar
Radford Neal committed
44 45
  invisibly and with the same conventions as \code{getwd}.  It will give
  an error if it does not succeed (including if it is not implemented).
Radford Neal's avatar
Radford Neal committed
46
}
Radford Neal's avatar
Radford Neal committed
47

Radford Neal's avatar
Radford Neal committed
48 49 50 51 52
\examples{
(WD <- getwd())
if (!is.null(WD)) setwd(WD)
}
\keyword{utilities}