Helper function for cleaning files created by resmush
Source:R/resmush_clean_dir.R
resmush_clean_dir.Rd
Use with caution. This would remove files from your computer.
Clean a directory (or a list of directories) of files created by
resmush_file()
.
Arguments
- dir
A character vector of full path names. See
list.files()
,path
argument.- suffix
Character, defaults to
"_resmush"
. Seeresmush_file()
.- recursive
Logical. Should the files to be deleted recurse into directories?
Examples
# \donttest{
# Simple example
png_file <- system.file("extimg/example.png", package = "resmush")
# Copy to a temporary file with a given suffix
suffix <- "_would_be_removed"
tmp_png <- file.path(
tempdir(),
paste0("example", suffix, ".png")
)
file.exists(tmp_png)
#> [1] FALSE
file.copy(png_file, tmp_png, overwrite = TRUE)
#> [1] TRUE
file.exists(tmp_png)
#> [1] TRUE
# This won't remove it
resmush_clean_dir(tempdir())
#> ℹ No files to clean in C:\Users\RUNNER~1\AppData\Local\Temp\RtmpaIt4HO with suffix "_resmush\\.".
file.exists(tmp_png)
#> [1] TRUE
# Need suffix
resmush_clean_dir(tempdir(), suffix = suffix)
#> ℹ Would remove 1 file:
#> → C:\Users\RUNNER~1\AppData\Local\Temp\RtmpaIt4HO/example_would_be_removed.png
file.exists(tmp_png)
#> [1] FALSE
# }