new_file: Create new files

View source: R/new_file.R

new_fileR Documentation

Create new files

Description

A convience wrapper around 'fs::file_create()' and 'fs::file_copy()' to create new files, and (defaultly) open them in an editor.

Usage

new_file(
  path,
  open = TRUE,
  template = NULL,
  create_dir = TRUE,
  overwrite = NULL
)

Arguments

path

Path of the file to create.

open

If 'TRUE' (the default) open the file.

template

A template file to copy.

create_dir

If 'TRUE' (the default) will create missing directories.

overwrite

When 'NULL' (the default) will warn and prompt the user if attempting to overwrite, set to 'TRUE' to force overwrite or 'FALSE' to not overwrite.

Details

This function is a replacement for 'rstudioapi::documentNew()', which only allows you to create files of the type 'r', 'rmarkdown' and 'sql'. Instead, 'new_file()' allows you to create any empty file of any type, or use an existing file as a template, and assuming in an interactive session to open that file in an editor.

Value

The path to the new file (invisibly).


mattkerlogue/mattR documentation built on July 11, 2024, 3:17 p.m.