public FakeFileSystemVersionedChange([NotNull] FakeSystemChangeEventArgs args, [NotNull] AbsolutePath pathInArgs, [CanBeNull] AbsolutePath previousPathInRenameInArgs, [NotNull] AbsolutePath basePath, int version, bool isDeleteOfWatcherDirectory) { Guard.NotNull(args, nameof(args)); ChangeType = args.ChangeType; Version = version; IsDeleteOfWatcherDirectory = isDeleteOfWatcherDirectory; RootDirectory = basePath; RelativePath = pathInArgs.MakeRelativeTo(basePath); PreviousRelativePathInRename = previousPathInRenameInArgs?.MakeRelativeTo(basePath); }
private bool MatchesFilters([NotNull] FakeSystemChangeEventArgs args, [NotNull] AbsolutePath pathInArgs, [CanBeNull] AbsolutePath previousPathInRenameInArgs, [NotNull] AbsolutePath watchDirectory) { if (!MatchesNotifyFilter(args.Filters)) { return(false); } if (!MatchesIncludeSubdirectories(pathInArgs, watchDirectory)) { return(false); } if (!MatchesPattern(pathInArgs, previousPathInRenameInArgs)) { return(false); } return(true); }
private void HandleFileSystemChange([CanBeNull] object sender, [NotNull] FakeSystemChangeEventArgs args) { Guard.NotNull(args, nameof(args)); lock (lockObject) { if (state == WatcherState.Active) { AbsolutePath pathInArgs = args.PathFormatter.GetPath(); AbsolutePath previousPathInRenameInArgs = args.PreviousPathInRenameFormatter?.GetPath(); AbsolutePath directoryToWatchSnapshot = directoryToWatch; if (directoryToWatchSnapshot != null) { if (IsDeleteOfWatcherDirectory(args, pathInArgs)) { producerConsumerQueue.Add(new FakeFileSystemVersionedChange(args, pathInArgs, null, directoryToWatchSnapshot, version, true)); } if (!hasBufferOverflow) { if (producerConsumerQueue.Count >= InternalBufferSize / NumBytesPerChange) { hasBufferOverflow = true; version++; } else { if (MatchesFilters(args, pathInArgs, previousPathInRenameInArgs, directoryToWatchSnapshot)) { producerConsumerQueue.Add(new FakeFileSystemVersionedChange(args, pathInArgs, previousPathInRenameInArgs, directoryToWatchSnapshot, version, false)); } } } } } } }
private bool IsDeleteOfWatcherDirectory([NotNull] FakeSystemChangeEventArgs args, [NotNull] AbsolutePath pathInArgs) { return(args.ChangeType == WatcherChangeTypes.Deleted && args.Filters.HasFlag(NotifyFilters.DirectoryName) && AbsolutePath.AreEquivalent(pathInArgs, directoryToWatch)); }