Beispiel #1
0
        private void opencatalogToolStripButton_Click(object sender, EventArgs e)
        {
            if (ofdCatalog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            // Read the catalog from the file
            tsStatus.Text = "Reading catalog...";
            mFileName     = CCatalogNode.ReadBackupFilename(ofdCatalog.FileName);
            if (mFile != null)
            {
                mFile.Close();
            }
            mFile = new CBackupReader(mFileName);
            CCatalogNode node = CCatalogNode.ReadCatalog(ofdCatalog.FileName);

            // Populate tree view
            tvDirs.Nodes.Clear();
            tvDirs.Nodes.Add("root", node.Name, 0);
            tvDirs.Nodes[0].Tag = node;
            PopulateTreeView(tvDirs.Nodes[0], node);
            tsStatus.Text = "Select a single volume, folder or file to extract.";

            // UI cues
            extractToolStripButton.Enabled     = false;
            cancelToolStripButton.Enabled      = false;
            savecatalogToolStripButton.Enabled = true;
        }
Beispiel #2
0
        private void extractToolStripButton_Click(object sender, EventArgs e)
        {
            if (tvDirs.SelectedNode == null)
            {
                return;
            }

            // Get the selected catalog node from tree node tag
            CCatalogNode node = (CCatalogNode)tvDirs.SelectedNode.Tag;

            if (node == null)
            {
                return;
            }
            if ((node.Type == ENodeType.Root) || (node.Type == ENodeType.Set))
            {
                return;
            }

            // Get extraction path
            if (fbdBackup.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string TargetPath = fbdBackup.SelectedPath;

            // Extract the selected node and child nodes
            node.ExtractTo(mFile, TargetPath);
        }
        public CCatalogNode AddDatabase(CDatabaseDescriptorBlock descriptorBlock)
        {
            var cnode = new CCatalogNode(descriptorBlock, "Database - not yet implemented", ENodeType.Folder);

            cnode.mParent = this;
            mNodes.Add(cnode);
            return(cnode);
        }
        public CCatalogNode AddFolder(CDirectoryDescriptorBlock descriptorBlock, string nName)
        {
            var cnode = new CCatalogNode(descriptorBlock, nName, ENodeType.Folder);

            cnode.mParent = this;
            mNodes.Add(cnode);
            return(cnode);
        }
        public CCatalogNode AddFile(CFileDescriptorBlock descriptorBlock, string nName)
        {
            var cnode = new CCatalogNode(descriptorBlock, nName, ENodeType.File);

            cnode.mParent = this;
            mNodes.Add(cnode);
            return(cnode);
        }
        public CCatalogNode AddVolume(CVolumeDescriptorBlock descriptorBlock)
        {
            var cnode = new CCatalogNode(descriptorBlock, descriptorBlock.DeviceName, ENodeType.Volume);

            cnode.mParent = this;
            mNodes.Add(cnode);
            return(cnode);
        }
        public CCatalogNode AddSet(CStartOfDataSetDescriptorBlock descriptorBlock)
        {
            var name  = "Set: " + descriptorBlock.DataSetNumber + " - " + descriptorBlock.DataSetName;
            var cnode = new CCatalogNode(descriptorBlock, name, ENodeType.Set);

            cnode.mParent = this;
            mNodes.Add(cnode);
            return(cnode);
        }
 public CCatalogNode(CDescriptorBlock descriptorBlock, string nName, ENodeType nType)
 {
     mDescriptorBlock = descriptorBlock;
     mName            = nName;
     mType            = nType;
     mOffset          = descriptorBlock.StartPosition;
     mParent          = null;
     mNodes           = new System.Collections.Generic.List <CCatalogNode>();
 }
 public CCatalogNode()
 {
     mDescriptorBlock = null;
     mName            = "";
     mType            = ENodeType.Root;
     mOffset          = 0;
     mParent          = null;
     mNodes           = new System.Collections.Generic.List <CCatalogNode>();
 }
        /// <summary>
        /// Saves the catalog to the disk.
        /// </summary>
        public static void SaveCatalog(string Filename, CCatalogNode Node, string BackupFilename)
        {
            // Open the file
            System.IO.BinaryWriter file = new System.IO.BinaryWriter(new System.IO.FileStream(Filename, System.IO.FileMode.Create, System.IO.FileAccess.Write));

            // Write full path to backup file
            file.Write(BackupFilename);

            // Write nodes
            Node.SaveNode(file);

            // Close the file
            file.Close();
        }
        private void ReadNode(System.IO.BinaryReader file)
        {
            // Read node info
            mType   = (ENodeType)file.ReadInt32();
            mName   = file.ReadString();
            mOffset = file.ReadInt64();
            int count = file.ReadInt32();

            // Recursively read child nodes
            for (int i = 0; i < count; i++)
            {
                CCatalogNode node = new CCatalogNode();
                mNodes.Add(node);
                node.ReadNode(file);
            }
        }
Beispiel #12
0
        private void savecatalogToolStripButton_Click(object sender, EventArgs e)
        {
            if (tvDirs.Nodes.Count == 0)
            {
                return;
            }
            if (tvDirs.Nodes[0].Tag == null)
            {
                return;
            }
            if (sfdCatalog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            // Save the catalog to the file
            CCatalogNode.SaveCatalog(sfdCatalog.FileName, (CCatalogNode)tvDirs.Nodes[0].Tag, mFileName);
        }
        /// <summary>
        /// Reads the catalog from the disk.
        /// </summary>
        public static CCatalogNode ReadCatalog(string filename)
        {
            // Create the root node
            var node = new CCatalogNode();

            // Open the file
            System.IO.BinaryReader file = new System.IO.BinaryReader(new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read));

            // Read backup file name
            file.ReadString();

            // Read nodes
            node.ReadNode(file);

            // Close the file
            file.Close();

            return(node);
        }
Beispiel #14
0
 private void PopulateTreeView(TreeNode TNode, CCatalogNode CNode)
 {
     foreach (CCatalogNode node in CNode.Children)
     {
         TreeNode snode = new TreeNode(node.Name);
         if (node.Type == ENodeType.Set)
         {
             snode.ImageIndex         = 1;
             snode.SelectedImageIndex = 1;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         else if (node.Type == ENodeType.Volume)
         {
             snode.ImageIndex         = 2;
             snode.SelectedImageIndex = 2;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         else if (node.Type == ENodeType.Folder)
         {
             snode.ImageIndex         = 3;
             snode.SelectedImageIndex = 3;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         else if (node.Type == ENodeType.File)
         {
             snode.ImageIndex         = 4;
             snode.SelectedImageIndex = 4;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         else if (node.Type == ENodeType.Database)
         {
             snode.ImageIndex         = 3;
             snode.SelectedImageIndex = 3;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         PopulateTreeView(snode, node);
     }
 }
Beispiel #15
0
        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            if (ofdBackup.ShowDialog() == DialogResult.OK)
            {
                // Open the backup file
                mFileName     = ofdBackup.FileName;
                tsStatus.Text = "Reading " + mFileName;

                // UI cues
                openToolStripButton.Enabled        = false;
                extractToolStripButton.Enabled     = false;
                cancelToolStripButton.Enabled      = true;
                opencatalogToolStripButton.Enabled = false;
                savecatalogToolStripButton.Enabled = false;

                // Open and read the catalog
                if (mFile != null)
                {
                    mFile.Close();
                }
                mFile = new CBackupReader(mFileName);
                mFile.OnProgressChange += new CBackupReader.ProgressChange(mFile_OnProgressChange);
                CCatalogNode node = mFile.ReadCatalog();

                // Populate tree view
                tvDirs.Nodes.Clear();
                tvDirs.Nodes.Add("root", node.Name, 0);
                tvDirs.Nodes[0].Tag = node;
                PopulateTreeView(tvDirs.Nodes[0], node);
                tsStatus.Text = "Select a single volume, folder or file to extract.";

                // UI cues
                openToolStripButton.Enabled        = true;
                extractToolStripButton.Enabled     = false;
                cancelToolStripButton.Enabled      = false;
                savecatalogToolStripButton.Enabled = true;
                opencatalogToolStripButton.Enabled = true;
                savecatalogToolStripButton.Enabled = true;
            }
        }
Beispiel #16
0
        private void tvDirs_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // Get the selected catalog node from tree node tag
            CCatalogNode node = (CCatalogNode)tvDirs.SelectedNode.Tag;

            if (node == null)
            {
                return;
            }
            if (node.Type != ENodeType.File)
            {
                return;
            }

            // Extract the selected node to a temporary folder
            string TargetPath = System.IO.Path.GetTempPath();

            node.ExtractTo(mFile, TargetPath);

            // Open the file
            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(TargetPath + node.Name);
            psi.UseShellExecute         = true;
            psi.ErrorDialog             = true;
            psi.ErrorDialogParentHandle = this.Handle;
            try
            {
                System.Diagnostics.Process.Start(psi);
            }
            catch (Win32Exception ex)
            {
                MessageBox.Show(this, "Could not open the file '" + node.Name + "'." + ex.ToString(), "Backup Reader", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #17
0
        private void tvDirs_AfterSelect(object sender, TreeViewEventArgs e)
        {
            extractToolStripButton.Enabled = false;

            if (tvDirs.SelectedNode == null)
            {
                return;
            }

            // Get the selected catalog node from tree node tag
            CCatalogNode node = (CCatalogNode)tvDirs.SelectedNode.Tag;

            if (node == null)
            {
                return;
            }
            if ((node.Type == ENodeType.Root) || (node.Type == ENodeType.Set))
            {
                return;
            }

            extractToolStripButton.Enabled = true;
        }
Beispiel #18
0
 private void PopulateTreeView(TreeNode TNode, CCatalogNode CNode)
 {
     foreach (CCatalogNode node in CNode.Children)
     {
         TreeNode snode = new TreeNode(node.Name);
         if (node.Type == ENodeType.Set)
         {
             snode.ImageIndex = 1;
             snode.SelectedImageIndex = 1;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         else if (node.Type == ENodeType.Volume)
         {
             snode.ImageIndex = 2;
             snode.SelectedImageIndex = 2;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         else if (node.Type == ENodeType.Folder)
         {
             snode.ImageIndex = 3;
             snode.SelectedImageIndex = 3;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         else if (node.Type == ENodeType.File)
         {
             snode.ImageIndex = 4;
             snode.SelectedImageIndex = 4;
             snode.Tag = node;
             TNode.Nodes.Add(snode);
         }
         PopulateTreeView(snode, node);
     }
 }