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]; }
private static ProcessedSize CreateFileProcessed(Stream sourceStream, IVirtualItem sourceItem) { ProcessedSize size = new ProcessedSize(0L, 0L); if (sourceStream.CanSeek) { size.SetProcessedSize(sourceStream.Position); size.SetTotalSize(sourceStream.Length); return size; } object obj2 = sourceItem[3]; if (obj2 != null) { size.SetTotalSize((long) obj2); } return size; }
private PROGRESS_RESULT SystemCopyProgress(long TotalFileSize, long TotalBytesTransferred, long StreamSize, long StreamBytesTransferred, uint dwStreamNumber, CALLBACK_REASON dwCallbackReason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData) { if (dwCallbackReason != CALLBACK_REASON.CALLBACK_STREAM_SWITCH) { long num = Marshal.ReadInt64(lpData); lock (this.FSnapshotLock) { this.FTotalProcessed.AddProcessedSize(TotalBytesTransferred - num); } Marshal.WriteInt64(lpData, TotalBytesTransferred); this.RaiseProgress(); } ProcessedSize processed = new ProcessedSize(TotalBytesTransferred, TotalFileSize); if (!this.RaiseFileProgress(ref processed)) { return PROGRESS_RESULT.PROGRESS_CANCEL; } return (base.CheckCancellationPending() ? PROGRESS_RESULT.PROGRESS_CANCEL : PROGRESS_RESULT.PROGRESS_CONTINUE); }
private bool RaiseFileProgress(ref ProcessedSize processed) { if (this.FileProgressChanged != null) { int progressPercent = processed.ProgressPercent; if (progressPercent <= 100) { ProgressEventArgs e = new ProgressEventArgs(progressPercent); this.FileProgressChanged(this, e); return !e.Cancel; } } return true; }
public ProcessedSize(ProcessedSize size) { this.FProcessedSize = size.Processed; this.FTotalSize = size.Total; }
private void Write185_ProcessedSize(string n, string ns, ProcessedSize o, bool needType) { if (!needType && (o.GetType() != typeof(ProcessedSize))) { throw base.CreateUnknownTypeException(o); } base.WriteStartElement(n, ns, o, false, null); if (needType) { base.WriteXsiType("ProcessedSize", ""); } base.WriteEndElement(o); }