www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/10/16:25:05

From: ovek AT arcticnet DOT no (Ove Kaaven)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Final comments: (Re: Desperately need help with "fopen")
Date: Wed, 09 Apr 1997 15:18:05 GMT
Organization: Vplan Programvare AS
Lines: 62
Message-ID: <5ijesm$331$1@troll.powertech.no>
References: <334B568B DOT DBF AT ife DOT ee DOT ethz DOT ch> <334D0BCB DOT 5E1B AT ife DOT ee DOT ethz DOT ch>
NNTP-Posting-Host: alwayscold.darkness.arcticnet.no
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Bernhard Baeumle <bb AT ife DOT ee DOT ethz DOT ch> wrote:

>This was quite confusing... 
>...some programs DO lock the file they opened and other programs dont.

Some programs are networkable and some aren't. Some programs can be
"sabotaged" easily (mess with their files while they are in use) and
some can't.

>...some programs can still read those files and others cant...

Naturally.

>No Windows95- and MSWord-expert knew about a way to turn off MSWord
>locking files!

Windows95 is too self-indulgent to let anyone be an expert on it. It
protects itself against being messed with by self-destructing.

>...and some gcc-gurus could not believe that 'fopen("bla","r")' could
>fail only because the file is opened with MSWord (no offence).

I don't think this is quite what they did not believe. They did not
believe that fopen() would fail where open() won't. Blame it on
inaccurate problem descriptions.

>The problem is now solved but I still do not understand why there had to
>be a problem at all!
>- SH_DENYNO = "Deny none mode"
>  ===> so what kind of flag was set by MSWord that has to be denied???

It seems likely that MS Word would use "deny write".

>- No matter what the flag is meant for, why can some programs read and
>others can not? Why do some programs set this flag and others dont?

Many programs don't care about sharing flags, thus they don't set it
either.

When no flags are set, the file is opened in "compatibility mode". In
this mode, the file can be opened by any other processes if they too
use "compatibility mode", i.e. no sharing flags at all. But a file
opened with sharing flags follow normal sharing rules, except that it
cannot be shared with processes that open it in compatibility mode.

So even a file opened with "deny none" cannot be opened with
"compatibility mode" (which djgpp uses by default), and vice versa. If
MS Word used any sharing flags (deny write), your program must
therefore also use some kind of sharing flags to be able to open it.

>- ... and why is DJGPP's fopen() the only function I found which has
>problems with reading??? (so "SH_DENYNO" should be the default!?!?)

Sharing flags such as these seem to be DOS-specific, and thus I
presume they aren't ANSI or POSIX, which would explain why djgpp
doesn't use them in the ANSI function fopen().

It's possible that other DOS compilers' fopen()'s use sharing by
default, though I think inferring the intended sharing flags from the
meager info given to fopen() might be more guesswork than science.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019