#' Create a folder for person files.
#' @description
#' This function creates a folder for person files in the directory
#' \code{folder_dir} if no folder gets overwritten or \code{overwrite = TRUE}.
#' The folder can be encrypted by specifying \code{password}.
#' @param password
#' The folder's password. Can be \code{NULL} for no password.
#' @param folder_dir
#' The directory for the folder. Set \code{folder_dir = "."} for the current
#' directory.
#' @param overwrite
#' If \code{overwrite = TRUE}, an existing folder in \code{folder_dir} gets
#' overwritten.
#' @return
#' Returns invisibly the created folder (which is an object of class
#' \code{personfiles}). The folder also is saved in \code{folder_dir}.
#' @examples
#' ### Create folder without password.
#' folder(password = NULL, folder_dir = tempdir(), overwrite = TRUE)
#' ### Create folder with password.
#' folder(password = "secret", folder_dir = tempdir(), overwrite = TRUE)
#' @export
folder <- function(password = NULL, folder_dir = ".", overwrite = FALSE) {
path <- personfiles_path(folder_dir = folder_dir)
if(file.exists(path) && !overwrite)
stop("Folder already exists.")
new_folder <- list()
class(new_folder) <- "personfiles"
cat("Folder created.\n")
if(!is.null(password))
new_folder <- folder_encrypt(folder_decrypted = new_folder,
password = password)
cat("Path:",path,"\n")
saveRDS(new_folder, path)
return(invisible(new_folder))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.