R/print_file.R

Defines functions print_file

Documented in print_file

#' Print Contents of Text File
#'
#' Prints all contents of text file.
#'
#' @param path \code{character} file path of text file.
#'
#' @export
#' 
#' @return prints contents of file as a side effect.
#' 
#' @examples
#' # create empty file.
#' fp <- file.path(tempdir(), "tester")
#' file.create(fp)
#' 
#' # append lines to Dockerfile.
#' write_lines_to_file("# no nonsense", filepath = fp)
#' 
#' print_file(fp)
print_file <- function(path) {
  # read text from file.
  query <- readChar(path, file.info(path)$size)
  # print text to console.
  cat(query)
}

Try the dockr package in your browser

Any scripts or data that you put into this service are public.

dockr documentation built on Dec. 20, 2019, 5:06 p.m.