overwrite_file: Check a file exists and, if so, prompt to overwrite

Description Usage Arguments Value Examples

View source: R/utils_files.R

Description

This function is a simple utility for checking whether a file exists and should be overwritten. 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 file does not exist and should be "overwritten" or TRUE if the user indicates they want to overwrite the file. FALSE if the user indicates they don't want to overwrite the file.

Examples

1
2
3
4
5
6
7
if (interactive()) {
  fs::dir_create("test-folder")
  fs::file_create("test-folder/test-file.R")
  if (overwrite_file("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.