Is it possible to monitor fi开发者_Go百科le read activity of processes under Mac OS X? (programmatically, or do you know any applications that does this? That can also be helpful.)
There is now is a very neat and tidy way to do this in the Instruments app shipped together with Xcode:
Run Instruments File > New
Choose the File Activity profiling template, then choose the app you want to monitor in the upper left corner of the interface. Now, click the recording button. If the app is not already running, Instruments will launch it for you.
The second parameter is called Reads/Writes and it will log all files that your app reads and writes. It's as user friendly as it gets.
Hoping to help posterity :)
You could look at the source for fs_usage in Darwin.
This problem may be long forgotten by Damien, but mentioning possible solution is to help other people in the future. For Peer Belt decided to fo with kernel queues. The reference can be found here:
http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/FSEvents_ProgGuide/KernelQueues/KernelQueues.html
Cheers
Get a file descriptor to your file with open
, then use stat
to get its last access time.
That method works on any POSIX compliant platform.
精彩评论