[Gambas-user] How to lock a file

nando nando_f at ...951...
Tue Oct 7 10:04:58 CEST 2008


In some applications, I create a folder as a lock.
The existance of the folder indicates 'locked'
It works very well and is used through Samba to share
the lock on both the linux and windows side.
-Fernando


---------- Original Message -----------
From: Benoit Minisini <gambas at ...1...>
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Sent: Fri, 26 Sep 2008 23:51:57 +0200
Subject: Re: [Gambas-user] How to lock a file

> On vendredi 26 septembre 2008, Almanova Sistemi wrote:
> > I need to lock the file to avoid writing by another user in multiuser
> > environment
> >
> 
> Sorry for that, the documentation is completely false. But who wrote it? :-)
> 
> The LOCK instruction does not lock a specific stream not a stream, but instead 
> use a specific path to create a global system lock.
> 
> You use it this way:
> 
> DIM hFile AS File
> 
> TRY hFile = LOCK "~/lock"
> IF ERROR THEN
>   PRINT "Already locked by something else!"
> ELSE
>   PRINT "Got locked!"
>   ...
>   UNLOCK hFile
> ENDIF
> 
> Do not rely on the lock file contents. It is truncated to zero byte when the 
> lock is acquired.
> 
> Regards,
> 
> -- 
> Benoit Minisini
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list