On Mon, Sep 12, 2011 at 6:26 PM, David Winsemius <dwinsem...@comcast.net> wrote: > > On Sep 12, 2011, at 2:43 PM, Dennis Fisher wrote: > >> R 2.13.1 >> OS X. 10.6.8 >> Colleagues, >> >> I just encountered an interesting Word / OS X / R interaction problem. >> Situation is: >> 1. I have an open RTF file >> 2. From R: >> a. I delete the file (confirmed) >> b. I create a new RTF file with the same name >> (successfully) >> c. I attempt to open the new RTF file >> Word hangs (a recursive message that it can't open the file -- it must be >> corrupt), presumably because the original file was open in Word, despite >> being deleted from the drive. > > Sounds more like a Microsoft error. File locking (or lack thereof) varies > across OSes. BSD is more permissive than System V. It is not the default on > BSD Unix. > >> >> Any ideas on how to solve this? Is there some method (from R or from the >> OS) to detect which files Word has open? If so, I could avoid creating the >> new file if the original one was open. >> Interestingly, I presume that this would not happen in Windows because >> step 2a could not happen if the file were open. > > > http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/10.5/man2/flock.2.html > > I suppose you need to determine by experimentation whether MS-Word sets any > flags that system utilities can access. > > >> Dennis
I can't reproduce this using Word 2011 (v14.1.2 (110505)), R 2.13.1, and 10.6.8. Word closes and re-opens the file without complaint. > I suppose you need to determine by experimentation whether MS-Word sets any > flags that system utilities can access. You could also, from R, call lsof (e.g., "system( "lsof | grep foo" ) ) to explicitly check if Word, or any other program, has the file open. Ben _______________________________________________ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac