public CopyWorker(IEnumerable<IVirtualItem> items, IVirtualFolder dest, CopySettings settings, CopyWorkerOptions copyOptions, IVirtualItemFilter filter, IRenameFilter renameFilter) { this.FSnapshotLock = new object(); this.FTotalProcessed = new ProcessedSize(); this.FStoredProgress = -1; this.FCopyBufferSize = 0x40000; if (items == null) { throw new ArgumentNullException("items"); } if (dest == null) { throw new ArgumentNullException("dest"); } if (!VirtualItemHelper.CanCreateInFolder(dest)) { throw new ArgumentException(string.Format(Resources.sCannotCopyToBasicFolder, dest.FullName)); } this.FContent = new AggregatedVirtualFolder(items); ICloneable cloneable = dest as ICloneable; if (cloneable != null) { this.FDest = (IVirtualFolder) cloneable.Clone(); } else { this.FDest = dest; } this.FCopyOptions = copyOptions; if (settings != null) { this.FCopyOptions |= settings.DefaultCopyOptions & (CopyWorkerOptions.CopyFolderTime | CopyWorkerOptions.ClearROFromCD); this.FCopyBufferSize = settings.CopyBufferSize; } this.FFilter = filter; this.FRenameFilter = renameFilter; if (this.FRenameFilter != null) { this.FRenameContent = new Dictionary<IVirtualItem, int>(); foreach (IVirtualItem item in items) { this.FRenameContent.Add(item, 0); } } this.Buffer1 = new byte[this.FCopyBufferSize]; }
public bool Execute(IWin32Window owner, IEnumerable<IVirtualItem> selection) { this.Selection = selection; this.UpdateCopyToText(this.chkDeleteSource.Checked, selection); if (this.FDestFolder != null) { IVirtualItem item = null; foreach (IVirtualItem item2 in selection) { if (item == null) { item = item2; } else { item = null; break; } } if (item is IVirtualFolder) { item = null; } ICreateVirtualFile fDestFolder = this.FDestFolder as ICreateVirtualFile; if ((fDestFolder != null) && (item != null)) { IVirtualItem item3 = fDestFolder.CreateFile(item.Name); this.cmbCopyTo.Text = item3.FullName; this.FRenameFilter = new SimpleRenameFilter(item3.Name); } else { this.cmbCopyTo.Text = this.FDestFolder.FullName; } } HistorySettings.PopulateComboBox(this.cmbCopyTo, HistorySettings.Default.CopyTo); if (base.ShowDialog(owner) == DialogResult.OK) { HistorySettings.Default.AddStringToCopyTo(this.CopyTo); if (this.cmbFilter.Enabled) { HistorySettings.Default.AddStringToCopyFilter(this.cmbFilter.FilterString); } return true; } return false; }
private void DestFolderNeeded() { if (this.FDestFolder == null) { this.FRenameFilter = null; string copyTo = this.CopyTo; if (string.IsNullOrEmpty(copyTo)) { this.FDestFolder = this.CurrentFolder; } else { PathType pathType = PathHelper.GetPathType(copyTo); if ((pathType & PathType.Folder) > PathType.Unknown) { this.FDestFolder = (IVirtualFolder) VirtualItem.FromFullName(copyTo, VirtualItemType.Folder, this.CurrentFolder); } else { if ((pathType & PathType.File) > PathType.Unknown) { string fileName = Path.GetFileName(copyTo); if (fileName.IndexOfAny(FileMaskChars) < 0) { if (this.SelectionHasFolders || (this.DestinationItem == CopyDestinationItem.Folder)) { this.FDestFolder = (IVirtualFolder) VirtualItem.FromFullName(copyTo, VirtualItemType.Folder, this.CurrentFolder); } else { try { IVirtualItem item = VirtualItem.FromFullName(copyTo, VirtualItemType.Unknown, this.CurrentFolder); this.FDestFolder = item as IVirtualFolder; if (this.FDestFolder == null) { this.FDestFolder = item.Parent; this.FRenameFilter = new RegexRenameFilter(fileName); } } catch (FileNotFoundException) { } } return; } copyTo = Path.GetDirectoryName(copyTo); this.FRenameFilter = new RegexRenameFilter(fileName); } if (string.IsNullOrEmpty(copyTo)) { this.FDestFolder = this.CurrentFolder; } else { this.FDestFolder = (IVirtualFolder) VirtualItem.FromFullName(copyTo, VirtualItemType.Folder, this.CurrentFolder); } } } } }