Skip to contents

This generic function takes a directory and file name then checks to make sure they exist. The parameter check_mode will also test to make sure the file is readable (default) or writeable (check_mode = "write"). By default it will return an error if the file doesn't exist but with create = TRUE it will create an empty file with appropriate permissions.

Usage

get_file_path(
  directory,
  file_name = NULL,
  ext = NULL,
  check_mode = "read",
  create = NULL,
  file_name_regexp = NULL,
  selection_method = "modification_date"
)

Arguments

directory

The file directory

file_name

The file name (with extension if not supplied to ext)

ext

The extension (type of the file) - optional

check_mode

The mode passed to fs::file_access(), defaults to "read" to check that you have read access to the file

create

Optionally create the file if it doesn't exists, the default is to only create a file if we set check_mode = "write"

file_name_regexp

A regular expression to search for the file name if this is used file_name should not be, it will return the most recently created file using find_latest_file()

selection_method

Passed only to find_latest_file(), will select the file based on latest modification date (default) or file name

Value

The full file path, an error will be thrown if the path doesn't exist or it's not readable