public OverwriteDialogResult GetOverwrite(IVirtualItem source, IVirtualItem dest)
        {
            if (this.CompareOperator == Compare.Always)
            {
                return this.OverwriteResult;
            }
            if (((this.CompareOperator != Compare.Never) && (source != null)) && (dest != null))
            {
                int num;
                if (!(source.IsPropertyAvailable(this.PropertyId) && dest.IsPropertyAvailable(this.PropertyId)))
                {
                    return OverwriteDialogResult.None;
                }
                switch (this.PropertyId)
                {
                    case 7:
                    case 8:
                    case 9:
                    {
                        DateTime time = (DateTime) source[8];
                        DateTime time2 = (DateTime) dest[8];
                        TimeSpan span = (TimeSpan) (time2 - time);
                        num = Math.Sign((long) (span.Ticks / 0x989680L));
                        break;
                    }
                    default:
                        num = Comparer.DefaultInvariant.Compare(dest[this.PropertyId], source[this.PropertyId]);
                        break;
                }
                switch (this.CompareOperator)
                {
                    case Compare.Equal:
                        return ((num == 0) ? this.OverwriteResult : OverwriteDialogResult.None);

                    case Compare.Greater:
                        return ((num > 0) ? this.OverwriteResult : OverwriteDialogResult.None);

                    case Compare.GreaterEqual:
                        return ((num >= 0) ? this.OverwriteResult : OverwriteDialogResult.None);

                    case Compare.Less:
                        return ((num < 0) ? this.OverwriteResult : OverwriteDialogResult.None);

                    case Compare.LessEqual:
                        return ((num <= 0) ? this.OverwriteResult : OverwriteDialogResult.None);

                    case Compare.NotEqual:
                        return ((num != 0) ? this.OverwriteResult : OverwriteDialogResult.None);
                }
            }
            return OverwriteDialogResult.None;
        }
 public OverwriteDialogResult GetOverwrite(IVirtualItem source, IVirtualItem dest)
 {
     if ((source != null) && (dest != null))
     {
         if (!(source.IsPropertyAvailable(this.PropertyId) && dest.IsPropertyAvailable(this.PropertyId)))
         {
             return OverwriteDialogResult.None;
         }
         object a = source[this.PropertyId];
         if ((Comparer.DefaultInvariant.Compare(a, this.Value) == 0) && (Comparer.DefaultInvariant.Compare(a, dest[this.PropertyId]) == 0))
         {
             return this.OverwriteResult;
         }
     }
     return OverwriteDialogResult.None;
 }
        private void CopyItem(IVirtualItem sourceItem, IVirtualFolder destFolder, IGetStream getSourceStream, List<IVirtualItem> skippedItems)
        {
            Exception exception;
            object obj2;
            CopyItemAction next = CopyItemAction.Next;
            IChangeVirtualFile DestFile = null;
            try
            {
                if (!(sourceItem is IChangeVirtualFile))
                {
                    throw new ItemChangeNotSupportedException();
                }
                ICreateVirtualFile file = destFolder as ICreateVirtualFile;
                if (file == null)
                {
                    throw new WarningException(string.Format(Resources.sCannotCopyToBasicFolder, destFolder.FullName));
                }
                DestFile = file.CreateFile(this.CreateNewName(sourceItem));
                OverwriteDialogResult Overwrite = OverwriteDialogResult.Overwrite;
                do
                {
                    string str;
                    Overwrite = this.BeforeCopy((IVirtualFile) sourceItem, DestFile, out str);
                    switch (Overwrite)
                    {
                        case OverwriteDialogResult.Rename:
                            DestFile = file.CreateFile(str);
                            break;

                        case OverwriteDialogResult.Skip:
                            skippedItems.Add(sourceItem);
                            lock ((obj2 = this.FSnapshotLock))
                            {
                                this.FSkippedCount++;
                                if (sourceItem.IsPropertyAvailable(3))
                                {
                                    this.FTotalProcessed.AddProcessedSize(Convert.ToInt64(sourceItem[3]));
                                }
                            }
                            return;

                        case OverwriteDialogResult.Abort:
                            base.CancelAsync();
                            return;
                    }
                }
                while (((Overwrite != OverwriteDialogResult.Append) && (Overwrite != OverwriteDialogResult.Resume)) && (Overwrite != OverwriteDialogResult.Overwrite));
                if (sourceItem.Equals(DestFile))
                {
                    throw new WarningException(string.Format(Resources.sCannotCopyFileToItself, sourceItem.FullName));
                }
                IChangeVirtualFile CurrentFile = (IChangeVirtualFile) sourceItem;
                IChangeVirtualItem item = sourceItem as IChangeVirtualItem;
                IChangeVirtualItem destItem = DestFile as IChangeVirtualItem;
                if ((this.CheckOption(CopyWorkerOptions.DeleteSource) && (item != null)) && item.CanMoveTo(destFolder))
                {
                    if (this.MoveItem(item, destFolder) == null)
                    {
                        next = CopyItemAction.Skip;
                    }
                    lock ((obj2 = this.FSnapshotLock))
                    {
                        this.FTotalProcessed.AddProcessedSize(Convert.ToInt64(CurrentFile[3]));
                    }
                }
                else
                {
                    if (!(!this.CheckOption(CopyWorkerOptions.CheckFreeSpace) || this.CheckDestFreeSpace(Overwrite, CurrentFile, DestFile, destFolder)))
                    {
                        next = CopyItemAction.Skip;
                    }
                    if (next == CopyItemAction.Next)
                    {
                        long num = 0L;
                        FileAttributes attributes = 0;
                        bool flag = false;
                        long position = 0L;
                        ISetOwnerWindow window = CurrentFile as ISetOwnerWindow;
                        if (window != null)
                        {
                            window.Owner = this.Owner;
                        }
                        try
                        {
                            if ((destItem != null) && destItem.Exists)
                            {
                                num = Convert.ToInt64(DestFile[3]);
                                attributes = DestFile.Attributes;
                                VirtualItemHelper.ResetSystemAttributes(DestFile);
                            }
                            else
                            {
                                Overwrite = OverwriteDialogResult.Overwrite;
                            }
                            bool flag2 = (((this.CheckOption(CopyWorkerOptions.UseSystemCopy) && OS.IsWinNT) && ((Overwrite == OverwriteDialogResult.Overwrite) && (getSourceStream == null))) && (CurrentFile is CustomFileSystemFile)) && (DestFile is CustomFileSystemFile);
                            if (flag2)
                            {
                                try
                                {
                                    if (this.CopySystem(CurrentFile, DestFile))
                                    {
                                        VirtualItemHelper.ResetSystemAttributes(DestFile);
                                    }
                                    else
                                    {
                                        next = CopyItemAction.Skip;
                                    }
                                }
                                catch (UnauthorizedAccessException)
                                {
                                    IElevatable elevatable = CurrentFile as IElevatable;
                                    bool flag3 = (elevatable != null) && elevatable.CanElevate;
                                    if (!flag3)
                                    {
                                        elevatable = DestFile as IElevatable;
                                        flag3 = (elevatable != null) && elevatable.CanElevate;
                                    }
                                    if (!flag3)
                                    {
                                        throw;
                                    }
                                    flag2 = false;
                                }
                            }
                            if (!flag2)
                            {
                                bool asyncCopy = this.CheckOption(CopyWorkerOptions.AsyncCopy);
                                if (this.CheckOption(CopyWorkerOptions.AutoAsyncCopy))
                                {
                                    IGetVirtualVolume parent = CurrentFile.Parent as IGetVirtualVolume;
                                    IGetVirtualVolume volume2 = destFolder as IGetVirtualVolume;
                                    asyncCopy = ((volume2 != null) && (parent != null)) && ((volume2.Location != parent.Location) || (volume2.VolumeType != parent.VolumeType));
                                }
                                Stream InStream = null;
                                bool DoAsyncCopy = asyncCopy;
                                long StartOffset = 0L;
                                if (Overwrite == OverwriteDialogResult.Resume)
                                {
                                    StartOffset = num;
                                }
                                next = this.OpenItemStream(sourceItem, sourceItem, DestFile, delegate {
                                    if (getSourceStream != null)
                                    {
                                        InStream = getSourceStream.GetStream();
                                        if (StartOffset > 0L)
                                        {
                                            InStream.Seek(StartOffset, SeekOrigin.Begin);
                                        }
                                    }
                                    else
                                    {
                                        InStream = CurrentFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read, FileOptions.SequentialScan | (DoAsyncCopy ? FileOptions.Asynchronous : FileOptions.None), StartOffset);
                                    }
                                });
                                using (InStream)
                                {
                                    if ((InStream != null) && (next == CopyItemAction.Next))
                                    {
                                        DoAsyncCopy = DoAsyncCopy && (!InStream.CanSeek || (InStream.Length > this.Buffer1.Length));
                                        Stream OutStream = null;
                                        next = this.OpenItemStream(DestFile, sourceItem, DestFile, delegate {
                                            OutStream = DestFile.Open((Overwrite == OverwriteDialogResult.Overwrite) ? FileMode.Create : FileMode.Append, FileAccess.Write, FileShare.None, FileOptions.SequentialScan | (DoAsyncCopy ? FileOptions.Asynchronous : FileOptions.None), 0L);
                                        });
                                        using (OutStream)
                                        {
                                            if ((OutStream != null) && (next == CopyItemAction.Next))
                                            {
                                                flag = true;
                                                FileStream stream = InStream as FileStream;
                                                DoAsyncCopy &= ((stream == null) || stream.IsAsync) && (InStream != Stream.Null);
                                                FileStream stream2 = OutStream as FileStream;
                                                DoAsyncCopy &= ((stream2 == null) || stream2.IsAsync) && (OutStream != Stream.Null);
                                                if (DoAsyncCopy)
                                                {
                                                    next = this.CopyStreamAsync(InStream, OutStream, CurrentFile, DestFile);
                                                }
                                                else
                                                {
                                                    next = this.CopyStream(InStream, OutStream, CurrentFile, DestFile);
                                                }
                                                if (OutStream.CanSeek)
                                                {
                                                    if (Overwrite == OverwriteDialogResult.Append)
                                                    {
                                                        position = OutStream.Position - num;
                                                    }
                                                    else
                                                    {
                                                        position = OutStream.Position;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (!((next != CopyItemAction.Next) || base.CancellationPending))
                                {
                                    this.CopyAlternateStreams(CurrentFile, DestFile, asyncCopy);
                                }
                            }
                            if ((next == CopyItemAction.Next) && !base.CancellationPending)
                            {
                                if (destItem != null)
                                {
                                    next = this.SetOutFileAttributes(sourceItem, destItem, true, this.CheckOption(CopyWorkerOptions.CopyItemTime));
                                }
                                if (((this.CheckOption(CopyWorkerOptions.DeleteSource) && (next == CopyItemAction.Next)) && (item != null)) && !this.DeleteItem(CurrentFile))
                                {
                                    next = CopyItemAction.Skip;
                                }
                                this.RaiseAfterCopy(sourceItem, DestFile);
                            }
                        }
                        catch (AbortException)
                        {
                            next = CopyItemAction.SkipUndoDest;
                            base.CancelAsync();
                        }
                        catch (Exception exception3)
                        {
                            exception = exception3;
                            next = this.CopyItemError(null, sourceItem, DestFile, flag ? AvailableItemActions.CanUndoDestination : AvailableItemActions.None, exception);
                        }
                        if ((next != CopyItemAction.Next) && CurrentFile.IsPropertyAvailable(3))
                        {
                            lock ((obj2 = this.FSnapshotLock))
                            {
                                this.FTotalProcessed.AddProcessedSize(Convert.ToInt64(CurrentFile[3]) - position);
                            }
                        }
                        if (flag && (next == CopyItemAction.SkipUndoDest))
                        {
                            if (Overwrite != OverwriteDialogResult.Overwrite)
                            {
                                using (Stream stream3 = DestFile.Open(FileMode.Open, FileAccess.Write, FileShare.None, FileOptions.None, 0L))
                                {
                                    if (stream3.CanSeek && stream3.CanWrite)
                                    {
                                        stream3.SetLength(num);
                                    }
                                }
                                if ((destItem != null) && destItem.CanSetProperty(6))
                                {
                                    destItem[6] = attributes;
                                }
                            }
                            else if (destItem != null)
                            {
                                destItem.Delete(false);
                            }
                        }
                    }
                }
            }
            catch (Exception exception4)
            {
                exception = exception4;
                next = this.CopyItemError(null, sourceItem, DestFile, AvailableItemActions.None, exception);
            }
            if (next != CopyItemAction.Next)
            {
                skippedItems.Add(sourceItem);
                lock ((obj2 = this.FSnapshotLock))
                {
                    this.FSkippedCount++;
                }
            }
            else
            {
                lock ((obj2 = this.FSnapshotLock))
                {
                    this.FProcessedCount++;
                }
            }
        }
 private static void SetProperty(IVirtualItem sourceItem, IChangeVirtualItem destItem, int property)
 {
     if (destItem.CanSetProperty(property) && sourceItem.IsPropertyAvailable(property))
     {
         object obj2 = sourceItem[property];
         if (obj2 != null)
         {
             destItem[property] = obj2;
         }
     }
 }
        private CopyItemAction SetOutFileAttributes(IVirtualItem sourceItem, IChangeVirtualItem destItem, bool setAttributes, bool setTime)
        {
            ChangeItemAction action;
            Debug.Assert(setAttributes || setTime);
        Label_000F:;
            try
            {
                IUpdateVirtualProperty property = destItem as IUpdateVirtualProperty;
                if (property != null)
                {
                    property.BeginUpdate();
                }
                if (setAttributes)
                {
                    if (destItem.CanSetProperty(6))
                    {
                        FileAttributes normal = FileAttributes.Normal;
                        if (sourceItem.IsPropertyAvailable(6))
                        {
                            normal = sourceItem.Attributes & ~(FileAttributes.Encrypted | FileAttributes.Compressed);
                            if (this.CheckOption(CopyWorkerOptions.ClearROFromCD))
                            {
                                IGetVirtualVolume parent = sourceItem.Parent as IGetVirtualVolume;
                                if ((parent != null) && (parent.VolumeType == DriveType.CDRom))
                                {
                                    normal &= ~FileAttributes.ReadOnly;
                                }
                            }
                        }
                        destItem[6] = normal | (destItem.Attributes & (FileAttributes.Encrypted | FileAttributes.Compressed));
                    }
                    if (this.CheckOption(CopyWorkerOptions.CopyACL))
                    {
                        SetProperty(sourceItem, destItem, 14);
                    }
                }
                if (setTime)
                {
                    SetProperty(sourceItem, destItem, 7);
                    SetProperty(sourceItem, destItem, 9);
                    SetProperty(sourceItem, destItem, 8);
                }
                if (property != null)
                {
                    property.EndUpdate();
                }
                return CopyItemAction.Next;
            }
            catch (UnauthorizedAccessException exception)
            {
                action = this.ChangeItemError(destItem, sourceItem, destItem, AvailableItemActions.CanRetryOrIgnore, exception);
            }
            catch (IOException exception2)
            {
                action = this.ChangeItemError(destItem, sourceItem, destItem, AvailableItemActions.CanRetryOrIgnore, exception2);
            }
            switch (action)
            {
                case ChangeItemAction.Retry:
                    goto Label_000F;

                case ChangeItemAction.Ignore:
                    return CopyItemAction.Next;

                case ChangeItemAction.Skip:
                    return CopyItemAction.Skip;

                case ChangeItemAction.Cancel:
                    base.CancelAsync();
                    return CopyItemAction.Skip;
            }
            throw new InvalidEnumArgumentException();
        }
 private void UpdateTotalSize(IVirtualItem item)
 {
     object obj2 = item[3];
     if (obj2 != null)
     {
         this.TotalSize += Convert.ToInt64(obj2);
     }
     if (item.IsPropertyAvailable(5))
     {
         obj2 = item[5];
     }
     if (obj2 != null)
     {
         this.TotalCompressedSize += Convert.ToInt64(obj2);
     }
 }
 private static CompareResult CompareProperties(IVirtualItem a, IVirtualItem b, int propertyId)
 {
     int num;
     if (!((((a != null) && (b != null)) && a.IsPropertyAvailable(propertyId)) && b.IsPropertyAvailable(propertyId)))
     {
         return CompareResult.Unknown;
     }
     switch (propertyId)
     {
         case 7:
         case 8:
         case 9:
         {
             DateTime time = (DateTime) a[8];
             DateTime time2 = (DateTime) b[8];
             TimeSpan span = (TimeSpan) (time - time2);
             num = Math.Sign((long) (span.Ticks / 0x989680L));
             break;
         }
         default:
             num = Comparer.DefaultInvariant.Compare(a[propertyId], b[propertyId]);
             break;
     }
     if (num < 0)
     {
         return CompareResult.Less;
     }
     if (num > 0)
     {
         return CompareResult.Greater;
     }
     return CompareResult.Equal;
 }