File: path_file.Rd

package info (click to toggle)
r-cran-fs 1.6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 744 kB
  • sloc: cpp: 1,288; ansic: 530; sh: 13; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,371 bytes parent folder | download | duplicates (3)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/path.R
\name{path_file}
\alias{path_file}
\alias{path_dir}
\alias{path_ext}
\alias{path_ext_remove}
\alias{path_ext_set}
\alias{path_ext<-}
\title{Manipulate file paths}
\usage{
path_file(path)

path_dir(path)

path_ext(path)

path_ext_remove(path)

path_ext_set(path, ext)

path_ext(path) <- value
}
\arguments{
\item{path}{A character vector of one or more paths.}

\item{ext, value}{The new file extension.}
}
\description{
\code{path_file()} returns the filename portion of the path, \code{path_dir()} returns
the directory portion. \code{path_ext()} returns the last extension (if any) for a
path. \code{path_ext_remove()} removes the last extension and returns the rest of
the path. \code{path_ext_set()} replaces the extension with a new extension. If
there is no existing extension the new extension is appended.
}
\details{
Note because these are not full file paths they return regular character
vectors, not \code{fs_path()} objects.
}
\examples{
path_file("dir/file.zip")

path_dir("dir/file.zip")

path_ext("dir/file.zip")

path_ext("file.tar.gz")

path_ext_remove("file.tar.gz")

# Only one level of extension is removed
path_ext_set(path_ext_remove("file.tar.gz"), "zip")
}
\seealso{
\code{\link[base:basename]{base::basename()}}, \code{\link[base:basename]{base::dirname()}}
}