开发者

could I know which file is altered using fsevent?

开发者 https://www.devze.com 2023-01-04 02:34 出处:网络
I get the directory path from fsevent, such as \"/User/Data/\" But what I really want is \"/User/Data/change.txt\"

I get the directory path from fsevent, such as "/User/Data/" But what I really want is "/User/Data/change.txt" I have read the programming guide, 开发者_运维技巧it said

typedef void ( *FSEventStreamCallback )(
    ConstFSEventStreamRef streamRef,
    void *clientCallBackInfo,
    size_t numEvents,
    void *eventPaths,
    const FSEventStreamEventFlags eventFlags[],
    const FSEventStreamEventId eventIds[]);  

eventPaths An array of paths to the directories in which event(s) occurred.

is there any method to find out which file is altered? thanks!!!! I have stuck to it for so long..


An alternative is kqueue. See Appendix A of the "File System Events Programming Guide".


Depending on your usage needs, you might consider low level fsevents. The process must run as root. Here is a simple example of reading from /dev/fsevents instead of using the FSEvents wrappers. With this you will get the full path as well as the process making the change and other details.


In 10.7+ you can pass the kFSEventStreamCreateFlagFileEvents flag to FSEventStreamCreate for individual file information. See documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消