assertions-file.RdUseful test related to files
is.dir(path)
is.writeable(path)
is.readable(path)
has_extension(path, ext)see_if(is.dir(1))
#> [1] FALSE
#> attr(,"msg")
#> [1] "path is not a string (a length one character vector)."
tmp <- tempfile()
see_if(file.exists(tmp))
#> [1] FALSE
#> attr(,"msg")
#> [1] "Path '/tmp/RtmpdT5P7V/file3b7804545bdb5' does not exist"
see_if(is.dir(tmp))
#> [1] FALSE
#> attr(,"msg")
#> [1] "Path '/tmp/RtmpdT5P7V/file3b7804545bdb5' does not exist"
writeLines("x", tmp)
see_if(file.exists(tmp))
#> [1] TRUE
see_if(is.dir(tmp))
#> [1] FALSE
#> attr(,"msg")
#> [1] "Path '/tmp/RtmpdT5P7V/file3b7804545bdb5' is not a directory"
see_if(is.writeable(tmp))
#> [1] TRUE
see_if(is.readable(tmp))
#> [1] TRUE
unlink(tmp)
see_if(is.readable(tmp))
#> [1] FALSE
#> attr(,"msg")
#> [1] "Path '/tmp/RtmpdT5P7V/file3b7804545bdb5' does not exist"