mktemp: Create a temporary file securely

Description Usage Arguments Details Value Examples

View source: R/mktemp.R

Description

Creates a temporary file securely with a system call to mktemp. A version of mktemp from GNU coreutils or BSD is required.

Usage

1
mktemp(template = "file.XXXXXXXXXX", tmpdir = tempdir())

Arguments

template

the template, which must end with at least 3 'X's. Only alphanumeric characters, underscore and dots are allowed.

tmpdir

the containing temporary folder. Only alphanumeric characters, underscore and dots are allowed.

Details

R's tempfile function makes no guarantee against race conditions, where the same temp file could be generated by different R processes. This is a problem especially 26 *in parallel environments. By contrast, file names generated by mktemp are guaranteed to be unique.

Note that the file is created before the function returns and must be removed manually afterwards.

Value

the newly created file name

Examples

1
2
tmpfile <- mktemp()
file.remove(tmpfile)

xrobin/xavamess documentation built on June 15, 2021, 3:46 a.m.