public static SFOHeader Read(Stream fIn) { SFOHeader sfoHeader = new SFOHeader(); byte[] tempByteArray = new byte[4]; // read FileType fIn.Read(tempByteArray, 0, 4); sfoHeader.FileType = SFOReaderUtilities.ByteArrayToString(tempByteArray); // read sfoVerion fIn.Read(tempByteArray, 0, 4); sfoHeader.SfoVersion = SFOReaderUtilities.ByteArrayToString(tempByteArray); // read offsetKeyTable fIn.Read(tempByteArray, 0, 4); sfoHeader.OffsetKeyTable = SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray); // read offsetValueTable fIn.Read(tempByteArray, 0, 4); sfoHeader.OffsetValueTable = SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray); // read numberDataItem fIn.Read(tempByteArray, 0, 4); sfoHeader.NumberDataItems = SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray); return(sfoHeader); }
/// <summary> /// Reads one entry of the indexTable and return it's values in a SFOIndexTableEntry-object /// </summary> public static SFOIndexTableEntry ReadEntry(Stream fIn) { SFOIndexTableEntry sfoIndexTableEntry = new SFOIndexTableEntry(); byte[] tempByteArray1 = new byte[1]; byte[] tempByteArray2 = new byte[2]; byte[] tempByteArray4 = new byte[4]; // read offsetKeyNameInKeyTable fIn.Read(tempByteArray2, 0, 2); sfoIndexTableEntry.OffsetKeyNameInKeyTable = tempByteArray2; // read dataAlignmentRequirements fIn.Read(tempByteArray1, 0, 1); sfoIndexTableEntry.DataAlignmentRequirements = tempByteArray1[0]; // read dataTypeValue fIn.Read(tempByteArray1, 0, 1); sfoIndexTableEntry.DataTypeValue = tempByteArray1[0]; // read sizeValueData fIn.Read(tempByteArray4, 0, 4); sfoIndexTableEntry.SizeValueData = SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray4); // read sizeValueDataAndPadding fIn.Read(tempByteArray4, 0, 4); sfoIndexTableEntry.SizeValueDataAndPadding = SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray4); // read offsetDataValueInDataTable fIn.Read(tempByteArray4, 0, 4); sfoIndexTableEntry.OffsetDataValueInDataTable = SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray4); return(sfoIndexTableEntry); }