Re: Busy Status
Re: Busy Status
- Subject: Re: Busy Status
- From: Jon Pugh <email@hidden>
- Date: Sun, 3 Nov 2002 16:21:42 -0800
At 4:07 PM -0800 11/3/02, Chris Page wrote:
>
Mac OS X 10.2 Jaguar introduced a built-in file access locking mechanism for applications that use the Carbon File Manager, so the pre-X behavior has been restored.
>
>
I just ran a test, and "open for access ... with write permission" correctly returns an error on a file open in another application, but fileIsBusy on the same file returns false. fileIsBusy returns true if I "open for access" the file beforehand in the same script. So there may be a way to get fileIsBusy to work, but it might involve trying to open the file, rather than testing the file status bits.
Here's a small test I wrote which confirms your findings:
set f to (path to desktop as string) & "Test.txt"
set wasBusy to fileIsBusy f
if wasBusy then
display dialog "File is already busy"
return
end if
set rf to open for access f with write permission
try
write "Test" to rf
set isBusy to fileIsBusy f
if isBusy then
set m to "File is busy"
else
set m to "File is not busy"
end if
display dialog m
close access rf
on error
close access rf
end try
I saved this as an application and then ran it so that it paused at the "File is busy" dialog, and then ran it again in the script editor.
The first dialog is never hit, because fileIsBusy doesn't see the file as being open in the other application. However, it errors trying to open for access, so Chris is right, there's a way to make it work, so I'll look into it.
Jon
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.