Using FSEvents API to receive events about individual files.
Using FSEvents API to receive events about individual files.
- Subject: Using FSEvents API to receive events about individual files.
- From: "Palagashvili, Gurami" <email@hidden>
- Date: Tue, 08 Apr 2014 19:15:32 +0000
- Thread-topic: Using FSEvents API to receive events about individual files.
Hi,
My environment :
Mac OSX : 10.9.2
Xcode : 5.1
I’m using kFSEventStreamCreateFlagFileEvents flag in FSEventsStreamCreate API to get file level notification.
CFStringRef strs[1];
strs[0] = CFStringCreateWithCString(NULL, m_path.c_str(), kCFStringEncodingUTF8);
CFArrayRef locations = CFArrayCreate(NULL, (constvoid**)strs, sizeof(strs) / sizeof(CFStringRef), &kCFTypeArrayCallBacks);
FSEventStreamContext context = { 0, (void *)this, NULL, NULL, NULL };
m_streamRef = FSEventStreamCreate(NULL,
&fseventsCallback,
&context,
locations,
kFSEventStreamEventIdSinceNow,
(CFAbsoluteTime)0.5,
kFSEventStreamCreateFlagFileEvents);
I couldn’t find any documentaion for the following flags (from FSEvents.h).
/* These flags are only set if you specified the FileEvents*/
/* flags when creating the stream.*/
kFSEventStreamEventFlagItemCreated = 0x00000100,
kFSEventStreamEventFlagItemRemoved = 0x00000200,
kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400,
kFSEventStreamEventFlagItemRenamed = 0x00000800,
kFSEventStreamEventFlagItemModified = 0x00001000,
kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000,
kFSEventStreamEventFlagItemChangeOwner = 0x00004000,
kFSEventStreamEventFlagItemXattrMod = 0x00008000,
kFSEventStreamEventFlagItemIsFile = 0x00010000,
kFSEventStreamEventFlagItemIsDir = 0x00020000,
kFSEventStreamEventFlagItemIsSymlink = 0x00040000,
kFSEventStreamEventFlagOwnEvent = 0x00080000
If file modified using TextEdit I may receive 3 or 2 events
File name Event Flag
Test.txt 0x18C00 (File,XattrMod,Renamed,InodeMetaMod )
Test.txt.sb-86c805cf-Ml9LOt 0x11E00 (File,Modified,Renamed,InodeMetaMod ,Removed )
Test.txt 0x18C00 (File,XattrMod,Renamed,InodeMetaMod )
Or
Test.txt 0x18C00 (File,XattrMod,Renamed,InodeMetaMod )
Test.txt 0x18C00 (File,XattrMod,Renamed,InodeMetaMod )
How could I reliably determine that file is modified?
If I move file to the Trash I will receive just one event
Test.txt0x10800 (File,Renamed).
How could I reliably determine that file is moved to Trash?
In general how reliable are the FileEvents flags?
Thanks,
-Gurami
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden