file.splitpath(dir, fsep=dirSeparator(), platform=getPlatform())
The character string given by the argument
fsep
is used to split up a path name into its component directories (subdirectories)
and file name. For example, the Unix path name "/dir/subdir/file.ext" will
be spilt into this character vector: c("/dir", "subdir", "file.ext").
The function
file.path has the opposite purpose
of
file.splitpath. It combines strings containing
path components into a single path name with the appropriate directory
separator character(s).
This function is used by
dir.create to
create a list of the directories when recursively creating directories.
# find the wavelets PDF file
fpath <- list.files(path = getenv("SHOME"), full.names = T, recursive = T, type
= "file", pattern = "wavelets.*pdf")
fspath <- file.splitpath(fpath)
# get the file name
fspath[length(fspath)]
# get the directory containing the file
do.call("file.path", as.list(fspath[-length(fspath)]))