Dear Stackoverflowers,
I am looking for a way to check the file permissions in the current folder (the one that can be obtained using getwd()) in the R language. I am working on a Unix platform and know that I can get file permission mode using file.info(), but I do not know how to check to which category (owner / group / rest) I belong and thus what specific rights I have.
A second question that I have is whether this can also be done cross-platform, so that this would work also on other platforms (most importantly on Windows).
Thank you very much for you help!
Thomas
file.access()
returns this information. So
file.access(".", 2)
tells you whether or not you can write to the current working directory. You can supply a vector of filenames/directories as appropriate.
Note that if there is a chance that permissions can change underneath you (i.e. multitasking system), you may be better off to just use try
and catch the error if you don't have permissions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With