R/Directory.R

#' @export
#' @importFrom R6 R6Class
#' @importFrom fs dir_create link_create path
Directory <- R6Class(

    "Directory",

    inherit = FileSystemEntry,

    public = list(

        initialize = function(path, link = NULL) {
            super$initialize(path)

            if (is.null(link)) {
                dir_create(path)
            } else {
                dir_create(path_dir(path))
                link_create(link, path)
            }
        },

        dir = function(dirname, link = NULL) {
            Directory$new(path(super$path(), dirname), link)
        },

        file = function(filename) {
            File$new(path(super$path(), filename))
        }
    )
)
aviralg/experimentr documentation built on Jan. 9, 2022, 8:11 a.m.