While constructing some tests of symbolic link code in R, I got
an odd warning when trying the remove a symbolic link:
file.create(tfile <- tempfile())
#[1] TRUE
file.symlink(tfile, tlink <- tempfile())
#[1] TRUE
unlink(tlink)
#Warning message:
#In unlink(tlink) :
# cannot delete reparse point
'C:\Users\wdunlap\AppData\Local\Temp\Rtmp0oB1gl\fileedc792515a3', reason
'There is a mismatch between the tag specified in the request and the tag
present in the reparse point.
#'
file.exists(tlink)
#[1] TRUE
I can remove the symbolic link, without any warnings, if it is in
a directory that I remove with unlink(recursive=TRUE):
dir.create(tdir <- tempfile(fileext=".dir"))
file.create(tfile <- file.path(tdir, "file"))
#[1] TRUE
file.symlink(tfile, tlink <- file.path(tdir, "symlinkToFile"))
#[1] TRUE
dir(tdir)
#[1] "file" "symlinkToFile"
print(unlink(tdir, recursive=TRUE))
#[1] 0
file.exists(tdir)
#[1] FALSE
file.exists(tlink)
#[1] FALSE
(I didn't know symlinks were even possible on Windows, but they are in
Windows 7. Sys.readlink() does nothing useful on Windows.)
> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] assertionTest_0.5
Bill Dunlap
TIBCO Software
wdunlap tibco.com
[[alternative HTML version deleted]]