createTempDir: Create Temporary Directory

Description Usage Arguments Examples

Description

Create a temporary directory with a random name in a specific location.

Usage

1
2
createTempDir(parent_dir, temp_dir_prefix = "", length_random_suffix = 10,
  trailing_slash = TRUE)

Arguments

parent_dir

Location where the temporary direcotiry will be created.

temp_dir_prefix

Optional. String that will be used as prefix for the temporary directory.

length_random_suffix

Optional. Number of random chars that will be used as suffix. By default 10.

trailing_slash

Optional. Boolean indicating if a trailing slash should be added. By default TRUE.

Examples

1
2
3
4
5
6
7
8
9
some.function <- function(..., temp_folder = '/default/path'){
  temporary_folder = createTempDir(temp_folder,"prefix_str")
  print(temporary_folder)
  # this will remove the temporary folder at the end of function execution
  on.exit(unlink(temporary_folder,recursive = TRUE),add=TRUE)

  # Some code

}

fabarca/reutiles documentation built on May 16, 2019, 9:57 a.m.