Esempio n. 1
0
        public static SpareAreaInformation?Decode(byte[] SAIResponse)
        {
            if (SAIResponse == null)
            {
                return(null);
            }

            if (SAIResponse.Length != 16)
            {
                DicConsole.DebugWriteLine("BD Spare Area Information decoder",
                                          "Found incorrect Blu-ray Spare Area Information size ({0} bytes)",
                                          SAIResponse.Length);
                return(null);
            }

            SpareAreaInformation decoded = new SpareAreaInformation();

            BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;

            decoded.DataLength           = BigEndianBitConverter.ToUInt16(SAIResponse, 0);
            decoded.Reserved1            = SAIResponse[2];
            decoded.Reserved2            = SAIResponse[3];
            decoded.Reserved3            = BigEndianBitConverter.ToUInt32(SAIResponse, 4);
            decoded.FreeSpareBlocks      = BigEndianBitConverter.ToUInt32(SAIResponse, 8);
            decoded.AllocatedSpareBlocks = BigEndianBitConverter.ToUInt32(SAIResponse, 12);

            return(decoded);
        }
Esempio n. 2
0
        public static string Prettify(SpareAreaInformation?SAIResponse)
        {
            if (SAIResponse == null)
            {
                return(null);
            }

            SpareAreaInformation response = SAIResponse.Value;

            StringBuilder sb = new StringBuilder();

            #if DEBUG
            if (response.Reserved1 != 0)
            {
                sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
            }
            if (response.Reserved2 != 0)
            {
                sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
            }
            if (response.Reserved3 != 0)
            {
                sb.AppendFormat("Reserved3 = 0x{0:X8}", response.Reserved3).AppendLine();
            }
            #endif
            sb.AppendFormat("{0} free spare blocks", response.FreeSpareBlocks).AppendLine();
            sb.AppendFormat("{0} allocated spare blocks", response.AllocatedSpareBlocks).AppendLine();

            return(sb.ToString());
        }
Esempio n. 3
0
        public static SpareAreaInformation?Decode(byte[] SAIResponse)
        {
            if (SAIResponse == null)
            {
                return(null);
            }

            if (SAIResponse.Length != 16)
            {
                AaruConsole.DebugWriteLine("BD Spare Area Information decoder",
                                           "Found incorrect Blu-ray Spare Area Information size ({0} bytes)",
                                           SAIResponse.Length);

                return(null);
            }

            var decoded = new SpareAreaInformation
            {
                DataLength           = BigEndianBitConverter.ToUInt16(SAIResponse, 0),
                Reserved1            = SAIResponse[2],
                Reserved2            = SAIResponse[3],
                Reserved3            = BigEndianBitConverter.ToUInt32(SAIResponse, 4),
                FreeSpareBlocks      = BigEndianBitConverter.ToUInt32(SAIResponse, 8),
                AllocatedSpareBlocks = BigEndianBitConverter.ToUInt32(SAIResponse, 12)
            };

            return(decoded);
        }
Esempio n. 4
0
        public static string Prettify(SpareAreaInformation?sai)
        {
            if (sai == null)
            {
                return(null);
            }

            SpareAreaInformation decoded = sai.Value;
            StringBuilder        sb      = new StringBuilder();

            sb.AppendFormat("{0} unused primary spare blocks", decoded.UnusedPrimaryBlocks).AppendLine();
            sb.AppendFormat("{0} unused supplementary spare blocks", decoded.UnusedSupplementaryBlocks).AppendLine();
            sb.AppendFormat("{0} allocated supplementary spare blocks", decoded.AllocatedSupplementaryBlocks)
            .AppendLine();

            return(sb.ToString());
        }