ncss-tech / soilReports

An R package that assists with the setup and operation of a collection of soil data summary, comparison, and evaluation reports. These reports are primarily used by USDA-NRCS soil scientists in both initial and update mapping.
15 stars 5 forks source link

region2/mu-comparison file.access(..., mode=4) fails #90

Open dylanbeaudette opened 6 years ago

dylanbeaudette commented 6 years ago

This is a more general problem with file.access() and UNC paths:

\\usda.net\NRCS\Home\CASON\NRCS\Dylan.Beaudette\Desktop\MU-comparison

It seems that the "Desktop" is migrated to this location as part of the transition to Windows 10.

Reading and writing files seems to work, however, testing for read access via file.access() does not work as expected. This is likely to only be a problem when input raster data are stored on a share with UNC path.

The affected code is:

accessible.inputs <- file.access(as.character(unlist(raster.list)), mode = 4) + 1 #file.access returns 0 for success and -1 for failure
if(any( accessible.inputs == 0 )) {
  unreadable.files <- names(which(accessible.inputs == 0))
  stop(paste0("The following input files either do not exist or are unreadable: \n", paste0(unreadable.files, collapse=", ")))
}

A reasonable solution is to test for an existing file (mode=0) as that seems to work.