Example

Example 16.5 shows a program that displays all of the historical events for the boot drive that have happened since it was last run. After that, it displays new events as they occur. To keep things simple, it exits after seeing 20 new events. It saves the device UUID and last event ID to the user defaults when it quits.

Example 16.5. fsevents.m

/​/​ ​f​s​e​v​e​n​t​s​.​m​ ​-​-​ ​W​a​t​c​h​ ​f​i​l​e​ ​s​y​s​t​e​m​ ​e​v​e​n​t​s​.​ /​/​ ​g​c​c​ ​-​s​t​d​=​c​9​9​ ​-​g​ ​-​W​a​l​l​ ​-​f​r​a​m​e​w​o​r​k​ ​F​o​u​n​d​a​t​i​o​n​ ​-​f​r​a​m​e​w​o​r​k​ ​C​o​r​e​S​e​r​v​i​c​e​s​ /​/​ ​ ​ ​ ​ ​-​o​ ​f​s​e​v​e​n​t​s​ ​f​s​e​v​e​n​t​s​.​m​ #​i​m​p​o​r​t​ ​<​F​o​u​n​d​a​t​i​o​n​/​F​o​u​n​d​a​t​i​o​n​.​h​>​ #​i​m​p​o​r​t​ ​<​C​o​r​e​S​e​r​v​i​c​e​s​/​C​o​r​e​S​e​r​v​i​c​e​s​.​h​>​ ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.