Exemple #1
0
 public IEnumerable <FsPathAndFileStatusPair> ListFilesRecursive(FsPath path, RecursiveFileListingParameters parameters)
 {
     foreach (var page in ListFilesRecursivePaged(path, parameters))
     {
         foreach (var filestatus in page.FileItems)
         {
             var item = new FsPathAndFileStatusPair(page.Path, filestatus);
             yield return(item);
         }
     }
 }
        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);
        }
Exemple #3
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);
                        }
                    }
                }
            }
        }