Skip to contents

For more information on how the full path is determined, see details.

Usage

cas_get_base_path(
  create_folder_if_missing = NULL,
  custom_path = NULL,
  custom_folder = NULL,
  index = FALSE,
  file_format = "html",
  ...
)

Arguments

create_folder_if_missing

Logical, defaults to NULL. If NULL, it will ask before creating a new folder. If TRUE, it will create it without asking.

custom_path

Defaults to NULL. If given, overrides all other inputs, and is returned as given.

custom_folder

Defaults to NULL. Folder name within the website folder is typically determined by file_format and either index or contents; if you prefer another option, different from both index and contents, you can set it using the custom_folder argument.

file_format

Defaults to html. Used to determine folder name, and internally to assume contents type when using functions such as cas_extract().

...

Passed to cas_get_options().

Value

Path to base folder. A character vector of length one of class fs_path.

Details

  • base_folder - path to the folder where all project files are expected to be stored. Can be retrieved with cas_get_base_folder(level = "base"), can be set for the whole session with cas_set_options(base_folder = fs::path(fs::path_temp(), "castarter").

  • project - project name, typically set with cas_set_options(project = "example_project)

  • website - website name, typically set with cas_set_options(website = "example_project)

  • a combination of file_format and either index, contents, or something different if set with the custom_folder argument.

Examples

set.seed(1)
cas_set_options(project = "example_project",
                website = "example_website", 
                base_folder = fs::path(fs::path_temp(), "castarter"))

cas_get_base_path(create_folder_if_missing = FALSE)
#>  Folder for contents files with file format html does not exist:
#>  /tmp/RtmprKtXJ9/castarter/example_project/example_website/html_contents
#> Warning: ! Base path returned, but the folder does not exist and has not been created.
#> /tmp/RtmprKtXJ9/castarter/example_project/example_website/html_contents

cas_get_base_path(file_format = "html", 
                  create_folder_if_missing = FALSE)
#>  Folder for contents files with file format html does not exist:
#>  /tmp/RtmprKtXJ9/castarter/example_project/example_website/html_contents
#> Warning: ! Base path returned, but the folder does not exist and has not been created.
#> /tmp/RtmprKtXJ9/castarter/example_project/example_website/html_contents

cas_get_base_path(file_format = "xml", 
                  create_folder_if_missing = FALSE)
#>  Folder for contents files with file format xml does not exist:
#>  /tmp/RtmprKtXJ9/castarter/example_project/example_website/xml_contents
#> Warning: ! Base path returned, but the folder does not exist and has not been created.
#> /tmp/RtmprKtXJ9/castarter/example_project/example_website/xml_contents

cas_get_base_path(index = TRUE,
                  create_folder_if_missing = FALSE)
#>  Folder for index files with file format html does not exist:
#>  /tmp/RtmprKtXJ9/castarter/example_project/example_website/html_index
#> Warning: ! Base path returned, but the folder does not exist and has not been created.
#> /tmp/RtmprKtXJ9/castarter/example_project/example_website/html_index