Alexander Cohen <mailto:alexco...@toomuchspace.com> wrote (Wednesday, February 3, 2010 2:50 PM -0500):

Is there any way in cocoa to get some sort of notifications when any process opens or closes any file? The reason i need this is because i need to watch the system and do a certain task every time a particular dylib is loaded by an application.

Alexander, I didn't see this thread until today and since it wasn't really answered, I'll add my two cents.

What you probably want is the kqueue()/kevent() family of BSD functions. It's not Cocoa, and programming it requires decoding typically dense/terse UNIX APIs, but it allows you to receive fine-grained notification of kernel events, including notifications of when a particular file/directory is opened, closed, or modified.

However, this still might not solve your problem. One of the hallmarks of frameworks/dylibs is that their code is only loaded once, and is then repeatedly mapped into the address space of multiple processes. So watching to see when the file is opened might not tell you if a process has loaded it, and it almost certainly won't tell you what process did the loading.

--
James Bucanek

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to