home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7655 < prev    next >
Encoding:
Text File  |  1992-12-23  |  1.5 KB  |  36 lines

  1. Newsgroups: comp.lang.pascal
  2. 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
  3. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  4. Subject: Opening read-only files (was:  TURBO...)
  5. Message-ID: <dmurdoch.247.725120119@mast.queensu.ca>
  6. Lines: 24
  7. Sender: news@knot.ccs.queensu.ca (Netnews control)
  8. Organization: Queen's University
  9. References: <965.6.uupcb@lill.frmug.fr.mugnet.org>
  10. Date: Wed, 23 Dec 1992 14:15:20 GMT
  11.  
  12. In article <965.6.uupcb@lill.frmug.fr.mugnet.org> vanney.raphael@lill.frmug.fr.mugnet.org (Vanney Raphael) writes:
  13. >I have no satisfying answer to your first question, but here is how to
  14. >open a file with R/O, Hiden and/or System attributes :
  15. >
  16. >Uses DOS ;
  17. >Var  f    : Text ;
  18. >Begin
  19. >     Assign(f, 'IO.SYS') ;
  20. >     SetFAttr(f, 0) ;         { Don't expect this to work with
  21. >directories
  22. >                                nor volume id }
  23. >     { Here, take a look at DOSError }
  24. >     ReSet(f) ;
  25.  
  26. No, no, no!  Don't do it this way.  Read-only text files aren't a problem, 
  27. the problem comes up with binary files.  To open one of them, set the 
  28. Filemode variable to 0 (or to a special mode like $40 if SHARE is a 
  29. consideration).  There's no need to mess with the attributes of the file, 
  30. and it's a really bad idea.  What if someone runs "ERASE \*.*" while
  31. IO.SYS is a normal file?  On a network or under a multitasker, it's a real 
  32. possibility.
  33.  
  34. Duncan Murdoch
  35. dmurdoch@mast.queensu.ca
  36.