检测磁盘上的可用空间何时发生变化
我需要使用 Objective-C 监视磁盘上的可用空间,尤其是当它发生变化时。 如果这不可行,那么我有兴趣检测用户何时清空垃圾。
感谢您的帮助,
问候,
I need to monitor the available free space on the disk using objective-c, especially when it changes.
If this is not feasible then I am interested to detect when the trash is emptied by the user.
Thanks for your help,
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

在任何给定时刻,大约有无数的东西可能会写入磁盘;虚拟机、控制台日志、程序、缓存、首选项、用户等等……
因此,每当空闲磁盘发生变化时收到通知几乎没有用,因为您将一直收到这样的通知。
看着垃圾被清空应该不会太难; kqueue 可以很容易地做到这一点。但这也不可能告诉你太多信息;垃圾箱中可能有 400MB,也可能有 4K。
你到底想做什么?
There are about a zillion things at any given moment that might be writing to disk; VM, console logs, programs, caches, preferences, the user, etc...
... thus, receiving a notice of whenever free disk changes is pretty much useless because you would be receiving such a notice all the time.
Watching for the trash being emptied shouldn't be too hard; a kqueue could do it easily enough. But that isn't likely to tell you much, either; the trash might have 400MB in it or it might have 4K.
What are you really trying to do?