Ejemplo n.º 1
0
        /// <inheritdoc />
        protected override IFileSystemWatcher WatchImpl(UPath path)
        {
            // TODO: create/delete events when mounts are added/removed

            var watcher = new AggregateFileSystemWatcher(this, path);

            lock (_mounts)
                lock (_aggregateWatchers)
                {
                    foreach (var kvp in _mounts)
                    {
                        if (!IsMountIncludedInWatch(kvp.Key, path, out var remainingPath))
                        {
                            continue;
                        }

                        if (kvp.Value.CanWatch(remainingPath))
                        {
                            var internalWatcher = kvp.Value.Watch(remainingPath);
                            watcher.Add(new Watcher(kvp.Value, kvp.Key, remainingPath, internalWatcher));
                        }
                    }

                    if (NextFileSystem != null && NextFileSystem.CanWatch(path))
                    {
                        var internalWatcher = NextFileSystem.Watch(path);
                        watcher.Add(new Watcher(NextFileSystem, null, path, internalWatcher));
                    }

                    _aggregateWatchers.Add(watcher);
                }

            return(watcher);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        protected override IFileSystemWatcher WatchImpl(UPath path)
        {
            lock (_fileSystems)
            {
                var watcher = new AggregateFileSystemWatcher(this, path);

                if (NextFileSystem != null && NextFileSystem.CanWatch(path))
                {
                    watcher.Add(NextFileSystem.Watch(path));
                }

                foreach (var fs in _fileSystems)
                {
                    if (fs.CanWatch(path))
                    {
                        watcher.Add(fs.Watch(path));
                    }
                }

                _watchers.Add(watcher);
                return(watcher);
            }
        }