Description Usage Arguments Author(s) References See Also Examples
Deletes file system ressource based on a condition.
1 | conditionalDelete(path, condition, content_only = FALSE, ...)
|
path |
Signature argument. Object containing file system location information. |
condition |
Signature argument. Object containing condition information. |
content_only |
|
... |
Further arguments to be passed to subsequent functions/methods. |
Janko Thyson janko.thyson@rappster.de
https://github.com/Rappster/filesystr
conditionalDelete-character-method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Not run:
## Example content //
path <- file.path(tempdir(), "conditionalDelete/dir")
dir.create(path, recursive = TRUE, showWarnings = FALSE)
file.create(file.path(path, paste0("file", 1:3)))
## Delete file if its in a directory that is a subdirectory of
## the temp directory //
fpath <- file.path(path, "file1")
conditionalDelete(path = fpath, condition = basename(tempdir()))
file.exists(fpath)
file.exists(path)
## When condition is not met //
fpath <- file.path(path, "file2")
conditionalDelete(path = fpath, condition = "abcd")
file.exists(fpath)
## Delete *content* of directory if its a subdirectory of the temp directory //
conditionalDelete(path = path, condition = basename(tempdir()),
content_only = TRUE)
file.exists(path)
## Delete directory if its a subdirectory of the temp directory //
conditionalDelete(path = path, condition = basename(tempdir()))
file.exists(path)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.