Skip to content

Commit

Permalink
For mllg#267. Add backup option for checking file access, using the m…
Browse files Browse the repository at this point in the history
…ethod from 'R.utils::fileAccess()`
  • Loading branch information
westat-schneider committed Sep 4, 2024
1 parent 63e001f commit a2a9077
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions R/checkAccess.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ checkAccess = function(x, access = "") {

if ("r" %in% access || is.root) {
w = wf(file.access(x, 4L) != 0L)

if (length(w) > 0L) {
w = wf(
sapply(X = x, FUN = function(x_i) {
tryCatch({readBin(x_i, what = raw(), n = 1L); return(FALSE)},
error = function(e) return(TRUE))
})
)
}

if (length(w) > 0L)
return(sprintf("'%s' not readable", x[w]))
}
Expand Down

0 comments on commit a2a9077

Please sign in to comment.