void OnFSeventClose(FSEvent fsEvent, FileSystemEvent fileSystemEvent) { this.callbackCount++; if (this.callbackCount == 3) { fsEvent.CloseHandle(this.OnClose); } }
void OnTimer(Timer handle) { FSEvent fsEvent = this.loop .CreateFSEvent() .Start(".", this.OnFSEvent); fsEvent.CloseHandle(this.OnClose); handle.CloseHandle(this.OnClose); }
void OnFSEventDirectory(FSEvent fsEvent, FileSystemEvent fileSystemEvent) { if (fileSystemEvent.EventType == FSEventType.Rename) { this.callbackCount++; } fsEvent.Stop(); fsEvent.CloseHandle(this.OnClose); }
void OnFSEventFile(FSEvent fsEvent, FileSystemEvent fileSystemEvent) { if (fileSystemEvent.EventType == FSEventType.Change) { this.callbackCount++; } fsEvent.Stop(); fsEvent.CloseHandle(this.OnClose); }
public void WatchFileRootDir() { string root = TestHelper.RootSystemDirectory(); FSEvent fsEvent = this.loop .CreateFSEvent() .Start(root, this.OnFSEvent); fsEvent.CloseHandle(this.OnClose); this.loop.RunDefault(); Assert.Equal(0, this.callbackCount); Assert.Equal(1, this.closeCount); }
void OnFSEventDirMultipleFile(FSEvent fsEvent, FileSystemEvent fileSystemEvent) { this.callbackCount++; if (this.fileCreated + this.fileRemoved == FileEventCount) { // Once we've processed all create events, delete all files this.timer.Start(this.OnTimerDeleteFile, 1, 0); } else if (this.callbackCount == 2 * FileEventCount) { // Once we've processed all create and delete events, stop watching this.timer.CloseHandle(this.OnClose); fsEvent.CloseHandle(this.OnClose); } }
public void NoCallbackOnClose() { string directory = TestHelper.CreateTempDirectory(); this.directoryList.Add(directory); string file = TestHelper.CreateTempFile(directory); FSEvent fsEvent = this.loop .CreateFSEvent() .Start(file, this.OnFSEventFile); fsEvent.CloseHandle(this.OnClose); this.loop.RunDefault(); Assert.Equal(0, this.callbackCount); Assert.Equal(1, this.closeCount); }
public void StartAndClose() { string directory = TestHelper.CreateTempDirectory(); this.directoryList.Add(directory); FSEvent fsEvent1 = this.loop.CreateFSEvent(); fsEvent1.Start(directory, this.OnFSEventDirectory); FSEvent fsEvent2 = this.loop.CreateFSEvent(); fsEvent2.Start(directory, this.OnFSEventDirectory); fsEvent1.CloseHandle(this.OnClose); fsEvent2.CloseHandle(this.OnClose); this.loop.RunDefault(); Assert.Equal(2, this.closeCount); Assert.Equal(0, this.callbackCount); }
public void GetPath() { FSEvent fsEvent = this.loop.CreateFSEvent(); var error = Assert.Throws <OperationException>(() => fsEvent.GetPath()); Assert.Equal(ErrorCode.EINVAL, error.ErrorCode); string directory = TestHelper.CreateTempDirectory(); this.directoryList.Add(directory); fsEvent.Start(directory, this.OnFSEvent); string path = fsEvent.GetPath(); Assert.Equal(directory, path); fsEvent.Stop(); fsEvent.CloseHandle(this.OnClose); this.loop.RunDefault(); Assert.Equal(0, this.callbackCount); Assert.Equal(1, this.closeCount); }