dir_exists_prompt: Check a directory exists

Description Usage Arguments Value Examples

View source: R/utils_files.R

Description

This function is a simple utility for checking whether a directory exists. It is used internally with the file_new_* family of functions.

Usage

1

Arguments

.path

The path where an action is to be executed.

Value

LOGICAL; TRUE if the directory already exists or TRUE if the user indicates they want to create the directory (in which case it will be created in this function). FALSE if the directory does not exist and the user indicates they don't want to create it.

Examples

1
2
3
4
5
6
if (interactive()) {
  fs::dir_create("test-folder")
  if (dir_exists_prompt(here("test-folder/test-file.R"))) {
    fs::file_create("test-folder/test-file.R")
  }
}

jdtrat/jdtools documentation built on Dec. 20, 2021, 10:05 p.m.