Skip to content

unlink fails to remove symbolic links

3 messages · Martin Morgan, Brian Ripley

#
unlink fails to remove symbolic links. This is more prominent now --
when a package creates symbolic links during installation, 00LOCK is
not removed.

Martin
[1] TRUE
[1] "file19495cff" "file74b0dc51"
[1] "file19495cff"
[1] "/tmp/Rtmpb0kd7B/file19495cff"
R version 2.10.0 Under development (unstable) (2009-03-21 r48173)
x86_64-unknown-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-\
8;LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] tools_2.10.0
#
A little more precisely, unlink fails when the file being unlinked is
a broken symbolic link (as in the example below). This is because
R_FileExists checks stat() == 0, and stat fails (returns -1) when
trying to resolve the broken link. Perhaps lstat() is more
appropriate?

Martin

Martin Morgan <mtmorgan at fhcrc.org> writes:

  
    
#
On Sat, 21 Mar 2009, Martin Morgan wrote:

            
lstat is not portable, and I don't think it is appropriate for most
uses of R_FileExists.

I don't think there is anything new about this, and it does seem only 
to apply to broken links.  At a quick look the best solution looks to 
be to remove the pretest, but I need to check in more detail.