Example #1
0
        private static void AddAllDirectoriesToTree(TreeNode parent, BobFsNode node)
        {
            foreach (KeyValuePair <string, BobFsNode> childNode in node.Contents)
            {
                if (!childNode.Value.IsDirectory)
                {
                    continue;
                }

                TreeNode currentNode = new TreeNode(childNode.Key, 0, 0);
                currentNode.Tag = childNode;
                parent.Nodes.Add(currentNode);

                AddAllDirectoriesToTree(currentNode, childNode.Value);
            }
        }
Example #2
0
        private void PopulateExplorerList(BobFsNode directory)
        {
            _curDirectory = directory;

            _currentDirTotalSize = 0;
            ExplorerList.Items.Clear();
            foreach (KeyValuePair <string, BobFsNode> childNode in directory.Contents)
            {
                ListViewItem currentItem = new ListViewItem(new string[] { childNode.Key, childNode.Value.Size.ToString(), childNode.Value.NumLinks.ToString() }, (int)childNode.Value.Type - 1);
                currentItem.Tag = childNode;
                ExplorerList.Items.Add(currentItem);

                _currentDirTotalSize += (int)childNode.Value.Size;
            }

            RecalculateStatus();
        }
Example #3
0
 // Requires caller to commit changes to parent
 private void AddContents(BobFsNode parent, string path)
 {
     if (File.Exists(path))
     {
         BobFsNode newFile      = parent.NewFile(Path.GetFileName(path));
         byte[]    fileContents = File.ReadAllBytes(path);
         newFile.WriteAll(0, fileContents, 0, fileContents.Length);
         newFile.Commit();
     }
     else if (Directory.Exists(path))
     {
         BobFsNode newDir = parent.NewDirectory(Path.GetFileName(path));
         foreach (string dirEntry in Directory.EnumerateFileSystemEntries(path))
         {
             AddContents(newDir, dirEntry);
         }
         newDir.Commit();
     }
 }