Esempio n. 1
0
            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);
            }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 private bool IsDeleteOfWatcherDirectory([NotNull] FakeSystemChangeEventArgs args, [NotNull] AbsolutePath pathInArgs)
 {
     return(args.ChangeType == WatcherChangeTypes.Deleted && args.Filters.HasFlag(NotifyFilters.DirectoryName) &&
            AbsolutePath.AreEquivalent(pathInArgs, directoryToWatch));
 }