| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/io.R |
| 3 |
\name{read_all} |
| 4 |
\alias{read_all} |
| 5 |
\title{Read all text files and concatenate their content} |
| 6 |
\usage{ |
| 7 |
read_all(files, before = function(f, x) NULL, after = function(f, x) NULL) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{files}{A vector of file paths.} |
| 11 |
|
| 12 |
\item{before, after}{A function that takes one file path and its content as |
| 13 |
the input and returns values to be added before or after the content of the |
| 14 |
file. Alternatively, they can be constant values to be added.} |
| 15 |
} |
| 16 |
\value{ |
| 17 |
A character vector. |
| 18 |
} |
| 19 |
\description{ |
| 20 |
Read files one by one, and optionally add text before/after the content. Then |
| 21 |
combine all content into one character vector. |
| 22 |
} |
| 23 |
\examples{ |
| 24 |
# two files in this package |
| 25 |
fs = system.file("scripts", c("call-fun.R", "child-pids.sh"), package = "xfun") |
| 26 |
xfun::read_all(fs) |
| 27 |
|
| 28 |
# add file paths before file content and an empty line after content |
| 29 |
xfun::read_all(fs, before = function(f) paste("#-----", f, "-----"), after = "") |
| 30 |
|
| 31 |
# add constants |
| 32 |
xfun::read_all(fs, before = "/*", after = c("*/", "")) |
| 33 |
} |