private static void StartMonitoringDirectory(KeventData data) { DirectoryInfo directoryInfo = new DirectoryInfo(data.Directory); if (data.DirEntries == null) { data.DirEntries = new Hashtable(); foreach (FileSystemInfo fileSystemInfo in directoryInfo.GetFileSystemInfos()) { data.DirEntries.Add(fileSystemInfo.FullName, new KeventFileData(fileSystemInfo, fileSystemInfo.LastAccessTime, fileSystemInfo.LastWriteTime)); } } int num = KeventWatcher.open(data.Directory, 0, 0); kevent ev = default(kevent); ev.udata = IntPtr.Zero; timespec timespec = default(timespec); timespec.tv_sec = 0; timespec.tv_usec = 0; if (num > 0) { ev.ident = num; ev.filter = -4; ev.flags = 21; ev.fflags = 31u; ev.data = 0; ev.udata = Marshal.StringToHGlobalAuto(data.Directory); kevent kevent = default(kevent); kevent.udata = IntPtr.Zero; KeventWatcher.kevent(KeventWatcher.conn, ref ev, 1, ref kevent, 0, ref timespec); data.ev = ev; KeventWatcher.requests[num] = data; } if (!data.IncludeSubdirs) { return; } }