private void bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            for (int i = 0; i < files.Count; i++)
            {
                currentFile = files[i];
                currentPath = targetPath + System.IO.Path.DirectorySeparatorChar + FIB.ProcessPath(currentFile.Path);
                string target_dir = System.IO.Path.GetDirectoryName(currentPath);

                try
                {
                    if (!System.IO.Directory.Exists(target_dir))
                    {
                        System.IO.Directory.CreateDirectory(target_dir);
                    }
                    currentFile.Extract(currentPath);
                    filesCompleted++;
                }
                catch (Exception ex)
                {
                    DialogResult result = MessageBox.Show(String.Format("Cannot extract file '{0}': {1}", currentFile.Filename, ex.Message), "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        this.DialogResult = DialogResult.Cancel;
                        return;
                    }
                    else
                    {
                        i--;
                    }
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Exemple #2
0
        private void ExtractAndOpen(string filePath)
        {
            // Find the file.
            RCH2File file = FindFileByPath(filePath);

            if (file == null)
            {
                MessageBox.Show("Cannot find specified path in the internal lists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Extract to temporary folder.
            string targetPath = FIB.GetTemporaryPath(System.IO.Path.GetFileName(FIB.ProcessPath(file.Filename)));

            try
            {
                file.Extract(targetPath);
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName = targetPath;
                proc.Start();
                FIB.DelSchedule(targetPath);
            }
            catch (Exception e)
            {
                MessageBox.Show("Cannot extract file: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     for (int i = 0; i < rch2.Files.Count; i++)
     {
         RCH2File file = rch2.Files[i];
         if ((Results[file.Path] = file.CRCVerified) == true)
         {
             nPassed++;
         }
     }
 }
Exemple #4
0
 //--- List Context Menu: "Validate CRC32" option selected.
 private void validateCRC32ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CheckSelection();
     foreach (DataGridViewRow row in dgvInstallerList.SelectedRows)
     {
         RCH2File file = FindFileByPath((string)row.Cells[0].Value);
         if (file == null)
         {
             MessageBox.Show("Unknown file: " + file.Path, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         SetCellCRC(row.Cells[3], file.CRCVerified);
     }
 }
Exemple #5
0
        private string GenerateReport()
        {
            StringBuilder buffer = new StringBuilder();

            buffer.AppendLine(String.Format("--- Installer Comparison: {0} --> {1}", FileName1, FileName2));

            // Store identical filenames if necessary.
            if (cbShowIdentical.Checked)
            {
                buffer.AppendLine("= Identical files");
                foreach (RCH2File file in CompareInstance.IdenticalFiles)
                {
                    buffer.AppendLine(String.Format("{0,8:x} [{1,8}] {2}", file.CRCSum, file.Size, file.Path));
                }
                buffer.AppendLine();
            }

            // Store different filenames if necessary.
            if (cbDifferent.Checked)
            {
                buffer.AppendLine("= Different files");
                foreach (RCH2File file in CompareInstance.File1.DifferentFiles)
                {
                    RCH2File file2 = FIB.FindFileByPath(CompareInstance.File2.Container, file.Path);
                    buffer.AppendLine(file.Path);
                    buffer.AppendLine(String.Format("   - CRC32: {0,8:x} --> {1,8:x}", file.CRCSum, file2.CRCSum));
                    buffer.AppendLine(String.Format("   - Size:  {0,8} --> {1,8}", file.Size, file2.Size));
                }
                buffer.AppendLine();
            }

            // Store unique filenames if necessary.
            if (cbUnique.Checked)
            {
                buffer.AppendLine("= Unique files");
                foreach (RCH2File file in CompareInstance.File1.UniqueFiles)
                {
                    buffer.AppendLine("- " + file.Path);
                }
                foreach (RCH2File file in CompareInstance.File2.UniqueFiles)
                {
                    buffer.AppendLine("+ " + file.Path);
                }
            }

            return(buffer.ToString());
        }
Exemple #6
0
        /*** Methods - UI Updates ***/
        private void UpdateList()
        {
            if (rch2 == null)
            {
                return;
            }

            dgvInstallerList.SuspendLayout();
            dgvInstallerList.Rows.Clear();
            dgvInstallerList.Rows.Add(rch2.Count);
            for (int i = 0; i < rch2.Files.Count; i++)
            {
                RCH2File file = rch2.Files[i];
                dgvInstallerList.Rows[i].Cells[0].Value = file.Path;
                dgvInstallerList.Rows[i].Cells[1].Value = file.Size;
                dgvInstallerList.Rows[i].Cells[2].Value = String.Format("{0:x8}", file.CRCSum);
                dgvInstallerList.Rows[i].Cells[3].Value = "";
            }
            dgvInstallerList.ResumeLayout();
        }
Exemple #7
0
        private void bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bw            = sender as BackgroundWorker;
            bool             showIdentical = cbShowIdentical.Checked;
            bool             showDifferent = cbDifferent.Checked;
            bool             showUnique    = cbUnique.Checked;
            string           targetPath    = (string)e.Argument;

            extractCurrentFile = 0;
            extractTotalFiles  =
                (showIdentical ? CompareInstance.IdenticalFiles.Count : 0) +
                (showDifferent ? CompareInstance.File1.DifferentFiles.Count + CompareInstance.File2.DifferentFiles.Count : 0) +
                (showUnique ? CompareInstance.File1.UniqueFiles.Count + CompareInstance.File2.UniqueFiles.Count : 0);

            // Create File1 and File2 folders.
            string file1path = targetPath + Path.DirectorySeparatorChar + FileName1;
            string file2path = targetPath + Path.DirectorySeparatorChar + FileName2;

            Directory.CreateDirectory(file1path);
            Directory.CreateDirectory(file2path);

            // Extract the files mentioned.
            if (showIdentical)
            {
                foreach (RCH2File file in CompareInstance.IdenticalFiles)
                {
                    string processedPath = FIB.ProcessPath(file.Path);
                    string file1full     = file1path + Path.DirectorySeparatorChar + processedPath;
                    string file2full     = file2path + Path.DirectorySeparatorChar + processedPath;
                    Directory.CreateDirectory(Path.GetDirectoryName(file1full));
                    Directory.CreateDirectory(Path.GetDirectoryName(file2full));

                    file.Extract(file1full);
                    File.Copy(file1full, file2full, true);
                    extractCurrentFile++;

                    if (bw.CancellationPending)
                    {
                        goto bgwCancel;
                    }
                }
            }

            if (showDifferent)
            {
                foreach (RCH2File file in CompareInstance.File1.DifferentFiles)
                {
                    RCH2File file2         = FIB.FindFileByPath(CompareInstance.File2.Container, file.Path);
                    string   processedPath = FIB.ProcessPath(file.Path);
                    string   file1full     = file1path + Path.DirectorySeparatorChar + processedPath;
                    string   file2full     = file2path + Path.DirectorySeparatorChar + processedPath;
                    Directory.CreateDirectory(Path.GetDirectoryName(file1full));
                    Directory.CreateDirectory(Path.GetDirectoryName(file2full));

                    file.Extract(file1full);
                    file2.Extract(file2full);
                    extractCurrentFile += 2;

                    if (bw.CancellationPending)
                    {
                        goto bgwCancel;
                    }
                }
            }

            if (showUnique)
            {
                bool flag = true;
                foreach (List <RCH2File> list in new List <RCH2File>[] { CompareInstance.File1.UniqueFiles, CompareInstance.File2.UniqueFiles })
                {
                    foreach (RCH2File file in list)
                    {
                        string full = (flag ? file1path : file2path) + Path.DirectorySeparatorChar + FIB.ProcessPath(file.Path);
                        Directory.CreateDirectory(Path.GetDirectoryName(full));
                        file.Extract(full);
                        extractCurrentFile++;

                        if (bw.CancellationPending)
                        {
                            goto bgwCancel;
                        }
                    }
                    flag = false;
                }
            }

            return;

bgwCancel:
            e.Cancel = true;
        }