How to check file is in use or not?

Hi, Is there any API for checking whether file is in use or not by any app? I know we can do the same using lsof command from terminal window. Can we do the same using API? Thanks

Replies

Is there any API for checking whether file is in use or not by any app? I know we can do the same using

lsof
command from terminal window. Can we do the same using API?

Those are two different things. An app may be using a file without actually having it open.

Anyway, you can do what

lsof
does, get a list of open files, using the
<libproc.h>
API. As to whether the app is in use by an app, the API I’d look to is
NSFileCoordinator
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"