From ruipbarradas at sapo.pt  Sat Dec  8 12:46:21 2012
From: ruipbarradas at sapo.pt (Rui Barradas)
Date: Sat, 08 Dec 2012 11:46:21 +0000
Subject: [Rd] file.link on Windows 7
In-Reply-To: <50C326C8.7080304@sapo.pt>
References: <50C326C8.7080304@sapo.pt>
Message-ID: <50C3288D.10507@sapo.pt>

Sorry, forgot the session info.

 > sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.1252

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


Rui Barradas
Em 08-12-2012 11:38, Rui Barradas escreveu:
> Hello,
>
> A post to R-Help by Oliver Soong reports what seems to be a bug 
> specific to Windows (I'm on Windows 7).
> The original post is as follows:
>
> ----------------------------------------------------------------
> from: Oliver Soong <osoong+r at gmail.com>
> to: r-help <r-help at r-project.org>
> date: Fri, 7 Dec 2012 22:07:49 -0800
> subject: [R] file.link fails on NTFS
>
> Windows 7 64-bit, R 2.15.2 i386.  Working directory is on an NTFS drive.
>
>> writeLines("", "file.txt")
>> file.link("file.txt", "link.txt")
>
> Warning in file.link("file.txt", "link.txt") :
>   cannot link 'link.txt' to 'link.txt', reason 'The system cannot find
> the file specified'
>
> No link is created.  The 'link.txt' to 'link.txt' is suspicious. Does
> this happen to anybody else?  I didn't find anything in my searches.
>
> Oliver
>
> ----------------------------------------------------------------
> The above code runs with no problems on Ubuntu 12.04/ R 2.15.2, 
> file.link returns TRUE.
> I've checked the sources and .Internal calls "file.link", executing 
> do_filelink(). The segment in file src/main/platform.c seems right, 
> not mistaking argument 'from' for 'to':
>
> #ifdef Win32
>         wchar_t *from, *to;
>
>         from = filenameToWchar(STRING_ELT(f1, i%n1), TRUE);
>         to = filenameToWchar(STRING_ELT(f2, i%n2), TRUE);
>         LOGICAL(ans)[i] = CreateHardLinkW(to, from, NULL) != 0;
>         if(!LOGICAL(ans)[i]) {
>         warning(_("cannot link '%ls' to '%ls', reason '%s'"),
>             from, to, formatError(GetLastError()));
>         }
> #else
>
>
> But there's something going on. The link is not created and the 
> warning message is wrong.
>
> Bug report? (Why CreateHardLinkW, and not CreateHardLink?)
>
> Rui Barradas
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] file.link on Windows 7
Rui Barradas