/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Sync.Strategy.MacWatcher"/> class. /// </summary> /// <param name="pathname">Path to be monitored.</param> /// <param name="queue">Queue to pass the new events to.</param> /// <param name="latency">Maximum latency for file system events.</param> public MacWatcher(string pathname, ISyncEventQueue queue, TimeSpan latency) { if (string.IsNullOrEmpty(pathname)) { throw new ArgumentNullException("The given fs stream must not be null"); } if (queue == null) { throw new ArgumentNullException("The given queue must not be null"); } this.Queue = queue; this.RunLoopThread = new Thread(() => { this.RunLoop = NSRunLoop.Current; while (!this.StopRunLoop) { this.RunLoop.RunUntil(NSDate.FromTimeIntervalSinceNow(1)); this.CleanLastRenameEvent(); } }); this.RunLoopThread.Start(); while (RunLoop == null) { Thread.Sleep(10); } this.FsStream = new FSEventStream(new [] { pathname }, latency, FSEventStreamCreateFlags.FileEvents); this.EnableEvents = false; this.FsStream.ScheduleWithRunLoop(this.RunLoop); }
void InitializeFSEventStream() { if (eventStream != null) { eventStream.Events -= OnFSEventStreamEvents; eventStream.Dispose(); eventStream = null; } if (Directory.Exists(currentWatchPath)) { Console.WriteLine("Creating new FSEventStream: latency={0}, path={1}", eventLatency, currentWatchPath); eventStreamIsRunning = false; eventStream = new FSEventStream(new [] { currentWatchPath }, eventLatency, FSEventStreamCreateFlags.FileEvents); eventStream.Events += OnFSEventStreamEvents; eventStream.ScheduleWithRunLoop(NSRunLoop.Current); EventStreamView.DataSource = eventsDataSource = new FSEventDataSource(); ToggleFSEventStream(); } }
public void Dispose() { if (fsEventStream != null) { fsEventStream.Dispose(); fsEventStream = null; } }
public void CreateFSEventStream() { watchedFileChanged = false; exludedFileChanged = false; fsEventStreamStarted = false; fsEventStream = new FSEventStream(st_dev, pathsToWatchRelativeToDevice, FSEvent.SinceNowId, TimeSpan.FromSeconds(1), FSEventStreamCreateFlags.WatchRoot | FSEventStreamCreateFlags.FileEvents | FSEventStreamCreateFlags.NoDefer); Assert.IsNotNull(fsEventStream, "Null"); }
public MacFileSystemWatcher(string filePath) { System.Diagnostics.Debug.WriteLine("Creating MacFileSystemWatcher"); _eventStream = new FSEventStream(new[] { filePath }, TimeSpan.FromMilliseconds(500), FSEventStreamCreateFlags.FileEvents); _eventStream.Events += OnFSEventStreamEvents; _eventStream.ScheduleWithRunLoop(NSRunLoop.Current); _eventStream.Start(); }
void StopMonitoringExternalCssChanges() { if (fsEventStream != null) { Log.Info(TAG, "Stopping CSS monitor"); fsEventStream.Stop(); fsEventStream.Dispose(); fsEventStream = null; } }
public void Setup(string path, int detectionToAlertDelayMilliseconds) { _eventStream = new FSEventStream(new string[] { path }, TimeSpan.FromMilliseconds(100), FSEventStreamCreateFlags.FileEvents); _eventStream.ScheduleWithRunLoop(Foundation.NSRunLoop.Current); DetectionToAlertDelayMilliseconds = detectionToAlertDelayMilliseconds; _eventStream.Events += eventStream_Events; }
public void Setup(Repository repository, int detectionToAlertDelayMilliseconds) { _repository = repository; _eventStream = new FSEventStream(new string[] { _repository.Path }, TimeSpan.FromMilliseconds(100), FSEventStreamCreateFlags.FileEvents); _eventStream.ScheduleWithRunLoop(Foundation.NSRunLoop.Main); DetectionToAlertDelayMilliseconds = detectionToAlertDelayMilliseconds; _eventStream.Events += eventStream_Events; }
public FileSystemWatcher(string path, bool includeSubdirectories) { if (!includeSubdirectories) { Filter = (s) => { return System.IO.Path.GetDirectoryName(s) == path; }; } fsEventStream = new FSEventStream( new string[] { path }, TimeSpan.FromSeconds(1), FSEventStreamCreateFlags.FileEvents | FSEventStreamCreateFlags.IgnoreSelf); fsEventStream.Events += handleEvents; fsEventStream.ScheduleWithRunLoop(NSRunLoop.Current); fsEventStream.Start(); }
void StartMonitoringExternalCssChanges() { if (fsEventStream != null) { return; } var monitorPaths = new [] { ClientApp.SharedInstance.WebServer.SourceBasePath.FullPath }; Log.Info(TAG, $"Starting CSS monitor for paths: {string.Join (", ", monitorPaths)}"); fsEventStream = new FSEventStream( monitorPaths, TimeSpan.FromSeconds(1), FSEventStreamCreateFlags.WatchRoot | FSEventStreamCreateFlags.FileEvents); fsEventStream.Events += HandleFSEventStreamEvents; fsEventStream.ScheduleWithRunLoop(NSRunLoop.Current); fsEventStream.Start(); }
public bool InitWatchFolder(string path) { try { this.path = path; TimeSpan eventLatency = TimeSpan.FromSeconds(1); //https://developer.apple.com/documentation/coreservices/file_system_events/1455376-fseventstreamcreateflags eventStream = new FSEventStream(new[] { path }, eventLatency, FSEventStreamCreateFlags.FileEvents | FSEventStreamCreateFlags.NoDefer); eventStream.Events += OnAppDataChanged; eventStream.ScheduleWithRunLoop(NSRunLoop.Current); Start(); return(true); } catch (Exception e) { this.path = null; return(false); } }
public override bool ReadFromUrl (NSUrl url, string typeName, out NSError outError) { fsEvents = new FSEventStream (new [] { Path.GetDirectoryName (url.Path) }, TimeSpan.FromSeconds (0), FSEventStreamCreateFlags.FileEvents); fsEvents.Events += (sender, e) => { foreach (var evnt in e.Events) { if (evnt.Path == url.Path && (evnt.Flags & FSEventStreamEventFlags.ItemModified) != 0) { ReloadDocument (); break; } } }; fsEvents.ScheduleWithRunLoop (NSRunLoop.Current); fsEvents.Start (); documentUrl = url; outError = null; return true; }
public override bool ReadFromUrl(NSUrl url, string typeName, out NSError outError) { fsEvents = new FSEventStream(new [] { Path.GetDirectoryName(url.Path) }, TimeSpan.FromSeconds(0), FSEventStreamCreateFlags.FileEvents); fsEvents.Events += (sender, e) => { foreach (var evnt in e.Events) { if (evnt.Path == url.Path && evnt.Flags.HasFlag(FSEventStreamEventFlags.ItemModified)) { ReloadDocument(); break; } } }; fsEvents.ScheduleWithRunLoop(NSRunLoop.Main); fsEvents.Start(); documentUrl = url; outError = null; return(true); }
void InitializeFSEventStream () { if (eventStream != null) { eventStream.Events -= OnFSEventStreamEvents; eventStream.Dispose (); eventStream = null; } if (Directory.Exists (currentWatchPath)) { Console.WriteLine ("Creating new FSEventStream: latency={0}, path={1}", eventLatency, currentWatchPath); eventStreamIsRunning = false; eventStream = new FSEventStream (new [] { currentWatchPath }, eventLatency, FSEventStreamCreateFlags.FileEvents); eventStream.Events += OnFSEventStreamEvents; eventStream.ScheduleWithRunLoop (NSRunLoop.Current); EventStreamView.DataSource = eventsDataSource = new FSEventDataSource (); ToggleFSEventStream (); } }
public void Create() { using var eventStream = new FSEventStream(new [] { Path.Combine(Environment.GetEnvironmentVariable("HOME"), "Desktop") }, TimeSpan.FromSeconds(5), FSEventStreamCreateFlags.FileEvents); }
/// <summary> /// Initializes a new instance of the <see cref="CmisSync.Lib.Sync.Strategy.MacWatcher"/> class. /// </summary> /// <param name="pathname">Path to be monitored.</param> /// <param name="queue">Queue to pass the new events to.</param> /// <param name="latency">Maximum latency for file system events.</param> public MacWatcher(string pathname, ISyncEventQueue queue, TimeSpan latency) { if (string.IsNullOrEmpty(pathname)) { throw new ArgumentNullException("pathname", "The given fs stream must not be null"); } if (queue == null) { throw new ArgumentNullException("queue", "The given queue must not be null"); } this.Queue = queue; this.RunLoopThread = new Thread(() => { this.RunLoop = NSRunLoop.Current; while (!this.StopRunLoop) { this.RunLoop.RunUntil(NSDate.FromTimeIntervalSinceNow(1)); this.CleanLastRenameEvent(); } }); this.RunLoopThread.Start(); while (RunLoop == null) { Thread.Sleep(10); } this.FsStream = new FSEventStream(new [] { pathname }, latency, FSEventStreamCreateFlags.FileEvents); this.EnableEvents = false; this.FsStream.ScheduleWithRunLoop(this.RunLoop); }