简体   繁体   中英

How can you get notified, if a volume is still used by an application?

If you have a document open and want to unmount a volume, os x opens this alert panel, that the document is still in use by program x. How can you get notified about this in cocoa? I tried the DADiskArbitration framework, but this doesn't send a callback until the disk has successfully unmounted.

Have you any ideas?

You could invoke lsof using NSTask to get a list of open files. Use lsof +D /Volumes/<volume name> to narrow the search down to files open in the mounted volume you're interested in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM