home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!usc!cs.utexas.edu!torn!mcshub!csx.cciw.ca!u055
- From: u055@csx.cciw.ca (James Sprenger)
- Subject: Re: File locking question
- Organization: Canada Centre for Inland Waters
- Date: Tue, 5 Jan 1993 22:03:46 GMT
- Message-ID: <1993Jan5.220346.24647@csx.cciw.ca>
- References: <Hendrik.Klompmaker.31.726184187@beheer.zod.wau.nl> <ppollet.118.726255594@cismibm.univ-lyon1.fr>
- Lines: 65
-
- In article <ppollet.118.726255594@cismibm.univ-lyon1.fr> ppollet@cismibm.univ-lyon1.fr (Patrick POLLET) writes:
- >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 )
-
- I don't think this will work 'cause the file that is accessed is
- redirected from the command line, and not initialized from the TP prog.
- Even if you did open the file from the TP program, I think you'll run into
- problems when two people try to write to the file simultaneously (spelling?)
- Any how, if you are using a Novell NetWare network, its probably best to
- use semaphores...these netware function are faaaast and you don't have to
- write your own lowlevel IO routines.
-
- >
- > 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 *)
- >
-
- I tried a similar routine with an app I was writing and never quite got it to
- work. Maybe I should look at it again....
-
- Cheers.
-
- James Sprenger : u055@csx.cciw.ca
-
-
-