Rev 54655 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/basename.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2009 R Core Development Team% Distributed under GPL 2 or later\name{basename}\alias{basename}\alias{dirname}\title{Manipulate File Paths}\description{\code{basename} removes all of the path up to and including the lastpath separator (if any).\code{dirname} returns the part of the \code{path} up to butexcluding the last path separator, or \code{"."} if there is no pathseparator.}\usage{basename(path)dirname(path)}\arguments{\item{path}{character vector, containing path names.}}\details{For \code{dirname} \link{tilde expansion} of the path is done.Trailing path separators are removed before dissecting the path,and for \code{dirname} any trailing file separators are removedfrom the result.}\section{Behaviour on Windows}{On Windows this will accept either \code{\\} or \code{/} as the pathseparator, but \code{dirname} will return a path using \code{/}(except if on a network share, when the leading \code{\\\\} will bepreserved). Expect these only to be able to handle completepaths, and not for example just a share or a drive.UTF-8-encoded dirnames not valid in the current locale can be used.}\note{These are not wrappers for the POSIX system functions of the samenames: in particular they do \strong{not} have the special handling ofthe path \code{"/"} and of returning \code{"."} for empty strings in\code{basename}.}\value{A character vector of the same length as \code{path}. A zero-lengthinput will give a zero-length output with no error.If an element of \code{path} is \code{\link{NA}}, so is the result.}\seealso{\code{\link{file.path}}, \code{\link{path.expand}}.}\examples{basename(file.path("","p1","p2","p3", c("file1", "file2")))dirname(file.path("","p1","p2","p3","filename"))}\keyword{file}