ensureDirectory: Create Directory

Description Usage Arguments Author(s) References See Also Examples

Description

Creates directory/directories. Basically, an S4 interface to dir.create.

Usage

1
ensureDirectory(path, strict, ...)

Arguments

path

Signature argument. Object containing directory information.

strict

logical. Should certain conditions trigger an error (TRUE) or simply result in a return value of FALSE (FALSE, default).

...

Further arguments to be passed to: dir.create.

Author(s)

Janko Thyson janko.thyson@rappster.de

References

https://github.com/Rappster/filesystr

See Also

ensureDirectory-character-method dir.create

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: 

## Auxiliary functions //
.carefulCleanup <- function(x, pattern=basename(tempdir())) {
  out <- sapply(x, function(ii) {
    out <- NA
    if (grepl(pattern, ii)) {
      out <- unlink(ii, recursive=TRUE, force=TRUE)
    }        
    out
  })
  invisible(out)
}

## Example content //
path <- file.path(tempdir(), "ensureDirectory")
sapply(path, dir.create, recursive=TRUE, showWarnings=FALSE)

path <- file.path(path, letters[1:3])
ensureDirectory(path = path)

## If directory already exists //
ensureDirectory(path = path)

## Clean up //
.carefulCleanup(x = path)
  


## End(Not run)

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