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