Esempio n. 1
0
        private void make_tree(FileIndexorNode fn, TreeNode tn, UInt64 total_size, string root_path)
        {
            var list = fn.Nodes;

            list.Sort((a, b) => b.GetTotalSize().CompareTo(a.GetTotalSize()));

            foreach (FileIndexorNode n in list)
            {
                string tag       = Path.GetFileName(n.Path.Remove(n.Path.Length - 1));
                string full_path = Path.Combine(root_path, n.Path);
                if (!filesize)
                {
                    make_node(tn.Nodes, $"[{((double)n.GetTotalSize() * 100 / total_size).ToString("0.0") + "%"}] {tag}", full_path);
                }
                else
                {
                    make_node(tn.Nodes, $"[{CapacityFormat(n.GetTotalSize())}] {tag}", full_path);
                }
                make_tree(n, tn.Nodes[tn.Nodes.Count - 1], total_size, Path.Combine(root_path, n.Path));
            }

            if (cbFileIndexing.Checked)
            {
                var file_list = fn.Files; //new DirectoryInfo(fn.Path).GetFiles().ToList();
                file_list.Sort((a, b) => b.Length.CompareTo(a.Length));
                foreach (FileInfo f in file_list)
                {
                    make_node(tn.Nodes, $"[{((double)f.Length * 100 / total_size).ToString("0.0") + "%"}] {f.Name}", Path.Combine(root_path, f.Name), true);
                }
            }
        }
