file_delete: Delete Files

Description Usage Arguments Value Examples

View source: R/func_files.R

Description

This function is a wrapper around fs::file_delete(), with the a console-based confirmation and, if ask = TRUE, the user will be prompted to confirm the deletion.

Usage

1
file_delete(path, ask = FALSE)

Arguments

path

A character vector of the file path(s) to be deleted.

ask

Logical: FALSE by default. Should the user be prompted whether or not the file(s) should be deleted?

Value

The deleted file path(s) (invisibly).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
if (interactive()) {
  # Create multiple files -- not opening them
  jdtools::file_new_text("test-file_delete", open = FALSE)
  jdtools::file_new_r("test-file_delete", open = FALSE)
  jdtools::file_new_md("test-file_delete", open = FALSE)
  jdtools::file_new_js("test-file_delete", open = FALSE)

  # Just delete the text file
  file_delete(path = "test-file_delete.txt",
              ask = FALSE)

  # Ask about whether to delete the R file
  file_delete(path = "test-file_delete.R",
              ask = TRUE)

  # Ask about whether to delete the markdown and JavaScript files
  file_delete(path = c("test-file_delete.md", "test-file_delete.js"),
              ask = TRUE)
}

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