conditionalDelete-character-character-method: Conditional Delete

Description Usage Arguments Value Author(s) References See Also Examples

Description

See conditionalDelete

Usage

1
2
3
## S4 method for signature 'character,character'
conditionalDelete(path, condition,
  content_only = FALSE, ...)

Arguments

path

character.

condition

character.

content_only

logical. Only relevant if path corresponds to a directory path. TRUE: only delete directory content, not the directory itself; FALSE: delete entire directory.

...

Further arguments to be passed to subsequent functions/methods.

Value

See method conditionalDelete-character-character-method

Author(s)

Janko Thyson janko.thyson@rappster.de

References

https://github.com/Rappster/filesystr

See Also

conditionalDelete

Examples

 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)

rappster/filesystr documentation built on May 26, 2019, 11:17 p.m.