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:
> unlink fails to remove symbolic links. This is more prominent now --
> when a package creates symbolic links during installation, 00LOCK is
> not removed.
>
> Martin
>
>> setwd(tempdir())
>> fl <- tempfile(); file.create(fl)
> [1] TRUE
>> lnFile <- tempfile(); system(paste("ln -s", fl, lnFile))
>> list.files()
> [1] "file19495cff" "file74b0dc51"
>> unlink(fl); unlink(lnFile)
>> list.files()
> [1] "file19495cff"
>> lnFile
> [1] "/tmp/Rtmpb0kd7B/file19495cff"
>
>> sessionInfo()
> 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
--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M2 B169
Phone: (206) 667-2793