private uint CalculateChecksum()
        {
            Footer copy = new Footer(this);
            copy.Checksum = 0;

            byte[] asBytes = new byte[512];
            copy.ToBytes(asBytes, 0);
            uint checksum = 0;
            foreach (uint value in asBytes)
            {
                checksum += value;
            }

            checksum = ~checksum;

            return checksum;
        }
 public Footer(Footer toCopy)
 {
     Cookie = toCopy.Cookie;
     Features = toCopy.Features;
     FileFormatVersion = toCopy.FileFormatVersion;
     DataOffset = toCopy.DataOffset;
     Timestamp = toCopy.Timestamp;
     CreatorApp = toCopy.CreatorApp;
     CreatorVersion = toCopy.CreatorVersion;
     CreatorHostOS = toCopy.CreatorHostOS;
     OriginalSize = toCopy.OriginalSize;
     CurrentSize = toCopy.CurrentSize;
     Geometry = toCopy.Geometry;
     DiskType = toCopy.DiskType;
     Checksum = toCopy.Checksum;
     UniqueId = toCopy.UniqueId;
     SavedState = toCopy.SavedState;
 }
        public static Footer FromBytes(byte[] buffer, int offset)
        {
            Footer result = new Footer();
            result.Cookie = Utilities.BytesToString(buffer, offset + 0, 8);
            result.Features = Utilities.ToUInt32BigEndian(buffer, offset + 8);
            result.FileFormatVersion = Utilities.ToUInt32BigEndian(buffer, offset + 12);
            result.DataOffset = Utilities.ToInt64BigEndian(buffer, offset + 16);
            result.Timestamp = EpochUtc.AddSeconds(Utilities.ToUInt32BigEndian(buffer, offset + 24));
            result.CreatorApp = Utilities.BytesToString(buffer, offset + 28, 4);
            result.CreatorVersion = Utilities.ToUInt32BigEndian(buffer, offset + 32);
            result.CreatorHostOS = Utilities.BytesToString(buffer, offset + 36, 4);
            result.OriginalSize = Utilities.ToInt64BigEndian(buffer, offset + 40);
            result.CurrentSize = Utilities.ToInt64BigEndian(buffer, offset + 48);
            result.Geometry = new Geometry(Utilities.ToUInt16BigEndian(buffer, offset + 56), buffer[58], buffer[59]);
            result.DiskType = (FileType)Utilities.ToUInt32BigEndian(buffer, offset + 60);
            result.Checksum = Utilities.ToUInt32BigEndian(buffer, offset + 64);
            result.UniqueId = Utilities.ToGuidBigEndian(buffer, offset + 68);
            result.SavedState = buffer[84];

            return result;
        }