Пример #1
0
        public override void Decode(BinaryReader reader)
        {
            string result = "";
            byte   b      = reader.ReadByte();

            if (b == 1)
            {
                result         = IOFunctions.ReadCAString(reader, stringEncoding);
                readLengthZero = result.Length == 0;
            }
            else if (b != 0)
            {
                throw new InvalidDataException(string.Format("- invalid - ({0:x2})", b));
            }
            Value = result;
        }
Пример #2
0
        public static DBFileHeader readHeader(BinaryReader reader)
        {
            byte   index      = reader.ReadByte();
            int    version    = 0;
            string guid       = "";
            bool   hasMarker  = false;
            uint   entryCount = 0;

            try
            {
                if (index != 1)
                {
                    // I don't think those can actually occur more than once per file
                    while (index == 0xFC || index == 0xFD)
                    {
                        var bytes = new List <byte>(4);
                        bytes.Add(index);
                        bytes.AddRange(reader.ReadBytes(3));
                        UInt32 marker = BitConverter.ToUInt32(bytes.ToArray(), 0);
                        if (marker == GUID_MARKER)
                        {
                            guid  = IOFunctions.ReadCAString(reader, Encoding.Unicode);
                            index = reader.ReadByte();
                        }
                        else if (marker == VERSION_MARKER)
                        {
                            hasMarker = true;
                            version   = reader.ReadInt32();
                            index     = reader.ReadByte();
                            // break;
                        }
                        else
                        {
                            throw new DBFileNotSupportedException(string.Format("could not interpret {0}", marker));
                        }
                    }
                }
                entryCount = reader.ReadUInt32();
            }
            catch
            {
            }
            DBFileHeader header = new DBFileHeader(guid, version, entryCount, hasMarker);

            return(header);
        }
Пример #3
0
 public override void Decode(BinaryReader reader)
 {
     Value = IOFunctions.ReadCAString(reader, stringEncoding);
 }