예제 #1
0
 /// <summary>A constructor to initialize a <c>new BackgroundMessage</c>.</summary>
 /// <param name=""></param>
 /// <param name=""></param>
 /// <param name=""></param>
 public BackgroundMessage(nType eType, Drive DriveProperty, int iValue) : this(eType)
 {
     _DriveProperty = DriveProperty;
     _iValue        = iValue;
 }
예제 #2
0
        /// <summary>A constructor to initialize a <c>new PairOfFiles</c>.</summary>
        /// <param name="FromStream"></param>
        /// <param name="SourceOrDestinationDrive"></param>
        /// <param name="TextEncoder"></param>
        public PairOfFiles(Stream FromStream, PairOfFiles ParentDirectory, bool isSource, TextConverter TextConverter) : this()
        {
            byte[] abBuffer, abTextBytes;
            ushort tTextLength;
            uint   uAttributes, uFirstBlock = 0;
            long   kCreationTimeTicks, kLastAccessTimeTicks, kLastWriteTimeTicks, kSize = -1;

            _ParentDirectory  = ParentDirectory;
            _SourceDrive      = _ParentDirectory.SourceDrive;
            _DestinationDrive = _ParentDirectory.DestinationDrive;
            _TextConverter    = TextConverter;
            abBuffer          = new byte[8];

            FromStream.Read(abBuffer, 0, 2);
            tTextLength = BitConverter.ToUInt16(abBuffer, 0);
            abTextBytes = new byte[tTextLength];
            FromStream.Read(abTextBytes, 0, tTextLength);
            _sRelativePath = _TextConverter.BytesToString(abTextBytes);

            FromStream.Read(abBuffer, 0, 4);
            uAttributes  = BitConverter.ToUInt32(abBuffer, 0);
            _isDirectory = ((uAttributes & (uint)FileAttributes.Directory) > 0);
            FromStream.Read(abBuffer, 0, 8);
            kCreationTimeTicks = BitConverter.ToInt64(abBuffer, 0);
            FromStream.Read(abBuffer, 0, 8);
            kLastAccessTimeTicks = BitConverter.ToInt64(abBuffer, 0);
            FromStream.Read(abBuffer, 0, 8);
            kLastWriteTimeTicks = BitConverter.ToInt64(abBuffer, 0);

            if (!_isDirectory)
            {
                FromStream.Read(abBuffer, 0, 8);
                kSize = BitConverter.ToInt64(abBuffer, 0);
                if ((isSource && (_SourceDrive.eEncryptionType == Drive.nEncryptionType.DirectorySymmetric)) || (!isSource && (_DestinationDrive.eEncryptionType == Drive.nEncryptionType.DirectorySymmetric)))
                {
                    FromStream.Read(abBuffer, 0, 4);
                    uFirstBlock = BitConverter.ToUInt32(abBuffer, 0);
                }
            }

            if (isSource)
            {
                _uAttributesSource    = uAttributes;
                _CreationTimeSource   = new DateTime(kCreationTimeTicks);
                _LastAccessTimeSource = new DateTime(kLastAccessTimeTicks);
                LastWriteTimeSource   = new DateTime(kLastWriteTimeTicks);
                _kSourceSize          = kSize;
                _sSourceSize          = FileSizeToString(kSize);
                _uFirstBlockSource    = uFirstBlock;
                _eComparison          = nComparison.UnknownDestination;
            }
            else
            {
                _uAttributesDestination    = uAttributes;
                _CreationTimeDestination   = new DateTime(kCreationTimeTicks);
                _LastAccessTimeDestination = new DateTime(kLastAccessTimeTicks);
                LastWriteTimeDestination   = new DateTime(kLastWriteTimeTicks);
                _kDestinationSize          = kSize;
                _sDestinationSize          = FileSizeToString(kSize);
                _uFirstBlockDestination    = uFirstBlock;
                _eComparison = nComparison.UnknownSource;
            }
        }
예제 #3
0
        /// <summary></summary>
        public void SwapSourceAndDestination()
        {
            bool     isSwap;
            uint     uSwap;
            long     kSwap;
            string   sSwap;
            DateTime dtSwap;
            Drive    Swap;

            isSwap                  = _isEncryptedSource;
            _isEncryptedSource      = _isEncryptedDestination;
            _isEncryptedDestination = isSwap;

            uSwap = _uAttributesSource;
            _uAttributesSource      = _uAttributesDestination;
            _uAttributesDestination = uSwap;

            uSwap = _uLastWriteTimeSource;
            _uLastWriteTimeSource      = _uLastWriteTimeDestination;
            _uLastWriteTimeDestination = uSwap;

            kSwap             = _kSourceSize;
            _kSourceSize      = _kDestinationSize;
            _kDestinationSize = kSwap;

            sSwap = _sLastWriteTimeSource;
            _sLastWriteTimeSource      = _sLastWriteTimeDestination;
            _sLastWriteTimeDestination = sSwap;

            sSwap             = _sSourceSize;
            _sSourceSize      = _sDestinationSize;
            _sDestinationSize = sSwap;

            dtSwap = _CreationTimeSource;
            _CreationTimeSource      = _CreationTimeDestination;
            _CreationTimeDestination = dtSwap;

            dtSwap = _LastAccessTimeSource;
            _LastAccessTimeSource      = _LastAccessTimeDestination;
            _LastAccessTimeDestination = dtSwap;

            dtSwap = _LastWriteTimeSource;
            _LastWriteTimeSource      = _LastWriteTimeDestination;
            _LastWriteTimeDestination = dtSwap;

            Swap              = _SourceDrive;
            _SourceDrive      = _DestinationDrive;
            _DestinationDrive = Swap;

            switch (_eComparison)
            {
            case nComparison.SourceOnly: eComparison = nComparison.DestinationOnly; break;

            case nComparison.DestinationOnly: eComparison = nComparison.SourceOnly; break;

            case nComparison.SourceNewer: eComparison = nComparison.DestinationNewer; break;

            case nComparison.DestinationNewer: eComparison = nComparison.SourceNewer; break;

            case nComparison.UnknownSource: eComparison = nComparison.UnknownDestination; break;

            case nComparison.UnknownDestination: eComparison = nComparison.UnknownSource; break;
            }
        }
예제 #4
0
 /// <summary>A constructor to initialize a <c>new PairOfFiles</c>.</summary>
 /// <param name="SourceDrive"></param>
 /// <param name="DestinationDrive"></param>
 public PairOfFiles(Drive SourceDrive, Drive DestinationDrive) : this()
 {
     _SourceDrive      = SourceDrive;
     _DestinationDrive = DestinationDrive;
 }