[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] flock() substitute???



At 15.28 11/3/97, David A. Barro wrote:
>   I'm changing a UN*X perl CGI script over to Macperl, and I've
>   discovered (by testing it) that the flock() function is used.
>   And, after CHECKING the manual Natthias' perlman dir, it says
>   "Currently not implemented in MacPerl"...  Does that mean that
>   it will soon??  Or someday?
>
>   Is there a substitute function I can use??

You could, if you like, use Mac::Files and FSpSetFLock() / FSpRstFLock().

#!perl -wl
use Mac::Files;
$f = 'amyfile';
open(F,">>$f") || warn "First try failed: $!";
FSpSetFLock($f);
print F 'some more text';
close(F);
open(F,">>$f") || warn "Second try failed: $!";
FSpRstFLock($f);
open(F,">>$f") || warn "Third try failed: $!";

It is not exactly the same, but it does basically lock the file from everyone except those who have it open already.

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch