Skip to content

Filepath lenses #21

Description

@cfhammill

I was oggling r-lib/fs today and my goodness would filesystem lenses be amazing.

ext_l <- lens(view = fs::path_ext, set = fs::path_ext_set)
dirn_l <- lens(view = dirname, set = function(d, x){
  mapply(function(dir, rpl, pth) sub(dir, rpl, pth, fixed = TRUE)
    , dirname(d), x, d, SIMPLIFY = FALSE) 
})

with

  • basename
  • path_rel/path_abs
  • path2list/list2path

left as an exercise for the reader

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions