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: Chris Page <email@hidden>
- Date: Wed, 26 Sep 2001 01:30:59 -0700
nigh on 9/25/01 10:47 PM, David Simerly at email@hidden wrote:
>
Mac OS 9 Tech. Note 1176:
>
<http://developer.apple.com/technotes/tn/tn1176.html>
>
>
> The "file busy" flag to has been added to the FileInfo result to allow a
>
> script to wait until a file operation is complete (i.e., until the file is no
>
> longer busy).
>
>
Scripts access the flag via the standard addition "get info":
>
>
set file_info to get info for my_file_alias
>
repeat while busy of file_info
>
delay 10
>
end
>
>
As I said earlier: the only app I've found to date that sets this flag is
>
the Finder.
Where exactly does "info for" get this flag from? AFAIK, applications are
not responsible for setting a "busy" flag on files. Perhaps "info for" gets
this from the kioFlAttribFileOpenBit flag in ioFlAttrib of HFileInfo, in
which case the problem for AppleScripts is probably that a lot of
applications open, read, then close files that are "open" in the UI, but
don't keep the actual file open the whole time the "document" is "open", if
you see what I mean.
By the way, things get worse on Mac OS X:
<
http://developer.apple.com/techpubs/macosx/Carbon/Files/FileManager/File_Ma
nager/Enumerations/File_Attribute_Constants2.html>
-------------------------8<-------------------------
kioFlAttribFileOpenBit
Indicates that the file is open. This bit is set if either the data or the
resource fork are open. On Mac OS X, this bit is not set if the file has
been opened by a process other than the process making the call to
PBHGetCatInfo or PBHGetFInfo.
-------------------------8<-------------------------
So on Mac OS X, there's no way to tell if a file is open unless it's open in
your process. This is a major problem, and I reported it as a bug over a
year ago, but I've received no indication from Apple whether it will ever be
addressed.
--
Chris Page
Mac OS Lead, Palm Desktop
Palm, Inc.
Software development is the art of cajoling megabytes of random noise into
doing something reasonably useful, or at least not life-threatening.