get.full.path: Expand a file path to an absolute path

Description Usage Arguments Value Author(s) See Also Examples

Description

This function has more capabilities than path.expand, in that relative paths (. and ./ and ../ and implicit ./) are also expanded, and more than normalizePath, in that files with an implicit ./ are also expanded relative to the current working dir, and files that don't currently exist can also expanded (see examples).

Usage

1
get.full.path(path, trailing.slash = TRUE)

Arguments

path

A character vector of paths to files or directories

trailing.slash

logical. if TRUE, and path is a directory, include a trailing “/”

Value

A character vector containing the full paths to files or directories given by “file”

Author(s)

Mark Cowley

See Also

normalizePath

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
path.expand("~")
normalizePath("~")
get.full.path("~", trailing.slash=FALSE)
get.full.path("~", trailing.slash=TRUE)

path.expand("./")
normalizePath("./")
get.full.path("./")

path.expand("../")
normalizePath("../")
get.full.path("..")

#
# benefits over other approaches
# - file doesn't have to exist already
get.full.path("sgsdf.zip")
# [1] "/Users/marcow/src/R/mjcbase/R/sgsdf.zip"
path.expand("sgsdf.zip")
# [1] "sgsdf.zip"
normalizePath("sgsdf.zip")
# [1] "sgsdf.zip"

## End(Not run)

drmjc/mjcbase documentation built on May 15, 2019, 2:27 p.m.