[REBOL] Re: Double trouble
From: petr:krenzelok:trz:cz at: 24-Jun-2001 0:52
Hi,
I solved the case one month ago. The only thing I found for file locking was
tcp server based. I have complete solution for non server based locking. I
have the script at my work, so you will have to wait till monday.
It works based upon following principle:
- you call the function supplied with path to file and file name, e.g.
%/C/my-dir/ %my-file.txt. It then tries to get lock on %my-file.sem, on the
path given. First thing I do is - I check if %my-file.sem exists. If it
does, I try to delete it (because some app could crash and left our
semaphore file in "dead" state, placed on hd). If I can't delete the .sem
file, I know that someone holds the lock. If I can delete it, I
open/new/direct %my-file.sem file.
So, in the end - we don't have any mechanism to write-protect file, but we
can prevent file from being deleted (if we (or someone else) hold it opened
....)
The solution is easy enough to adapt to your conditions ...
-pekr-