R/utils.R

Defines functions match_contents list_files

list_files <- function(path, filename) {
  files <- dir(path = path, pattern = filename, all.files = TRUE, full.names = TRUE)
  dirs <- dir.exists(files)
  files <- files[!dirs]
  files
}

match_contents <- function(f, contents, n, fixed) {
  if (is.null(contents)) {
    return(TRUE)
  }

  fc <- readLines(f, n)
  any(grepl(contents, fc, fixed = fixed))
}

Try the rprojroot package in your browser

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

rprojroot documentation built on Nov. 5, 2023, 5:06 p.m.