本文整理汇总了C#中IO.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IO.Dispose方法的具体用法?C# IO.Dispose怎么用?C# IO.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IO
的用法示例。
在下文中一共展示了IO.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyXvcHash
public bool VerifyXvcHash(bool rehash = false)
{
if (!IsXvcFile)
return true;
ulong hashTreeSize = HashTreeBlockCount * 0x1000;
var ms = new MemoryStream();
var msIo = new IO(ms);
msIo.Writer.WriteStruct(XvcInfo);
for (int i = 0; i < XvcInfo.RegionCount; i++)
msIo.Writer.WriteStruct(RegionHeaders[i]);
for (int i = 0; i < XvcInfo.UpdateSegmentCount; i++)
msIo.Writer.WriteStruct(UpdateSegments[i]);
msIo.Stream.SetLength(Header.XvcDataLength);
// fix region headers to match pre-hashtable
msIo.Stream.Position = 0xDA8 + 0x50;
for (int i = 0; i < XvcInfo.RegionCount; i++)
{
ulong length = RegionHeaders[i].Length;
ulong offset = RegionHeaders[i].Offset;
if (IsDataIntegrityEnabled)
{
if ((offset == HashTreeOffset || offset < HashTreeOffset) && HashTreeOffset < (offset + length))
length -= hashTreeSize;
else if (offset > HashTreeOffset)
offset -= hashTreeSize;
}
msIo.Writer.Write(offset); // write fixed offset
msIo.Writer.Write(length); // write fixed length
msIo.Writer.Write((ulong)0); // null out PDUID
msIo.Stream.Position += (0x80 - 24);
}
if (IsDataIntegrityEnabled)
{
// remove hash table offset from the special regions
if (XvcInfo.InitialPlayOffset > HashTreeOffset)
{
msIo.Stream.Position = 0xD28;
msIo.Writer.Write(XvcInfo.InitialPlayOffset - hashTreeSize);
}
if (XvcInfo.PreviewOffset > HashTreeOffset)
{
msIo.Stream.Position = 0xD40;
msIo.Writer.Write(XvcInfo.PreviewOffset - hashTreeSize);
}
}
byte[] xvcData = ms.ToArray();
msIo.Dispose();
byte[] hash = SHA256.Create().ComputeHash(xvcData);
bool isValid = Header.OriginalXvcDataHash.IsEqualTo(hash);
if (rehash)
Header.OriginalXvcDataHash = hash;
return isValid; //todo: investigate why this gets the correct hash for dev XVCs but fails for retail ones, might be to do with retail XVC data having a content ID that doesn't match with VDUID/UDUID
}