Retrieve the contents of the named xattr

get_xattr(path, name, follow_symlinks = TRUE)

Arguments

path

target path (file or dir); this is auto-expanded

name

xattr name to retrieve

follow_symlinks

if FALSE get xattr of the symlink vs the target it references

Note

You should really use get_xattr_raw()

Examples

# Create a temp file for the example tf <- tempfile(fileext = ".csv") write.csv(mtcars, tf) # has attributes? (shld be FALSE) has_xattrs(tf)
#> [1] FALSE
get_xattr(tf, "is.rud.setting")
#> character(0)
# set an attribute set_xattr(tf, "is.rud.setting.a", "first attribut") get_xattr(tf, "is.rud.setting.a")
#> [1] "first attribut"
get_xattr_size(tf, "is.rud.setting.a")
#> [1] 14
# shld be TRUE has_xattrs(tf)
#> [1] TRUE
set_xattr(tf, "is.rud.setting.b", "second attribute") get_xattr(tf, "is.rud.setting.b")
#> [1] "second attribute"
get_xattr_size(tf, "is.rud.setting.b")
#> [1] 16
# overwrite an attribute set_xattr(tf, "is.rud.setting.a", "first attribute") get_xattr(tf, "is.rud.setting.a")
#> [1] "first attribute"
get_xattr_size(tf, "is.rud.setting.a")
#> [1] 15
# see all the attributes list_xattrs(tf)
#> [1] "is.rud.setting.a" "is.rud.setting.b"
# data frame vs individual functions get_xattr_df(tf)
#> # A tibble: 2 x 3 #> name size contents #> <chr> <dbl> <list> #> 1 is.rud.setting.a 15 <raw [15]> #> 2 is.rud.setting.b 16 <raw [16]>
# remove attribute rm_xattr(tf, "is.rud.setting") get_xattr(tf, "is.rud.setting")
#> character(0)
# cleanup unlink(tf)