Skip to content

file.access() on network (mounted) drive on Windows Vista?

1 message · Henrik Bengtsson

#
Hi,

I have a writable and readable file on a small network file system
(Cisco NSLU2 Unslung; non-NTFS) that I access via a mounted drive on
Windows Vista.  My problem could be due to a "funny" file
system/server, but here it goes:
[1] "Hello world!"
size isdir mode               mtime               ctime
Q:/foo.txt   14 FALSE  666 2008-11-26 11:45:53 2008-11-26 11:45:53
                         atime exe
Q:/foo.txt 2008-11-26 11:45:57  no

The mode == 666 reported by file.info() indicates that it is readable
& writable by all users.  This is also what Windows Vista file
properties reports.  So far so good.  However, when I use
file.access() to test for file permissions, I get:
Q:/foo.txt
         0
Q:/foo.txt
        -1
Q:/foo.txt
        -1
Q:/foo.txt
        -1

I obviously can write to and read from the file, and this is what
file.info()$mode says too.  However, file.access() tells a different
story.  More troubleshooting: When I log into the file server and do:

# chmod ugo-w foo.txt
# ls -l foo.txt
-r-xr-----    1 admin    everyone       14 Nov 26 11:48 foo.txt

The changes in permission are seen by file.info():
size isdir mode               mtime               ctime
Q:/foo.txt   14 FALSE  444 2008-11-26 11:48:50 2008-11-26 11:48:50
                         atime exe
Q:/foo.txt 2008-11-26 11:56:40  no

The output from file.access() remains the same though.
File modes are probably only useful on NTFS file systems, and it
     seems all three digits refer to the file's owner. The
     execute/search bits are set for directories, and for files based
     on their extensions (e.g., '.exe', '.com', '.cmd' and '.bat'
     files).  'file.access' will give a more reliable view of
     read/write access availability to the R process.
this a feature or a bug?

I need a cross-platform test for file permissions, and I am looking
for safer workaround.  For instance, could it be that a zero result
from file.access() can be trusted, but a -1 could occur either from a
true lack of permission as well as a failure to test for the
permission?  If that would be case, I could try other measures (e.g.
try to open the file) whenever I receive a -1 before throwing an
exception.

Any feedback or suggestions would be great.

Thanks

/Henrik
R version 2.8.0 Patched (2008-10-21 r46766)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MON
ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252


attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base