简体   繁体   English

如果某个应用程序仍在使用某个卷,您如何获得通知?

[英]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. 如果您打开了一个文档并想卸载一个卷,则os x将打开此警报面板,表明程序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. 我尝试了DADiskArbitration框架,但是直到成功卸载磁盘后,它才发送回调。

Have you any ideas? 你有什么想法吗?

You could invoke lsof using NSTask to get a list of open files. 您可以使用NSTask调用lsof来获取打开文件的列表。 Use lsof +D /Volumes/<volume name> to narrow the search down to files open in the mounted volume you're interested in. 使用lsof +D /Volumes/<volume name>将搜索范围缩小到您感兴趣的已装入卷中打开的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在OS X的Safari中更改/加载URL时如何通知可可应用程序? - How can a Cocoa application get notified when a URL is changed/loaded in Safari for OS X? 如何在Cocoa应用程序中收到系统时间更改的通知? - How can I get notified of a system time change in my Cocoa application? 在iPhone应用程序中,当一天中的特定时间到达时,如何获得通知? - How can I get notified when it reaches a certain time of day in an iPhone application? 当应用程序移至垃圾箱或在Mac中被垃圾箱丢弃时如何获得通知? - How to get notified when an application moved to trash or an application trashed in mac? 如何在WebView中通知我的Cocoa应用程序onClick事件? - How can my Cocoa application be notified of onClick events in a WebView? 加载/卸载NSViewController实例时如何获得通知 - How can I get notified when NSViewController instance is loaded / unloaded 当进程或应用程序被终止/强制终止时得到通知? - Get notified when a process or application is killed/forcekilled? 如何通过NSArrayController获得有关模型更改的通知? - How to get notified of changes to models via an NSArrayController? NSWindow打开时如何获得通知? - How to get notified when NSWindow opens? 当用户将图像粘贴或拖动到NSImageView中时,如何通知我的代码? - How can my code get notified when the user pastes or drags an image into NSImageView?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM