home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / pascal / 7872 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  4.1 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!cismibm.univ-lyon1.fr!ppollet
  2. From: ppollet@cismibm.univ-lyon1.fr (Patrick POLLET)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: File locking question
  5. Date: Tue, 5 Jan 1993 17:39:54 GMT
  6. Organization: INSA  CENTRE INFORMATIQUE DU 1er CYCLE
  7. Lines: 85
  8. Message-ID: <ppollet.118.726255594@cismibm.univ-lyon1.fr>
  9. References: <Hendrik.Klompmaker.31.726184187@beheer.zod.wau.nl>
  10. NNTP-Posting-Host: pc110-02.insa-lyon.fr
  11.  
  12. In article <Hendrik.Klompmaker.31.726184187@beheer.zod.wau.nl> Hendrik.Klompmaker@beheer.zod.wau.nl (Hendrik Klompmaker) writes:
  13. >From: Hendrik.Klompmaker@beheer.zod.wau.nl (Hendrik Klompmaker)
  14. >Subject: File locking question
  15. >Date: Mon, 4 Jan 1993 21:49:47 GMT
  16.  
  17. >Hy,
  18.  
  19. >This might not be the correct folder to put this question but I thought 
  20. >there might be a TP solution.
  21. >I have to keep a log file a everyone who logs in to my network. A bacth file 
  22. >is used to write to that log file by simple redirection:
  23. >username >>logfile.dat
  24. >which writes the username, time and date to the log file.
  25. >A problem arrises when 2 people log in at the same time. Right: the log file 
  26. >is locked by one of them and the other one gets a A-R-I error (abort,re...)
  27. >Is there a simple (and fast and small) method to detect if a file is locked 
  28. >or not. (since username is a TP program it would sure be possible to do the 
  29. >checking there (how ??) but maybe it would even be possible to do that at 
  30. >dos/batch level. 
  31. >Any hints ??
  32.  
  33. >Bye
  34.  
  35. >Hendrik
  36.  
  37. >===============================================================================
  38. >|******** Wageningen Agricultural University. Animal Production Group ********|
  39. >-------------------------------------------------------------------------------
  40. >Hendrik Klompmaker              Internet : Hendrik.Klompmaker@Beheer.Zod.Wau.Nl
  41. >System Manager                  Bitnet   : KLOMPMAKER@HWALHW50.BITNET
  42. >Phone : +31 (0)8370-83934       Fax      : +31 (0)8370-83962
  43. >Snail : Marijkeweg 40, 6709 PG  WAGENINGEN, The Netherlands
  44. >===============================================================================
  45.  
  46.         If you want your files to be "SHAREABLE" you should fiddle with the 
  47. FileMode public variable of TurboPascal BEFORE doing any Reset,Rewrite,
  48. Close (and possibly Append :I did not tried that one yet )
  49.  
  50.     The standard value is 02 that is ReadWrite with no share support.
  51.     The actual value should be created from the following table:
  52.             OPEN  MODE
  53.     bit    7   1 if file private to process, 0 if child may use it
  54.            6,5,4 : Sharing Mode as follow:
  55.                      000   compatible mode (no share)
  56.                      001   deny Read/write
  57.                      010   deny Write
  58.                      101   deny read
  59.                      100   deny none
  60.             3   always 0   
  61.             2,1,0 : Acces mode
  62.                       000 Read 
  63.                       001 Write
  64.                       010 Read write 
  65.                      
  66. to get some share support you should  set FileMode to:
  67.    - $42     open for Read/Write AND Deny NONE
  68.    - $22     open for Read/Write AND Deny write by others...
  69.     all whatever valid combination...
  70.  
  71.   INFO TAKEN FROM  the Dos lan juncture by J.S.Haugdahk 
  72.                    PC TECH JOURNAL  JULY 1987 ,p 78-89 
  73.                    An execellent article that explains all MsDos-Share
  74.                     entry points, with entry points, return values...
  75.  
  76.  So my guess  is that your program username should:
  77.  
  78.   -be compiled with $I-  (no stop on runtime error)
  79.  
  80.   -Repeat
  81.      -try to open the file in mode $11 (Write and deny ALL)
  82.   -Until (IoResult=0)  (* nobody else has locked it *)
  83.  
  84. Hope it helps....   
  85.   
  86. ppollet@cismibm.univ-lyon1.fr (Patrick POLLET)
  87. --------------------------------------------------------
  88. Dr Patrick L.Pollet
  89. Institut National des Sciences Appliquees
  90. Centre Informatique du 1er Cycle  Bat 110
  91. 20 Avenue A.Einstein
  92. 69621 Villeurbanne Cedex France
  93. --------------------------------------------------------
  94. Phone: 72 43 83 80 -   la premiere erreur c'est
  95. Fax  : 72 43 85 33 -   de se lever le matin  ... GASTON
  96. -------------------------------------------------------
  97.