[Rd] tools::md5sum(directory) behavior different on Windows vs. Unix

Scott Kostyshak skostysh at princeton.edu
Mon Sep 9 09:00:24 CEST 2013


tools::md5sum gives a warning if it receives a directory as an
argument on Unix but not on Windows.

>From what I understand, this happens because in Windows a directory is
not treated as a file so fopen returns NULL. Then, NA is returned
without a warning. On Unix, a directory is treated as a file so fopen
does not return NULL so md5 is run and fails, leading to a warning.

This is a good opportunity for me to understand further (in addition
to [1] and the many places where OS special cases are mentioned) in
which cases R tries to behave the same on Windows as on Unix and in
which cases it allows for differences (in this case, a warning vs. no
warning). For example, it would be straightforward to create a patch
that would lead to the same behavior in this case. tools::md5sum could
either issue a warning for each argument that is a directory or it
could issue no warning (consistent with file.info). Would either patch
be considered?

Or is this difference encouraged because the concept of a file is
different on Unix than on Windows?

Scott

[1] http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What-should-I-expect-to-behave-differently-from-the-Unix-version


--
Scott Kostyshak
Economics PhD Candidate
Princeton University



More information about the R-devel mailing list