コード例 #1
0
 public bool Equals(DuplicateFileModel other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(LastWriteTime.Equals(other.LastWriteTime) && LastAccessTimeUtc.Equals(other.LastAccessTimeUtc) && LastAccessTime.Equals(other.LastAccessTime) && CreationTimeUtc.Equals(other.CreationTimeUtc) &&
            CreationTime.Equals(other.CreationTime) && LastWriteTimeUtc.Equals(other.LastWriteTimeUtc) && string.Equals(FullName, other.FullName) && string.Equals(Name, other.Name) && string.Equals(HashValue, other.HashValue) &&
            string.Equals(UniqueIdHashValue, other.UniqueIdHashValue) && IsMaster == other.IsMaster && Equals(DuplicateFiles, other.DuplicateFiles) && FileSize == other.FileSize);
 }
コード例 #2
0
        /// <summary>
        /// Returns a byte array representing the current <see cref="SftpFileAttributes"/>.
        /// </summary>
        /// <returns>
        /// A byte array representing the current <see cref="SftpFileAttributes"/>.
        /// </returns>
        public byte[] GetBytes()
        {
            var stream = new SshDataStream(4);

            uint flag = 0;

            if (IsSizeChanged && IsRegularFile)
            {
                flag |= 0x00000001;
            }

            if (IsUserIdChanged || IsGroupIdChanged)
            {
                flag |= 0x00000002;
            }

            if (IsPermissionsChanged)
            {
                flag |= 0x00000004;
            }

            if (IsLastAccessTimeChanged || IsLastWriteTimeChanged)
            {
                flag |= 0x00000008;
            }

            if (IsExtensionsChanged)
            {
                flag |= 0x80000000;
            }

            stream.Write(flag);

            if (IsSizeChanged && IsRegularFile)
            {
                stream.Write((ulong)Size);
            }

            if (IsUserIdChanged || IsGroupIdChanged)
            {
                stream.Write((uint)UserId);
                stream.Write((uint)GroupId);
            }

            if (IsPermissionsChanged)
            {
                stream.Write(Permissions);
            }

            if (IsLastAccessTimeChanged || IsLastWriteTimeChanged)
            {
                var time = (uint)(LastAccessTimeUtc.ToFileTimeUtc() / 10000000 - 11644473600);
                stream.Write(time);
                time = (uint)(LastWriteTimeUtc.ToFileTimeUtc() / 10000000 - 11644473600);
                stream.Write(time);
            }

            if (IsExtensionsChanged)
            {
                foreach (var item in Extensions)
                {
                    // TODO: we write as ASCII but read as UTF8 !!!

                    stream.Write(item.Key, SshData.Ascii);
                    stream.Write(item.Value, SshData.Ascii);
                }
            }

            return(stream.ToArray());
        }