gpt4 book ai didi

file - 监控数千个文件移动、删除和重命名的最佳 Cocoa 方式?

转载 作者:行者123 更新时间:2023-12-03 16:45:51 26 4
gpt4 key购买 nike

我有一个应用程序,它保存位于用户计算机上或可能在线或不在线的网络卷上的文件数据库。该数据库可能包含位于不同文件夹中的数千个文件。当文件名更改、移动或删除时,监视他们接收通知的最佳方法是什么?

我之前曾将 FSEvents 用于单个目录,但我猜测它不能很好地扩展到几千个单独的文件。使用 kqueue 怎么样?

我也许能够尝试维护一个动态文件夹列表,试图用尽可能少的文件夹包含所有文件,但这意味着阅读完整列表并尝试找出共同的祖先等。

想法或建议?

最佳答案

来自苹果的文档:

If you are monitoring a large hierarchy of content, you should use file system events instead, however, because kernel queues are somewhat more complex than kernel events, and can be more resource intensive because of the additional user-kernel communication involved.

https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/FSEvents_ProgGuide/KernelQueues/KernelQueues.html#//apple_ref/doc/uid/TP40005289-CH5-SW2

关于file - 监控数千个文件移动、删除和重命名的最佳 Cocoa 方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27181929/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com