Re: How to tell if a file is busy?
Re: How to tell if a file is busy?
- Subject: Re: How to tell if a file is busy?
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 28 Sep 2001 07:42:11 -0400
on 9/27/01 8:44 PM, Chris Page at email@hidden wrote:
>
Unfortunately, as I mentioned elsewhere, on Mac OS X although a given file
>
can only be opened once with write access within a given process, multiple
>
processes can open the file with write access (they can't tell the file is
>
busy in another process, either), so you can no longer rely on checking
>
whether the file is "busy" to control access to a file. I guess this
>
reflects the underlying BSD I/O model, but it seems ludicrously stupid and
>
burdensome to me. It means programs have to find some more complicated way
>
to share access to a file, and of course you can only do this between
>
cooperating programs -- any program that doesn't participate in your
>
necessarily proprietary scheme may ruin your day.
AppleScript has always provided a standard way for applications to deal with
this problem, but only a few applications implement it (e.g., FileMaker Pro,
Font Reserve). Namely, the With Transaction event (and the related Abort
Transaction event).
I recently wrote a brief article about it in the "Tips" chapter of The
AppleScript Sourcebook. Given the multiprocess, multiuser nature of Mac OS
X, it might be a good idea for application developers to take a closer look
at implementing this standard mechanism.
It can be finer-grained than just locking everybody out of a file that is
currently in use. As its name suggests, it can lock everybody out of a
single record, allowing simultaneous access to other records.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
The AppleScript Sourcebook - www.AppleScriptSourcebook.com
Vermont Recipes - www.stepwise.com/Articles/VermontRecipes