public CopyFileEngineBase (string[] source, string destination, CopyEngineOptions options, CopyFileProgressDialog dialog) { initial_source = source; initial_destination = destination; this.options = options; progress_dialog = dialog; progress_dialog.FormClosing += new System.Windows.Forms.FormClosingEventHandler(progress_dialog_FormClosing); update_progress_delegate_holder = new MethodInvokerUpdateProgress(update_progress); }
public CopyFileEngine (List <FileInfoEx> source, string destination, CopyEngineOptions options, CopyFileProgressDialog dialog, string mask, bool dest_remote) { this.options = options; copy_progress_routine_delegate_holder = new CopyProgressRoutine(copy_progress_proc); copyFileEx_options = CopyFileExOptions.None; if ((options & CopyEngineOptions.AllowDecryptDestination) == CopyEngineOptions.AllowDecryptDestination) { copyFileEx_options = copyFileEx_options | CopyFileExOptions.ALLOW_DECRYPTED_DESTINATION; } if (Options.IsVistaOrServer2003OrLater()) { if ((options & CopyEngineOptions.CopySymlinkAsSymlink) == CopyEngineOptions.CopySymlinkAsSymlink) { copyFileEx_options = copyFileEx_options | CopyFileExOptions.COPY_SYMLINK; } } if ((options & CopyEngineOptions.NoRewrite) == CopyEngineOptions.NoRewrite) { copyFileEx_options = copyFileEx_options | CopyFileExOptions.FAIL_IF_EXISTS; } if ((options & CopyEngineOptions.RewriteIfSourceNewer) == CopyEngineOptions.RewriteIfSourceNewer) { copyFileEx_options = copyFileEx_options | CopyFileExOptions.FAIL_IF_EXISTS; } progress_dialog = dialog; if (progress_dialog != null) { progress_dialog.FormClosing += new System.Windows.Forms.FormClosingEventHandler (progress_dialog_FormClosing); } initial_source = source; initial_destination = destination; initial_mask = mask; destination_remote = dest_remote; update_progress_delegate_holder = new MethodInvokerUpdateProgress(update_progress); copy_thread = new Thread(internal_do); }
//use read and write to framework streams public CopyFileEngine_1(string[] source, string destination, CopyEngineOptions options, CopyFileProgressDialog dialog) : base(source, destination, options, dialog) { }
protected override void internal_command_proc() { QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs(); QueryPanelInfoEventArgs e_other = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e_current); OnQueryOtherPanel(e_other); if (e_current.FocusedIndex == -1) { return; } if (!(e_other.ItemCollection is DirectoryList)) { Messages.ShowMessage("Cannot copy to current destination."); return; } //see source source_list = new List <string>(); DirectoryList dl_source = (DirectoryList)e_current.ItemCollection; DirectoryList dl_target = (DirectoryList)e_other.ItemCollection; int[] sel_indices = e_current.SelectedIndices; if (sel_indices.Length == 0) { if (dl_source.GetItemDisplayNameLong(e_current.FocusedIndex) == "..") { return; } //get focused entry source_list.Add(Path.Combine(dl_source.DirectoryPath, dl_source.GetItemDisplayNameLong(e_current.FocusedIndex))); } else { //get source from selection for (int i = 0; i < sel_indices.Length; i++) { source_list.Add(Path.Combine(dl_source.DirectoryPath, dl_source.GetItemDisplayNameLong(sel_indices[i]))); } } string dest_path = dl_target.DirectoryPath; //prepare copy dialog CopyFileDialog dialog = new CopyFileDialog(); dialog.CopyEngineOptions = engine_opts; dialog.Text = "Copy"; if (source_list.Count == 1) { dialog.labelSourceFile.Text = source_list[0]; } else { dialog.labelSourceFile.Text = string.Format("{0} entries", source_list.Count); } dialog.textBoxDestination.Text = dest_path; if (dialog.ShowDialog() != DialogResult.OK) { return; } //save user selection engine_opts = dialog.CopyEngineOptions; Options.CopyEngineOptions = engine_opts; //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); //prepare copy engine CopyFileEngine copy_engine = new CopyFileEngine (source_list.ToArray(), dialog.textBoxDestination.Text, engine_opts, dialog_progress); copy_engine.Done += new EventHandler(copy_engine_Done); copy_engine.CopyItemDone += new ItemEventHandler(copy_engine_CopyItemDone); //and do job copy_engine.Do(); }
protected override void internal_command_proc() { QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs(); QueryPanelInfoEventArgs e_other = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e_current); OnQueryOtherPanel(e_other); if (e_current.FocusedIndex == -1) { return; } if (e_other.ItemCollection is FtpDirectoryList) { //do ftp download upload_to_ftp(e_current, e_other); return; } else if (e_other.ItemCollection is ZipDirectory) { add_to_zip(e_current, e_other); return; } else if (!(e_other.ItemCollection is DirectoryList)) { Messages.ShowMessage(Options.GetLiteral(Options.LANG_WRONG_DESTINATION)); return; } //see source List <FileInfoEx> source_list = new List <FileInfoEx>(); DirectoryList dl_source = (DirectoryList)e_current.ItemCollection; DirectoryList dl_target = (DirectoryList)e_other.ItemCollection; int[] sel_indices = e_current.SelectedIndices; if (sel_indices.Length == 0) { if (dl_source.GetItemDisplayNameLong(e_current.FocusedIndex) == "..") { return; } //get focused entry source_list.Add(dl_source[e_current.FocusedIndex]); } else { //get source from selection for (int i = 0; i < sel_indices.Length; i++) { source_list.Add(dl_source[sel_indices[i]]); } } string dest_path = dl_target.DirectoryPath; //prepare copy dialog CopyFileDialog dialog = new CopyFileDialog(); dialog.CopyEngineOptions = Options.CopyEngineOptions; dialog.Text = Options.GetLiteral(Options.LANG_COPY); dialog.textBoxSourceMask.Text = "*"; dialog.textBoxDestination.Text = string.Empty; if (dialog.ShowDialog() != DialogResult.OK) { return; } //save user selection CopyEngineOptions engine_opts = dialog.CopyEngineOptions; Options.CopyEngineOptions = engine_opts; //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); //prepare copy engine bool dest_remote = true; try { FileInfoEx dest_info = new FileInfoEx(); FileInfoEx.TryGet(dest_path, ref dest_info); NT_FS_DEVICE_CHARACTERISTICS chars = dest_info.GetDeviceInfo().Characteristics; if (((chars & NT_FS_DEVICE_CHARACTERISTICS.Remote) == NT_FS_DEVICE_CHARACTERISTICS.Remote) || ((chars & NT_FS_DEVICE_CHARACTERISTICS.Removable) == NT_FS_DEVICE_CHARACTERISTICS.Removable) || ((chars & NT_FS_DEVICE_CHARACTERISTICS.WebDAV) == NT_FS_DEVICE_CHARACTERISTICS.WebDAV)) { dest_remote = true; } else { dest_remote = false; } } catch (Exception) { } dest_path = dialog.textBoxDestination.Text == string.Empty ? dest_path : Path.Combine(dest_path, dialog.textBoxDestination.Text); CopyFileEngine copy_engine = new CopyFileEngine (source_list, dest_path, engine_opts, dialog_progress, dialog.textBoxSourceMask.Text, dest_remote); copy_engine.Done += new EventHandler(copy_engine_Done); copy_engine.CopyItemDone += new ItemEventHandler(copy_engine_CopyItemDone); //and do job copy_engine.Do(); }