Exemplo n.º 1
0
        public static PriamTag?DecodePriamTag(byte[] tag)
        {
            if (tag == null || tag.Length != 24)
            {
                return(null);
            }

            PriamTag pmTag = new PriamTag();

            BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;

            byte[] tmp = new byte[4];

            pmTag.Version   = BigEndianBitConverter.ToUInt16(tag, 0);
            pmTag.Kind      = (byte)((tag[2] & 0xC0) >> 6);
            pmTag.Reserved  = (byte)(tag[2] & 0x3F);
            pmTag.Volume    = tag[3];
            pmTag.FileId    = BigEndianBitConverter.ToInt16(tag, 4);
            pmTag.ValidChk |= (tag[6] & 0x80) == 0x80;
            pmTag.UsedBytes = (ushort)(BigEndianBitConverter.ToUInt16(tag, 6) & 0x7FFF);

            tmp[0]        = 0x00;
            tmp[1]        = tag[8];
            tmp[2]        = tag[9];
            tmp[3]        = tag[10];
            pmTag.AbsPage = BigEndianBitConverter.ToUInt32(tmp, 0);

            pmTag.Checksum = tag[11];
            pmTag.RelPage  = BigEndianBitConverter.ToUInt16(tag, 12);

            tmp[0]          = 0x00;
            tmp[1]          = tag[14];
            tmp[2]          = tag[15];
            tmp[3]          = tag[16];
            pmTag.NextBlock = BigEndianBitConverter.ToUInt32(tmp, 0);

            tmp[0]          = 0x00;
            tmp[1]          = tag[17];
            tmp[2]          = tag[18];
            tmp[3]          = tag[19];
            pmTag.PrevBlock = BigEndianBitConverter.ToUInt32(tmp, 0);

            pmTag.DiskSize = BigEndianBitConverter.ToUInt32(tag, 20);

            pmTag.IsLast  = pmTag.NextBlock == 0xFFFFFF;
            pmTag.IsFirst = pmTag.PrevBlock == 0xFFFFFF;

            return(pmTag);
        }
Exemplo n.º 2
0
        public static PriamTag?DecodeTag(byte[] tag)
        {
            if (tag == null)
            {
                return(null);
            }

            PriamTag pmTag;

            switch (tag.Length)
            {
            case 12:
                SonyTag?snTag = DecodeSonyTag(tag);

                if (snTag == null)
                {
                    return(null);
                }

                pmTag           = new PriamTag();
                pmTag.AbsPage   = 0;
                pmTag.Checksum  = 0;
                pmTag.DiskSize  = 0;
                pmTag.FileId    = snTag.Value.FileId;
                pmTag.Kind      = snTag.Value.Kind;
                pmTag.NextBlock = snTag.Value.NextBlock;
                pmTag.PrevBlock = snTag.Value.PrevBlock;
                pmTag.RelPage   = snTag.Value.RelPage;
                pmTag.Reserved  = snTag.Value.Reserved;
                pmTag.UsedBytes = 0;
                pmTag.ValidChk  = false;
                pmTag.Version   = snTag.Value.Version;
                pmTag.Volume    = snTag.Value.Volume;
                pmTag.IsFirst   = snTag.Value.IsFirst;
                pmTag.IsLast    = snTag.Value.IsLast;

                return(pmTag);

            case 20:
                ProfileTag?phTag = DecodeProfileTag(tag);

                if (phTag == null)
                {
                    return(null);
                }

                pmTag           = new PriamTag();
                pmTag.AbsPage   = phTag.Value.AbsPage;
                pmTag.Checksum  = phTag.Value.Checksum;
                pmTag.DiskSize  = 0;
                pmTag.FileId    = phTag.Value.FileId;
                pmTag.Kind      = phTag.Value.Kind;
                pmTag.NextBlock = phTag.Value.NextBlock;
                pmTag.PrevBlock = phTag.Value.PrevBlock;
                pmTag.RelPage   = phTag.Value.RelPage;
                pmTag.Reserved  = phTag.Value.Reserved;
                pmTag.UsedBytes = phTag.Value.UsedBytes;
                pmTag.ValidChk  = phTag.Value.ValidChk;
                pmTag.Version   = phTag.Value.Version;
                pmTag.Volume    = phTag.Value.Volume;
                pmTag.IsFirst   = phTag.Value.IsFirst;
                pmTag.IsLast    = phTag.Value.IsLast;

                return(pmTag);

            case 24: return(DecodePriamTag(tag));

            default: return(null);
            }
        }