/* This file is part of libmspack. * (C) 2003-2018 Stuart Caie. * * libmspack is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License (LGPL) version 2.1 * * For further details, see the file COPYING.LIB distributed with libmspack */ using System; namespace LibMSPackSharp.CAB { internal class _DataBlockHeader { #region Fields /// /// Block CRC32 checksum /// /// 0x00 public uint CheckSum { get; private set; } /// /// Compressed size of the data block /// /// 0x04 public ushort CompressedSize { get; private set; } /// /// Uncompressed size of the data block /// /// 0x06 public ushort UncompressedSize { get; private set; } /// /// Size of the Data Block header in bytes /// public const int Size = 0x08; #endregion /// /// Private constructor /// private _DataBlockHeader() { } /// /// Create a _DataBlockHeader from a byte array, if possible /// public static Error Create(byte[] buffer, out _DataBlockHeader header) { header = null; if (buffer == null || buffer.Length < Size) return Error.MSPACK_ERR_READ; header = new _DataBlockHeader(); header.CheckSum = BitConverter.ToUInt32(buffer, 0x00); header.CompressedSize = BitConverter.ToUInt16(buffer, 0x04); header.UncompressedSize = BitConverter.ToUInt16(buffer, 0x06); return Error.MSPACK_ERR_OK; } } }