safe_folder: Safely create a uniquely named folder.

Description Usage Arguments Value

View source: R/safe_folder.R

Description

When writing scripts that need to write to the local machine, we often need to create a unique (often temporary) directory.

This function attempts to create a directory of the given name - or "temp" if no name is given - but will avoid overwriting or recreating an already existing directory.

If a directory of the given name exists, it will instead attempt to create a variant of the given name.

Usage

1
safe_folder(target_name = "temp", target_path = ".")

Arguments

target_name

The folder name the function will try to create.

target_path

Where the folder should be created. Defaults to the current working directory (".").

Value

The function will return a list with three items.

x$result will be a boolean. TRUE on success and FALSE on failure.

x$details will be a character string explaining what occurred. Probably only interesting on failure.

x$full_path will be a character string giving the path of the created folder. Useful for automation where you need to know what folder was created.

On success, the given folder will also have been created in the target directory.


pocdata/pocr documentation built on Jan. 5, 2022, 9:54 a.m.