home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!wupost!howland.reston.ans.net!paladin.american.edu!gatech!darwin.sura.net!jvnc.net!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!torn!news.ccs.queensu.ca!slip201.telnet1.QueensU.CA!dmurdoch
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Subject: Opening read-only files (was: TURBO...)
- Message-ID: <dmurdoch.247.725120119@mast.queensu.ca>
- Lines: 24
- Sender: news@knot.ccs.queensu.ca (Netnews control)
- Organization: Queen's University
- References: <965.6.uupcb@lill.frmug.fr.mugnet.org>
- Date: Wed, 23 Dec 1992 14:15:20 GMT
-
- In article <965.6.uupcb@lill.frmug.fr.mugnet.org> vanney.raphael@lill.frmug.fr.mugnet.org (Vanney Raphael) writes:
- >I have no satisfying answer to your first question, but here is how to
- >open a file with R/O, Hiden and/or System attributes :
- >
- >Uses DOS ;
- >Var f : Text ;
- >Begin
- > Assign(f, 'IO.SYS') ;
- > SetFAttr(f, 0) ; { Don't expect this to work with
- >directories
- > nor volume id }
- > { Here, take a look at DOSError }
- > ReSet(f) ;
-
- No, no, no! Don't do it this way. Read-only text files aren't a problem,
- the problem comes up with binary files. To open one of them, set the
- Filemode variable to 0 (or to a special mode like $40 if SHARE is a
- consideration). There's no need to mess with the attributes of the file,
- and it's a really bad idea. What if someone runs "ERASE \*.*" while
- IO.SYS is a normal file? On a network or under a multitasker, it's a real
- possibility.
-
- Duncan Murdoch
- dmurdoch@mast.queensu.ca
-