|
Prev: MPICH and Fortran90
Next: glibc??
From: David Thompson on 7 Apr 2008 02:00 On Mon, 24 Mar 2008 05:20:29 -0700 (PDT), "johnharwood(a)arrakis.es" <johnharwood(a)arrakis.es> wrote: > Although I suspect that this may be a Windows question, maybe somebody > has been here before! > > Using IVF and Windows XP Professional, if a file is opened with the > specifier NOSHARED and then I attempt to open it again with, say > Notepad, access is denied. Great. However, if a file is already > opened with Notepad, it is successfully opened again by my program. notepad doesn't actually have the file open. At startup or Open, it opens the file and 'slurps' it into memory and closes it. From then on you work only on the memory copy, unless and until you do Save [As], or Exit or New or Open after changes and answer the dialog to save. To see an error you'll have to run your Fortran program while notepad is reading, which normally takes only milliseconds, unless the file is _really_ big (typically gigabytes) or on a remote share over say a very busy and noisy network or a dialup VPN or somesuch. wordpad same. Word and Excel DO keep open the file they are working on, and Word should be able to deal with any content that notepad can (although it typically won't be the default app for plain text files). > How do I prevent this from happening? The various INQUIRE options > return Opened=false, Share=unknown, Access=undefined - formerly david.thompson1 || achar(64) || worldnet.att.net
From: johnharwood on 7 Apr 2008 05:02 On Apr 7, 8:00 am, David Thompson <dave.thomps...(a)verizon.net> wrote: > On Mon, 24 Mar 2008 05:20:29 -0700 (PDT), "johnharw...(a)arrakis.es" > > <johnharw...(a)arrakis.es> wrote: > > Although I suspect that this may be a Windows question, maybe somebody > > has been here before! > > > Using IVF and Windows XP Professional, if a file is opened with the > > specifier NOSHARED and then I attempt to open it again with, say > > Notepad, access is denied. Great. However, if a file is already > > opened with Notepad, it is successfully opened again by my program. > > notepad doesn't actually have the file open. At startup or Open, it > opens the file and 'slurps' it into memory and closes it. From then on > you work only on the memory copy, unless and until you do Save [As], > or Exit or New or Open after changes and answer the dialog to save. > > To see an error you'll have to run your Fortran program while notepad > is reading, which normally takes only milliseconds, unless the file is > _really_ big (typically gigabytes) or on a remote share over say a > very busy and noisy network or a dialup VPN or somesuch. > > wordpad same. Word and Excel DO keep open the file they are working > on, and Word should be able to deal with any content that notepad can > (although it typically won't be the default app for plain text files). > > > How do I prevent this from happening? The various INQUIRE options > > return Opened=false, Share=unknown, Access=undefined > > - formerly david.thompson1 || achar(64) || worldnet.att.net Thanks, David. Steve Lionel had already pointed out to me how Notepad operates but his reply was not posted here. What I was trying to do is ensure that, within a small department (half a dozen people), if somebody were using a file nobody else could open that file. The file locking works fine with Fortran applications, Excel and Word. Visual Studio (which also "slurps it into memory") is not an issue for other users. I conclude that there is no way that I can prevent the (very remote) possibility that someone has opened the file with Notepad, then somebody else opens it with my application, amends and saves it, then the Notepad user closes and saves the file thereby overwriting the now amended version of that file. In the big picture it doesn't really matter because, the next time that file is used, a checksum error would be detected by my application. I just wanted to ensure that that sort of aggravation doesn't occur!
From: glen herrmannsfeldt on 7 Apr 2008 05:35 johnharwood(a)arrakis.es wrote: (snip) > The file locking works fine with Fortran applications, Excel and Word. > Visual Studio (which also "slurps it into memory") is not an issue for > other users. I conclude that there is no way that I can prevent the > (very remote) possibility that someone has opened the file with > Notepad, then somebody else opens it with my application, amends and > saves it, then the Notepad user closes and saves the file thereby > overwriting the now amended version of that file. You are probably right, but notepad could check to see if the file (or just the size) had changed while it was in memory before rewriting it. Otherwise, don't let people use notepad. -- glen
From: Gary Scott on 7 Apr 2008 08:38 johnharwood(a)arrakis.es wrote: > On Apr 7, 8:00 am, David Thompson <dave.thomps...(a)verizon.net> wrote: > >>On Mon, 24 Mar 2008 05:20:29 -0700 (PDT), "johnharw...(a)arrakis.es" >> >><johnharw...(a)arrakis.es> wrote: >> >>>Although I suspect that this may be a Windows question, maybe somebody >>>has been here before! >> >>>Using IVF and Windows XP Professional, if a file is opened with the >>>specifier NOSHARED and then I attempt to open it again with, say >>>Notepad, access is denied. Great. However, if a file is already >>>opened with Notepad, it is successfully opened again by my program. >> >>notepad doesn't actually have the file open. At startup or Open, it >>opens the file and 'slurps' it into memory and closes it. From then on >>you work only on the memory copy, unless and until you do Save [As], >>or Exit or New or Open after changes and answer the dialog to save. >> >>To see an error you'll have to run your Fortran program while notepad >>is reading, which normally takes only milliseconds, unless the file is >>_really_ big (typically gigabytes) or on a remote share over say a >>very busy and noisy network or a dialup VPN or somesuch. >> >>wordpad same. Word and Excel DO keep open the file they are working >>on, and Word should be able to deal with any content that notepad can >>(although it typically won't be the default app for plain text files). >> >> >>>How do I prevent this from happening? The various INQUIRE options >>>return Opened=false, Share=unknown, Access=undefined >> >>- formerly david.thompson1 || achar(64) || worldnet.att.net > > > Thanks, David. Steve Lionel had already pointed out to me how Notepad > operates but his reply was not posted here. > > What I was trying to do is ensure that, within a small department > (half a dozen people), if somebody were using a file nobody else could > open that file. > > The file locking works fine with Fortran applications, Excel and Word. > Visual Studio (which also "slurps it into memory") is not an issue for > other users. I conclude that there is no way that I can prevent the > (very remote) possibility that someone has opened the file with > Notepad, then somebody else opens it with my application, amends and > saves it, then the Notepad user closes and saves the file thereby > overwriting the now amended version of that file. > > In the big picture it doesn't really matter because, the next time > that file is used, a checksum error would be detected by my > application. I just wanted to ensure that that sort of aggravation > doesn't occur! You can temporarily rename it or change the attributes while open with your app for a slight bit of extra protection, although Notepad could already be open. -- Gary Scott mailto:garylscott(a)sbcglobal dot net Fortran Library: http://www.fortranlib.com Support the Original G95 Project: http://www.g95.org -OR- Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html If you want to do the impossible, don't hire an expert because he knows it can't be done. -- Henry Ford
|
Pages: 1 Prev: MPICH and Fortran90 Next: glibc?? |