public DynamicHeader(long dataOffset, long tableOffset, uint blockSize, long diskSize) { Cookie = HeaderCookie; DataOffset = dataOffset; TableOffset = tableOffset; HeaderVersion = Version1; BlockSize = blockSize; MaxTableEntries = (int)((diskSize + blockSize - 1) / blockSize); ParentTimestamp = Footer.EpochUtc; ParentUnicodeName = string.Empty; ParentLocators = new ParentLocator[8]; for (int i = 0; i < 8; ++i) { ParentLocators[i] = new ParentLocator(); } }
public DynamicHeader(DynamicHeader toCopy) { Cookie = toCopy.Cookie; DataOffset = toCopy.DataOffset; TableOffset = toCopy.TableOffset; HeaderVersion = toCopy.HeaderVersion; MaxTableEntries = toCopy.MaxTableEntries; BlockSize = toCopy.BlockSize; Checksum = toCopy.Checksum; ParentUniqueId = toCopy.ParentUniqueId; ParentTimestamp = toCopy.ParentTimestamp; ParentUnicodeName = toCopy.ParentUnicodeName; ParentLocators = new ParentLocator[toCopy.ParentLocators.Length]; for (int i = 0; i < ParentLocators.Length; ++i) { ParentLocators[i] = new ParentLocator(toCopy.ParentLocators[i]); } }
public static DynamicHeader FromBytes(byte[] data, int offset) { DynamicHeader result = new DynamicHeader(); result.Cookie = Utilities.BytesToString(data, offset, 8); result.DataOffset = Utilities.ToInt64BigEndian(data, offset + 8); result.TableOffset = Utilities.ToInt64BigEndian(data, offset + 16); result.HeaderVersion = Utilities.ToUInt32BigEndian(data, offset + 24); result.MaxTableEntries = Utilities.ToInt32BigEndian(data, offset + 28); result.BlockSize = Utilities.ToUInt32BigEndian(data, offset + 32); result.Checksum = Utilities.ToUInt32BigEndian(data, offset + 36); result.ParentUniqueId = Utilities.ToGuidBigEndian(data, offset + 40); result.ParentTimestamp = Footer.EpochUtc.AddSeconds(Utilities.ToUInt32BigEndian(data, offset + 56)); result.ParentUnicodeName = Encoding.BigEndianUnicode.GetString(data, offset + 64, 512).TrimEnd('\0'); result.ParentLocators = new ParentLocator[8]; for (int i = 0; i < 8; ++i) { result.ParentLocators[i] = ParentLocator.FromBytes(data, offset + 576 + (i * 24)); } return(result); }