#' sbox_functions()
#' ------
#' Given a dir, create fs:path ------------------
#'
#' @param dir (character).
#' @return fs:path.
#' @export
sbox_create_path <- function(dir="tmp") path <-fs::path(dir)
#' ---------
#' Create tmp directory for soapbox.
#'
#' @param path (character) relative dir of tmp directory.
#' @return null
#' @export
sbox_create_dir <- function(path="tmp") {
# if dir exists, remove
if (fs::is_dir(path)) fs::dir_delete(path)
# create tmp dir
fs::dir_create(path)
}
#' ---------
#' Delete tmp (soapbox) directory.
#' @param path (character) dir of tmp directory.
#' @return null
#' @export
sbox_delete_dir <- function(path) fs::dir_delete(path)
#' ---------
#' List files in tmp (soapbox) directory.
#'
#' @param path (character) dir of tmp directory.
#' @return null
#' @export
sbox_ls_files <- function(path) fs::dir_ls(path)
#' ----------
#' Create a few files in tmp (sandbox) directory.
#' @param (character) dir (path) of tmp directory.
#' @return null
#' @export
sbox_create_files <- function(dir="tmp"){
# add files
fs::file_touch(fs::path(dir,"000001_testA"))
fs::file_touch(fs::path(dir,"000002_testB"))
fs::file_touch(fs::path(dir,"000003_testC"))
fs::file_touch(fs::path(dir,"000004_testD"))
fs::file_touch(fs::path(dir,"000005_testE"))
}
#' Tests to see that tmp (sandbox) is properly configured.
#' @param (character) dir (path) of tmp directory.
#' @return null
#' @export
sbox_test_files <- function(dir="tmp") {
# tests structure is correct
if (fs::is_file(path(dir,"000001_testA"))) print ("passes")
if (!fs::is_file(path(dir,"junk"))) print ("passes")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.