本文整理汇总了C#中Blamite.IO.FileSegmentGroup.PointerToOffset方法的典型用法代码示例。如果您正苦于以下问题:C# FileSegmentGroup.PointerToOffset方法的具体用法?C# FileSegmentGroup.PointerToOffset怎么用?C# FileSegmentGroup.PointerToOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blamite.IO.FileSegmentGroup
的用法示例。
在下文中一共展示了FileSegmentGroup.PointerToOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteReflexive
/// <summary>
/// Writes data to a reflexive at a particular address.
/// </summary>
/// <param name="entries">The entries to write.</param>
/// <param name="address">The address to write to.</param>
/// <param name="layout">The layout of the data to write.</param>
/// <param name="metaArea">The meta area of the cache file.</param>
/// <param name="writer">The stream to write to.</param>
public static void WriteReflexive(IEnumerable<StructureValueCollection> entries, uint address, StructureLayout layout,
FileSegmentGroup metaArea, IWriter writer)
{
int offset = metaArea.PointerToOffset(address);
int index = 0;
foreach (StructureValueCollection entry in entries)
{
writer.SeekTo(offset + index*layout.Size);
StructureWriter.WriteStructure(entry, layout, writer);
index++;
}
}
示例2: FromPointer
/// <summary>
/// Given a pointer, creates a SegmentPointer which points to a segment in a certain group.
/// </summary>
/// <param name="pointer">The pointer to create a SegmentPointer to.</param>
/// <param name="baseGroup">The segment group containing the pointer.</param>
/// <returns>The SegmentPointer corresponding to the file pointer.</returns>
public static SegmentPointer FromPointer(uint pointer, FileSegmentGroup baseGroup)
{
if (baseGroup.Segments.Count == 0)
throw new ArgumentException("Cannot create a SegmentPointer from an empty group");
FileSegment baseSegment = baseGroup.FindSegmentWithPointer(pointer);
if (baseSegment == null)
throw new ArgumentException("Cannot create a SegmentPointer from an invalid pointer");
int baseSegmentDelta = (int)(baseGroup.PointerToOffset(pointer) - baseSegment.Offset);
return new SegmentPointer(baseSegment, baseGroup, baseSegmentDelta);
}
示例3: Load
private void Load(StructureValueCollection values, FileSegmenter segmenter, FileSegmentGroup localeArea)
{
StringCount = (int) values.GetInteger("string count");
if (StringCount > 0)
{
// Index table offset, segment, and pointer
int localeIndexTableOffset = localeArea.PointerToOffset(values.GetInteger("locale index table offset"));
LocaleIndexTable = segmenter.WrapSegment(localeIndexTableOffset, StringCount*8, 8, SegmentResizeOrigin.End);
LocaleIndexTableLocation = localeArea.AddSegment(LocaleIndexTable);
// Data offset, segment, and pointer
int localeDataOffset = localeArea.PointerToOffset(values.GetInteger("locale data index offset"));
var localeDataSize = (int) values.GetInteger("locale table size");
LocaleData = segmenter.WrapSegment(localeDataOffset, localeDataSize, _sizeAlign, SegmentResizeOrigin.End);
LocaleDataLocation = localeArea.AddSegment(LocaleData);
// Load hashes if they exist
if (values.HasRaw("index table hash"))
IndexTableHash = values.GetRaw("index table hash");
if (values.HasRaw("string data hash"))
StringDataHash = values.GetRaw("string data hash");
}
}
示例4: ReadReflexive
public static StructureValueCollection[] ReadReflexive(IReader reader, int count, uint address, StructureLayout entryLayout, FileSegmentGroup metaArea)
{
if (entryLayout.Size == 0)
throw new ArgumentException("The entry layout must have a size associated with it.");
// Handle null pointers
if (count <= 0 || !metaArea.ContainsPointer(address))
return new StructureValueCollection[0];
// Convert the address to an offset and seek to it
int offset = metaArea.PointerToOffset(address);
reader.SeekTo(offset);
// Read the entries
StructureValueCollection[] result = new StructureValueCollection[count];
for (int i = 0; i < count; i++)
result[i] = StructureReader.ReadStructure(reader, entryLayout);
return result;
}