示例#1
0
        public static SFOHeader Read(Stream fIn)
        {
            SFOHeader sfoHeader = new SFOHeader();

            byte[] tempByteArray = new byte[4];

            // read FileType
            fIn.Read(tempByteArray, 0, 4);
            sfoHeader.SetFileType(SFOReaderUtilities.ByteArrayToString(tempByteArray));

            // read sfoVerion
            fIn.Read(tempByteArray, 0, 4);
            sfoHeader.SetSfoVersion(SFOReaderUtilities.ByteArrayToString(tempByteArray));

            // read offsetKeyTable
            fIn.Read(tempByteArray, 0, 4);
            sfoHeader.SetOffsetKeyTable(SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray));

            // read offsetValueTable
            fIn.Read(tempByteArray, 0, 4);
            sfoHeader.SetOffsetValueTable(SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray));

            // read numberDataItem
            fIn.Read(tempByteArray, 0, 4);
            sfoHeader.SetNumberDataItems(SFOReaderUtilities.ByteArrayReverseToInt(tempByteArray));

            return(sfoHeader);
        }
        /**
         * Reads an entry of the dataValueTable an return it as String
         *
         * @param fIn
         * @param sfoIndexTableEntry
         * @return String
         * @throws IOException
         */
        public string ReadEntry(Stream sfoFile, SFOIndexTableEntry sfoIndexTableEntry)
        {
            byte[] entryByteArray = new byte[sfoIndexTableEntry.GetSizeValueData()];

            sfoFile.Read(entryByteArray, 0, sfoIndexTableEntry.GetSizeValueData());
            this.valueBytesReaded += sfoIndexTableEntry.GetSizeValueData();

            long offsetNextValue = sfoIndexTableEntry.GetOffsetDataValueInDataTable() +
                                   sfoIndexTableEntry.GetSizeValueDataAndPadding(); // korrekt!
            long skipBytes = offsetNextValue - this.valueBytesReaded;

            sfoFile.Seek(skipBytes, SeekOrigin.Current);
            this.valueBytesReaded += Convert.ToInt32(skipBytes);

            return(SFOReaderUtilities.ByteArrayToString(entryByteArray, true));
        }
 /**
  * Converts any byte[]-Array to a string with the specified encoding.
  *
  * @param byteArray
  * @param encoding
  * @return String
  */
 public static string ByteArrayToString(byte[] byteArray)
 {
     return(SFOReaderUtilities.ByteArrayToString(byteArray, false));
 }