with_dir: Execute Code in a Temporary Working Directory

View source: R/with_dir.R

with_dirR Documentation

Execute Code in a Temporary Working Directory

Description

This is a verbatim copy of withr::with_dir from of withr's version 2.4.1. I often need withr only to import withr::with_dir, which is a really simple function. So I just hijack withr::with_dir.

Usage

with_dir(new, code)

Arguments

new

The new working directory.

code

Code to execute in the temporary working directory.

Value

The results of the evaluation of the code argument.

See Also

Other operating system functions: clipboard_path(), file_copy(), file_save(), get_boolean_envvar(), get_run_r_tests(), is_installed(), is_r_package_installed(), is_success(), is_windows(), view(), vim(), wipe_tempdir()

Examples

temp_dir <- file.path(tempfile())
dir.create(temp_dir)
with_dir(temp_dir, getwd())

fritools documentation built on Nov. 19, 2023, 1:06 a.m.