| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/list.R |
| 3 |
\name{dir_ls} |
| 4 |
\alias{dir_ls} |
| 5 |
\alias{dir_map} |
| 6 |
\alias{dir_walk} |
| 7 |
\alias{dir_info} |
| 8 |
\title{List files} |
| 9 |
\usage{ |
| 10 |
dir_ls( |
| 11 |
path = ".", |
| 12 |
all = FALSE, |
| 13 |
recurse = FALSE, |
| 14 |
type = "any", |
| 15 |
glob = NULL, |
| 16 |
regexp = NULL, |
| 17 |
invert = FALSE, |
| 18 |
fail = TRUE, |
| 19 |
..., |
| 20 |
recursive |
| 21 |
) |
| 22 |
|
| 23 |
dir_map( |
| 24 |
path = ".", |
| 25 |
fun, |
| 26 |
all = FALSE, |
| 27 |
recurse = FALSE, |
| 28 |
type = "any", |
| 29 |
fail = TRUE |
| 30 |
) |
| 31 |
|
| 32 |
dir_walk( |
| 33 |
path = ".", |
| 34 |
fun, |
| 35 |
all = FALSE, |
| 36 |
recurse = FALSE, |
| 37 |
type = "any", |
| 38 |
fail = TRUE |
| 39 |
) |
| 40 |
|
| 41 |
dir_info( |
| 42 |
path = ".", |
| 43 |
all = FALSE, |
| 44 |
recurse = FALSE, |
| 45 |
type = "any", |
| 46 |
regexp = NULL, |
| 47 |
glob = NULL, |
| 48 |
fail = TRUE, |
| 49 |
... |
| 50 |
) |
| 51 |
} |
| 52 |
\arguments{ |
| 53 |
\item{path}{A character vector of one or more paths.} |
| 54 |
|
| 55 |
\item{all}{If \code{TRUE} hidden files are also returned.} |
| 56 |
|
| 57 |
\item{recurse}{If \code{TRUE} recurse fully, if a positive number the number of levels |
| 58 |
to recurse.} |
| 59 |
|
| 60 |
\item{type}{File type(s) to return, one or more of "any", "file", "directory", |
| 61 |
"symlink", "FIFO", "socket", "character_device" or "block_device".} |
| 62 |
|
| 63 |
\item{glob}{A wildcard aka globbing pattern (e.g. \verb{*.csv}) passed on to \code{\link[=grep]{grep()}} to filter paths.} |
| 64 |
|
| 65 |
\item{regexp}{A regular expression (e.g. \verb{[.]csv$}) passed on to \code{\link[=grep]{grep()}} to filter paths.} |
| 66 |
|
| 67 |
\item{invert}{If \code{TRUE} return files which do \emph{not} match} |
| 68 |
|
| 69 |
\item{fail}{Should the call fail (the default) or warn if a file cannot be |
| 70 |
accessed.} |
| 71 |
|
| 72 |
\item{...}{Additional arguments passed to \link{grep}.} |
| 73 |
|
| 74 |
\item{recursive}{(Deprecated) If \code{TRUE} recurse fully.} |
| 75 |
|
| 76 |
\item{fun}{A function, taking one parameter, the current path entry.} |
| 77 |
} |
| 78 |
\description{ |
| 79 |
\code{dir_ls()} is equivalent to the \code{ls} command. It returns filenames as a |
| 80 |
named \code{fs_path} character vector. The names are equivalent to the values, |
| 81 |
which is useful for passing onto functions like \code{purrr::map_dfr()}. |
| 82 |
|
| 83 |
\code{dir_info()} is equivalent to \code{ls -l} and a shortcut for |
| 84 |
\code{file_info(dir_ls())}. |
| 85 |
|
| 86 |
\code{dir_map()} applies a function \code{fun()} to each entry in the path and returns |
| 87 |
the result in a list. |
| 88 |
|
| 89 |
\code{dir_walk()} calls \code{fun} for its side-effect and returns the input \code{path}. |
| 90 |
} |
| 91 |
\examples{ |
| 92 |
\dontshow{.old_wd <- setwd(tempdir())} |
| 93 |
dir_ls(R.home("share"), type = "directory") |
| 94 |
|
| 95 |
# Create a shorter link |
| 96 |
link_create(system.file(package = "base"), "base") |
| 97 |
|
| 98 |
dir_ls("base", recurse = TRUE, glob = "*.R") |
| 99 |
|
| 100 |
# If you need the full paths input an absolute path |
| 101 |
dir_ls(path_abs("base")) |
| 102 |
|
| 103 |
dir_map("base", identity) |
| 104 |
|
| 105 |
dir_walk("base", str) |
| 106 |
|
| 107 |
dir_info("base") |
| 108 |
|
| 109 |
# Cleanup |
| 110 |
link_delete("base") |
| 111 |
\dontshow{setwd(.old_wd)} |
| 112 |
} |