Esempio n. 2
0
        private void Processing()
        {
            int    i          = 1;
            UInt64 total_size = indexor.GetTotalSize();
            UInt64 acc_size   = 0;

            this.Post(() => label2.Text = $"{CapacityFormat(total_size)} ({total_size.ToString("#,0")} 바이트)");
            List <ListViewItem> l = new List <ListViewItem>();

            this.Post(() => pbIndexing.Maximum = indexor.Count);
            foreach (var v in indexor.GetListSortWithNativeSize())
            {
                acc_size += v.Item2;
                l.Add(new ListViewItem(new string[] { i++.ToString(), v.Item1,
                                                      CapacityFormat(v.Item2), ((double)v.Item2 * 100 / total_size).ToString("0.0") + "%",
                                                      ((double)acc_size * 100 / total_size).ToString("0.0") + "%" }));
                this.Post(() => pbIndexing.Value++);
            }
            this.Post(() => listView1.Items.AddRange(l.ToArray()));

            FileIndexorNode node = null;

            i    = 1;
            node = indexor.GetPathNode(indexor.Node.Path);
            foreach (FileIndexorNode n in node.GetListSortWithSize())
            {
                this.Post(() => listView2.Items.Add(new ListViewItem(new string[] { i++.ToString(), n.Path, CapacityFormat(n.Size),
                                                                                    ((double)n.Size * 100 / node.Size).ToString("0.0") + "%",
                                                                                    ((double)n.Size * 100 / indexor.GetTotalSize()).ToString("0.0") + "%" })));
            }
            this.Post(() => SetStatusMessage(StatusMessage.EndIndexing));
            Task.Run(() => ProcessingTreeView());
        }
Esempio n. 3
0
 private void make_tree(FileIndexorNode fn, TreeNode tn)
 {
     foreach (FileIndexorNode n in fn.Nodes)
     {
         make_node(tn.Nodes, Path.GetFileName(n.Path.Remove(n.Path.Length - 1)));
         make_tree(n, tn.Nodes[tn.Nodes.Count - 1]);
     }
     foreach (FileInfo f in new DirectoryInfo(fn.Path).GetFiles())
     {
         make_node(tn.Nodes, f.Name);
     }
 }
Esempio n. 4
0
        private void listing(FileIndexor fi)
        {
            FileIndexorNode node = fi.GetRootNode();

            foreach (FileIndexorNode n in node.Nodes)
            {
                make_node(PathTree.Nodes, Path.GetFileName(n.Path.Remove(n.Path.Length - 1)));
                make_tree(n, PathTree.Nodes[PathTree.Nodes.Count - 1]);
            }
            foreach (FileInfo f in new DirectoryInfo(node.Path).GetFiles())
            {
                make_node(PathTree.Nodes, f.Name);
            }
        }
Esempio n. 5
0
 static void internal_listing(FileIndexorNode node, bool with_files)
 {
     foreach (FileIndexorNode n in node.Nodes)
     {
         Console.Instance.WriteLine(n.Path);
         internal_listing(n, with_files);
     }
     if (with_files)
     {
         foreach (FileInfo f in new DirectoryInfo(node.Path).GetFiles())
         {
             Console.Instance.WriteLine(f.FullName);
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 특정된 옵션에 따라 파일 또는 폴더를 나열합니다.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="recursive"></param>
        /// <param name="with_files"></param>
        static void ProcessDirectory(string[] args, bool recursive, bool with_files)
        {
            Console.Instance.GlobalTask.Add(Task.Run(async() =>
            {
                if (!Directory.Exists(args[0]))
                {
                    Console.Instance.WriteErrorLine($"'{args[0]}' is not valid directory name.");
                    return;
                }

                if (!recursive)
                {
                    foreach (DirectoryInfo d in new DirectoryInfo(args[0]).GetDirectories())
                    {
                        Console.Instance.WriteLine(d.FullName);
                    }

                    if (with_files)
                    {
                        foreach (FileInfo f in new DirectoryInfo(args[0]).GetFiles())
                        {
                            Console.Instance.WriteLine(f.FullName);
                        }
                    }
                }
                else
                {
                    var indexor = new FileIndexor();
                    await indexor.ListingDirectoryAsync(args[0]);

                    FileIndexorNode node = indexor.GetRootNode();
                    foreach (FileIndexorNode n in node.Nodes)
                    {
                        Console.Instance.WriteLine(n.Path);
                        internal_listing(n, with_files);
                    }
                    if (with_files)
                    {
                        foreach (FileInfo f in new DirectoryInfo(node.Path).GetFiles())
                        {
                            Console.Instance.WriteLine(f.FullName);
                        }
                    }
                }
            }));
        }
Esempio n. 7
0
 private void async_end(IAsyncResult ar)
 {
     this.BeginInvoke((Action) delegate()
     {
         FileIndexorNode node = fx.GetPathNode(tbPath.Text);
         foreach (FileIndexorNode n in node.Nodes)
         {
             make_node(tvTags.Nodes, Path.GetFileName(n.Path.Remove(n.Path.Length - 1)));
             make_tree(n, tvTags.Nodes[tvTags.Nodes.Count - 1]);
         }
         foreach (FileInfo f in new DirectoryInfo(node.Path).GetFiles())
         {
             make_node(tvTags.Nodes, f.Name);
         }
         color_node(tvTags.Nodes);
         UpdateTagsRank();
         UpdateManage();
         EnableControl();
     });
 }
Esempio n. 8
0
        private void ProcessingTreeView()
        {
            FileIndexorNode node       = indexor.GetRootNode();
            UInt64          total_size = indexor.GetTotalSize();
            var             list       = node.Nodes;

            list.Sort((a, b) => b.GetTotalSize().CompareTo(a.GetTotalSize()));

            string   root_path = indexor.GetRootNode().Path;
            TreeNode root      = new TreeNode($"[100.0%] {root_path}");

            root.Tag = root_path;

            foreach (FileIndexorNode n in list)
            {
                string tag       = Path.GetFileName(n.Path.Remove(n.Path.Length - 1));
                string full_path = Path.Combine(root_path, n.Path);
                if (!filesize)
                {
                    make_node(root.Nodes, $"[{((double)n.GetTotalSize() * 100 / total_size).ToString("0.0") + "%"}] {tag}", full_path);
                }
                else
                {
                    make_node(root.Nodes, $"[{CapacityFormat(n.GetTotalSize())}] {tag}", full_path);
                }
                make_tree(n, root.Nodes[root.Nodes.Count - 1], total_size, full_path);
            }

            if (cbFileIndexing.Checked)
            {
                var file_list = node.Files; //new DirectoryInfo(fn.Path).GetFiles().ToList();
                file_list.Sort((a, b) => b.Length.CompareTo(a.Length));
                foreach (FileInfo f in file_list)
                {
                    make_node(root.Nodes, $"[{((double)f.Length * 100 / total_size).ToString("0.0") + "%"}] {f.Name}", Path.Combine(root_path, f.Name), true);
                }
            }

            this.Post(() => tvFs.Nodes.Add(root));
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
        }
Esempio n. 9
0
        private void listView2_DoubleClick(object sender, EventArgs e)
        {
            if (listView2.SelectedItems.Count > 0)
            {
                string          selected_path = listView2.SelectedItems[0].SubItems[1].Text;
                bool            c             = listView2.SelectedItems[0].SubItems[0].Text == "..";
                FileIndexorNode node          = null;

                listView2.Items.Clear();
                if (c)
                {
                    string peek = ss.Pop();
                    if (peek == null)
                    {
                        peek = indexor.GetRootNode().Path;
                    }
                    node = indexor.GetPathNode(peek);
                    if (ss.Count != 0)
                    {
                        listView2.Items.Add(new ListViewItem(new string[] { "..", peek }));
                    }
                    now_path = peek;
                }
                else
                {
                    node = indexor.GetPathNode(selected_path);
                    listView2.Items.Add(new ListViewItem(new string[] { "..", now_path }));
                    ss.Push(now_path);
                    now_path = selected_path;
                }

                int i = 1;
                foreach (FileIndexorNode n in node.GetListSortWithSize())
                {
                    listView2.Items.Add(new ListViewItem(new string[] { i++.ToString(), n.Path, CapacityFormat(n.Size),
                                                                        ((double)n.Size * 100 / node.Size).ToString("0.0") + "%",
                                                                        ((double)n.Size * 100 / indexor.GetTotalSize()).ToString("0.0") + "%" }));
                }
            }
        }