getFiles: Retrieve theme files

View source: R/utils.R

getFilesR Documentation

Retrieve theme files


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.


  pkg = "stationery",
  overwrite = FALSE,
  backup = overwrite,
  pkgdir = "theme",
  outputdir = "theme"



A file name vector. In stationery, this is typically retrieving logo images or theme files.


Package name, default "stationery"


Default FALSE, function returns TRUE, meaning "my work was done before." If TRUE, old file will be replaced.


Default is TRUE, if a file is to be overwritten, then a backup will be created with kutils::file.backup.


package directory name where files are found. Default is "theme" because that is used in stationery and related CRMDA packages. It is the name of a directory in the package's inst folder, the same place where R system.file looks for files and directories.


Default is same as pkgdir. A directory where file file will be copied within the current working directory.


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.


TRUE if succeeded, either a file existed before (and overwrite=FALSE) or a file was copied.


Paul Johnson<>


## 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)

stationery documentation built on May 29, 2024, 4:56 a.m.