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.
file_delete(path, ask = FALSE)
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? |
The deleted file path(s) (invisibly).
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) }