getFiles {stationery} | R Documentation |
Retrieve theme files
Description
A wrapper for file.copy that retieves files from the dn = "theme" directory of a package. It ties in the file.backup function from kutils so that if a file is overwritten, then a backup copy is created, using the last modification time of the file in the backup file name.
Usage
getFiles(
fn,
pkg = "stationery",
overwrite = FALSE,
backup = overwrite,
pkgdir = "theme",
outputdir = "theme"
)
Arguments
fn |
A file name vector. In |
pkg |
Package name, default "stationery" |
overwrite |
Default FALSE, function returns TRUE, meaning "my work was done before." If TRUE, old file will be replaced. |
backup |
Default is TRUE, if a file is to be overwritten, then a backup will be created with kutils::file.backup. |
pkgdir |
package directory name where files are
found. Default is "theme" because that is used in
|
outputdir |
Default is same as |
Details
This was originally created because we wanted to protect user logo
and address files from accidental erasure. Now it has a little
more versatility because overwrite=TRUE
and
backup=TRUE
add a little bit of valuable functionality.
When a file is overwritten, it should never be lost if
backup=TRUE
.
Value
TRUE if succeeded, either a file existed before (and overwrite=FALSE) or a file was copied.
Author(s)
Paul Johnson<pauljohn@ku.edu>
Examples
## To demonstrate, we use a temporary directory. Usage of setwd is discouraged
## in examples, so this is a little bit more indirect than a real usage would be:
tdir <- tempdir()
list.files(file.path(tdir, "theme"))
getFiles("logo.pdf", pkg = "stationery", overwrite = TRUE, outputdir = file.path(tdir, "theme"))
list.files(file.path(tdir, "theme"))
getFiles("logo.pdf", pkg = "stationery", overwrite = TRUE, outputdir = file.path(tdir, "theme"),
backup = TRUE)
list.files(file.path(tdir, "theme"))
unlink(file.path(tdir, "theme"), recursive = TRUE)