1 Reply
      Latest reply on Nov 7, 2019 12:10 AM by eskimo
      maju Level 1 Level 1 (0 points)

        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

        • Re: How to check file is in use or not?
          eskimo Apple Staff Apple Staff (12,305 points)

          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"