[R] source(file) => file becomes readonly

Hjellvik Vidar Vidar.Hjellvik at imr.no
Thu Sep 22 08:34:12 CEST 2005


That sounds fine! It will be as before in version 2.2.* then? The editor I use is Vim, which says that the file "is read-only", but I can override the protection. Wordpad says that the file is "in use by another application". In notepad it is saved without protests. It's especially when I use the browser() I like to edit and save the file while R has it open. 

Regards,
Vidar

-----Original Message-----
From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca]
Sent: 22. september 2005 02:12
To: Prof Brian Ripley
Cc: Hjellvik Vidar; r-help at stat.math.ethz.ch; Uwe Ligges
Subject: Re: [R] source(file) => file becomes readonly


Prof Brian Ripley wrote:
> This was not really accurate.
> 
> Being `read-only' is a Windows phenomenon on open files (even files open 
> for reading).  In 2.0.1 and 2.1.1 the file was open whilst it was parsed 
> and so `read-only' during that time. In 2.0.1 it was then closed, but in 
> 2.1.1 it was (potentially) opened several times to find an encoding, 
> parsed and left open until source() terminated.  In 2.2.0 it will be 
> closed once it has been parsed.

But R doesn't open files in an exclusive mode.  It opens them in "share 
deny none" mode (_SH_DENYNO; this is an undocumented feature of the MSVC 
run-time library that MinGW uses).  I suspect whatever editor Hjellvik 
was using attempted to open the file with exclusive access, and when 
that failed (because R had it open), it fell back to read-only access.

It's certainly possible to open a file for write access in another 
process while R has it open for read access.  You just can't get 
exclusive access to it.

Duncan Murdoch
> 
> Changing a file after it has been parsed will have no effect, so there is 
> no reason to prevent it (beyond that was the simplest way to implement 
> choosing a suitable encoding).
> 
> On Thu, 1 Sep 2005, Hjellvik Vidar wrote:
> 
> 
>>The OS is Windows XP.
>>I use to work on the file while it's executed and save changes 
>>continually. It doesn't seem to have any effect on the current 
>>execution. I just find it annoying not to be able to do it. It's not 
>>crucial, but if there is some easy way around it I would like to 
>>know....
>>
>>-----Original Message-----
>>From: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de]
>>Sent: 1. september 2005 14:21
>>To: Hjellvik Vidar
>>Cc: r-help at stat.math.ethz.ch
>>Subject: Re: [R] source(file) => file becomes readonly
>>
>>
>>Hjellvik Vidar wrote:
>>
>>
>>>Hello,
>>>when I work in R, I write code in a text file that I run with the "source(filename)" command. In R2.1.1 the file is read-only while the source command is executed. This was not the case in R2.0.1. Is this a bug-fix or is it possible not to have the file read-only when executed?
>>
>>So you want to modify a file *while* it is executed?
>>Sounds dangerous to me, you may want to explain further...
>>
>>BTW: Which OS are we talking about?
>>
>>Uwe Ligges
>>
>>
>>
>>>Best regards
>>>Vidar
>>>
>>>______________________________________________
>>>R-help at stat.math.ethz.ch mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
> 
>




More information about the R-help mailing list