Example #1
0
        public void FSPath_Constructor_Combine_Unrooted()
        {
            var p0 = new FsPath("test");
            var p1 = p0.Append("foo");
            var p2 = p0.Append("foo/bar");

            Assert.AreEqual("test", p0.ToString());
            Assert.AreEqual("test/foo", p1.ToString());
            Assert.AreEqual("test/foo/bar", p2.ToString());
            Assert.IsFalse(p0.IsRooted);
            Assert.IsFalse(p1.IsRooted);
            Assert.IsFalse(p2.IsRooted);
        }
Example #2
0
        public IEnumerable <FsFileStatusPage> ListFilesRecursivePaged(FsPath path, FileListingParameters parameters)
        {
            var queue = new Queue <FsPath>();

            queue.Enqueue(path);

            while (queue.Count > 0)
            {
                FsPath cur_path = queue.Dequeue();

                foreach (var page in ListFilesPaged(cur_path, parameters))
                {
                    yield return(page);

                    foreach (var item in page.FileItems)
                    {
                        if (item.Type == MSADLS.Models.FileType.DIRECTORY)
                        {
                            var new_path = cur_path.Append(item.PathSuffix);
                            queue.Enqueue(new_path);
                        }
                    }
                }
            }
        }
        public void List_Files_Recursive()
        {
            this.Initialize();

            int page_count  = 0;
            int child_count = 0;

            var lfo = new FileListingParameters();

            lfo.PageSize = 4;

            var folder = new FsPath("/test_adl_demo_client/List_Files_Recursive");

            if (StoreClient.FileSystem.FolderExists(folder))
            {
                StoreClient.FileSystem.Delete(folder, true);
            }

            var bytes = new byte[0];
            var fcp   = new AdlClient.Models.FileCreateParameters();

            StoreClient.FileSystem.Create(folder.Append("f1"), bytes, fcp);
            StoreClient.FileSystem.Create(folder.Append("f2"), bytes, fcp);
            StoreClient.FileSystem.Create(folder.Append("a/f3"), bytes, fcp);
            StoreClient.FileSystem.Create(folder.Append("a/f4"), bytes, fcp);
            StoreClient.FileSystem.Create(folder.Append("a/b/f5"), bytes, fcp);
            StoreClient.FileSystem.Create(folder.Append("a/b/f6"), bytes, fcp);
            StoreClient.FileSystem.CreateDirectory(folder.Append("b"));

            var rlfo = new RecursiveFileListingParameters();

            rlfo.PageSize = 4;

            var pages = this.StoreClient.FileSystem.ListFilesRecursivePaged(folder, rlfo);

            foreach (var page in pages)
            {
                foreach (var child in page.FileItems)
                {
                    child_count++;
                }
                page_count++;
            }

            Assert.AreEqual(3, page_count);
            Assert.AreEqual(9, child_count);
        }
Example #4
0
        public IEnumerable <FsFileStatusPage> ListFilesRecursivePaged(FsPath path, RecursiveFileListingParameters parameters)
        {
            var queue = new Queue <FsPath>();

            queue.Enqueue(path);

            var flp = new FileListingParameters();

            flp.PageSize = parameters.PageSize;
            flp.Top      = 0;

            int count = 0;

            while (queue.Count > 0)
            {
                FsPath cur_path = queue.Dequeue();

                foreach (var page in ListFilesPaged(cur_path, flp))
                {
                    yield return(page);

                    count += page.FileItems.Count;

                    if (parameters.Top > 0 && count >= parameters.Top)
                    {
                        break;
                    }

                    foreach (var item in page.FileItems)
                    {
                        if (item.Type == MSADLS.Models.FileType.DIRECTORY)
                        {
                            var new_path = cur_path.Append(item.PathSuffix);
                            queue.Enqueue(new_path);
                        }
                    }
                }
            }
        }