예제 #1
0
        private void Delete(string path)
        {
            var pathSegments = path.SplitByDirectorySeparator();

            if (DeleteFile(path, pathSegments))
            {
                return;
            }

            var foundFilesInfo = filesInfo.Search(pathSegments, 0).ToList();

            foreach (var(filePathSegments, fileInfo) in foundFilesInfo)
            {
                DeleteFile(fileInfo.Path, filePathSegments);
            }

            log.TraceFormat("Directory {Path} with {FilesCount} was deleted", path, foundFilesInfo.Count);
        }
예제 #2
0
        public void Test()
        {
            var root = new SegmentTreeNode<int>(StringComparer.InvariantCultureIgnoreCase);

            root.Search(new[] {"a"}, 0).Should().BeEmpty();
            root.Add(new[] {"a", "b", "c"}, 0, 42).Should().BeTrue();
            root.Search(new[] {"a"}, 0).Should().BeEquivalentTo((new[] {"a", "b", "c"}, 42));
            root.Search(new[] {"a", "b"}, 0).Should().BeEquivalentTo((new[] {"a", "b", "c"}, 42));
            root.Search(new[] {"a", "b", "c"}, 0).Should().BeEquivalentTo((new[] {"a", "b", "c"}, 42));
            root.Search(new[] {"a", "b", "c", "d"}, 0).Should().BeEmpty();
            root.Add(new[] {"a", "b"}, 0, 42).Should().BeFalse();
            root.Delete(new[] {"a", "b", "c"}, 0).Should().BeTrue();
            root.Search(new[] {"a"}, 0).Should().BeEmpty();
        }