Adam: fileIsBusy

Hi Adam,

I haven’t figured out how to reply at the users list yet, so posting here.

Jon’s Commands ‘fileIsBusy’ command returns true when a file is opened with ‘open for access’. This might be true for the ‘busy status’ property and you can check that out.

gl,

Ahh, Kel;

Sure enough. Apparently a file is only “busy” if a Script is making it “busy”. Interesting.

Hi Adam,

This is my guess on what happens. When you open a file in an app, the app opens the file gets the data and closes it. The app uses the data in it’s documents or whatever. Using the ‘open for access’ command just allow testing of the opening of the file.

Just guessing.

gl,

“open for access” is a common concept in other programming languages, I think. At least Perl and others have options to “lock” the file when reading or writing. I guess AppleScript’s “open for access with write permission” uses some kind of “lock” flag, and “without”, without.

I’m not sure about Jon’s Commands “fileIsBusy” (not its equivalent in newer versions of the Standard Additions via file information’s “busy status”), but “open for access” will detect files “locked” by third party apps (not only AppleScript-based ones). Perhaps this is due to the programming language (or executing code) in question, and whether it uses a “readable” lock instruction or not -from the AS-side-. :frowning:

But the final answer will result in: actually, the only tool able to guess if the file is really in use or not is “lsof”.

Thanks, jj.