protected override void internal_command_proc() { QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e); if (!(e.ItemCollection is ZipDirectory)) { return; } ZipDirectory zd = (ZipDirectory)e.ItemCollection; List <string> initial_sources = new List <string>(); string initial_zip_dir = zd.CurrentZipDirectory; if (initial_zip_dir.StartsWith("/")) { initial_zip_dir = initial_zip_dir.Substring(1); } if ((!initial_zip_dir.EndsWith("/")) && (initial_zip_dir != string.Empty)) { initial_zip_dir = initial_zip_dir + "/"; } if (e.SelectedIndices.Length == 0) { if (zd.GetItemDisplayName(e.FocusedIndex) == "..") { return; } initial_sources.Add(initial_zip_dir + zd.GetItemDisplayName(e.FocusedIndex)); } else { for (int i = 0; i < e.SelectedIndices.Length; i++) { initial_sources.Add(initial_zip_dir + zd.GetItemDisplayName(e.SelectedIndices[i])); } } //show dialog DeleteFileDialog dialog = new DeleteFileDialog(); dialog.Text = Options.GetLiteral(Options.LANG_DELETE); dialog.DeleteFileOptions = DeleteFileOptions.DeleteEmptyDirectories | DeleteFileOptions.DeleteReadonly | DeleteFileOptions.RecursiveDeleteFiles; dialog.textBoxMask.Text = "*"; dialog.checkBoxForceReadonly.Enabled = false; dialog.checkBoxRecursive.Enabled = false; dialog.checkBoxRemoveEmptyDirs.Enabled = false; if (dialog.ShowDialog() != DialogResult.OK) { return; } List <ZipEntry> del_list = new List <ZipEntry>(); create_delete_list(del_list, initial_sources, dialog.textBoxMask.Text, zd.ZipFile); mainForm main_win = (mainForm)Program.MainWindow; try { zd.ZipFile.BeginUpdate(); for (int i = 0; i < del_list.Count; i++) { main_win.NotifyLongOperation (string.Format (Options.GetLiteral(Options.LANG_DELETE_NOW_0), del_list[i].Name), true); zd.ZipFile.Delete(del_list[i]); } main_win.NotifyLongOperation(Options.GetLiteral(Options.LANG_COMMIT_ARCHIVE_UPDATES), true); zd.ZipFile.CommitUpdate(); zd.Refill(); } catch (Exception ex) { Messages.ShowException(ex); } finally { main_win.NotifyLongOperation("Done", false); } }
protected override void internal_command_proc() { QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs(); QueryPanelInfoEventArgs e_other = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e_current); OnQueryOtherPanel(e_other); //int buffer_size = 0x8000; if (!(e_other.ItemCollection is DirectoryList)) { Messages.ShowMessage (Options.GetLiteral(Options.LANG_WRONG_DESTINATION)); return; } DirectoryList dl = (DirectoryList)e_other.ItemCollection; string dest_dir = dl.DirectoryPath; ZipDirectory zd = (ZipDirectory)e_current.ItemCollection; ZipFile source_zip_file = zd.ZipFile; string zip_current_dir = zd.CurrentZipDirectory; ArchiveExtractOptions opts = Options.ArchiveExtractOptions; //show user dialog ExtractDialog dialog = new ExtractDialog(); dialog.ArchiveExtractOptions = opts; dialog.textBoxSourceMask.Text = "*"; dialog.Text = Options.GetLiteral(Options.LANG_EXTRACT); if (dialog.ShowDialog() != DialogResult.OK) { return; } //retrieve options opts = dialog.ArchiveExtractOptions; string dest_path = Path.Combine(dest_dir, dialog.textBoxDestination.Text); string source_mask = dialog.textBoxSourceMask.Text; Options.ArchiveExtractOptions = opts; //retrieve source list List <string> source_list = new List <string>(); if ((e_current.SelectedIndices.Length == 0) && (e_current.FocusedIndex != 0)) { //focused index==0 always ref to parent entry, so skip it source_list.Add(zd.GetItemDisplayName(e_current.FocusedIndex)); } else { for (int i = 0; i < e_current.SelectedIndices.Length; i++) { if (e_current.SelectedIndices[i] == 0) { continue; } source_list.Add(zd.GetItemDisplayName(e_current.SelectedIndices[i])); } } //prepare progress dialog dialog_progress = new CopyFileProgressDialog(); dialog_progress.labelError.Visible = false; dialog_progress.labelSpeed.Text = string.Empty; dialog_progress.labelStatus.Text = string.Empty; dialog_progress.labelStatusTotal.Text = string.Empty; dialog_progress.checkBoxCloseOnFinish.Checked = Options.CopyCloseProgress; dialog_progress.TopLevel = true; int x_center = Program.MainWindow.Left + Program.MainWindow.Width / 2; int y_center = Program.MainWindow.Top + Program.MainWindow.Height / 2; int x_dialog = x_center - dialog_progress.Width / 2; int y_dialog = y_center - dialog_progress.Height / 2; if (x_dialog < 0) { x_dialog = 0; } if (x_dialog < 0) { y_dialog = 0; } dialog_progress.Show(); dialog_progress.Location = new System.Drawing.Point(x_dialog, y_dialog); ZipExtractEngine engine = new ZipExtractEngine (source_list, dest_path, opts, dialog_progress, dialog.textBoxSourceMask.Text, zd.ZipFile, zd.CurrentZipDirectory); engine.Done += new EventHandler(engine_Done); engine.ExtractItemDone += new ItemEventHandler(engine_ExtractItemDone); zip_directory = zd; zd.LockSafe = true; engine.Run(); //ZipEntry source_entry = zd[e_current.FocusedIndex]; //if (source_entry == null) //{ // return; //} //Stream out_stream = source_zip_file.GetInputStream(source_entry); //string target_file_name = Path.Combine(dest_dir, source_entry.Name); //FileStream writer = new FileStream(target_file_name, FileMode.CreateNew, FileAccess.Write, FileShare.Read); //byte[] buffer = new byte[buffer_size]; //int bytes_readed = 0; //while ((bytes_readed = out_stream.Read(buffer, 0, buffer_size)) != 0) //{ // writer.Write(buffer, 0, bytes_readed); //} //writer.Flush(); //writer.Close(); //out_stream.Close(); }