Ejemplo n.º 1
0
        /// <summary>
        /// The constructor for the DiskInformation class.  It parses the information from the
        /// memory buffer that contains the raw SCSI result.
        /// </summary>
        /// <param name="buffer">The buffer containing the raw SCSI result</param>
        /// <param name="size">The size of the raw SCSI result buffer</param>
        public DiskInformation(IntPtr buffer, int size) : base(buffer, size)
        {
            ushort len = Get16(0);
            byte   b   = Get8(2);

            if ((b & 0x10) != 0)
            {
                m_erasable = true;
            }
            else
            {
                m_erasable = false;
            }

            m_session_state = (SessionStateType)((b >> 2) & 0x03);
            m_disk_status   = (DiskStatusType)(b & 0x03);

            m_first_track   = Get8(3);
            m_session_count = (ushort)(Get8(4) | (Get8(9) << 8));
            m_first_track_in_last_session = (ushort)(Get8(5) | (Get8(10) << 8));
            m_last_track_in_last_session  = (ushort)(Get8(6) | (Get8(11) << 8));

            b = Get8(7);
            if ((b & 0x80) != 0)
            {
                m_disk_id_valid       = true;
                m_disk_identification = Get32(12);
            }
            else
            {
                m_disk_id_valid = false;
            }

            if ((b & 0x40) != 0)
            {
                m_disk_bar_code_valid = true;
                m_disk_bar_code       = new byte[8];
                for (int i = 24; i <= 31; i++)
                {
                    m_disk_bar_code[i - 24] = Get8(i);
                }
            }
            else
            {
                m_disk_bar_code_valid = false;
                m_disk_bar_code       = null;
            }

            if ((b & 0x20) != 0)
            {
                m_unrestricted_disk_use = true;
            }
            else
            {
                m_unrestricted_disk_use = false;
            }

            if ((b & 0x10) != 0)
            {
                m_disk_application_code_valid = true;
                m_disk_application_code       = Get8(32);
            }
            else
            {
                m_disk_application_code_valid = false;
            }

            if ((b & 0x04) != 0)
            {
                m_dirty_bit = true;
            }
            else
            {
                m_dirty_bit = false;
            }

            m_background_format_status = (BackgroundFormatStatusType)(b & 0x03);

            m_last_session_lead_in_start_address  = new MinuteSecondFrame(Get8(16) * 60 + Get8(17), Get8(18), Get8(19));
            m_last_possible_leadout_start_address = new MinuteSecondFrame(Get8(20) * 60 + Get8(21), Get8(22), Get8(23));

            OpcTable = new List <OpcTableEntry>();

            if (BufferSize > 33)
            {
                byte cnt    = Get8(33);
                int  offset = 34;

                for (byte i = 0; i < cnt && offset < BufferSize; i++)
                {
                    OpcTableEntry entry = new OpcTableEntry(Buffer, BufferSize, offset);
                    OpcTable.Add(entry);
                    offset += 8;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The constructor for the DiskInformation class.  It parses the information from the
        /// memory buffer that contains the raw SCSI result.
        /// </summary>
        /// <param name="buffer">The buffer containing the raw SCSI result</param>
        /// <param name="size">The size of the raw SCSI result buffer</param>
        public DiskInformation(IntPtr buffer, int size) : base(buffer, size)
        {
            ushort len = Get16(0);
            byte b = Get8(2);

            if ((b & 0x10) != 0)
                m_erasable = true;
            else
                m_erasable = false;

            m_session_state = (SessionStateType)((b >> 2) & 0x03);
            m_disk_status = (DiskStatusType)(b & 0x03);

            m_first_track = Get8(3);
            m_session_count = (ushort)(Get8(4) | (Get8(9) << 8));
            m_first_track_in_last_session = (ushort)(Get8(5) | (Get8(10) << 8));
            m_last_track_in_last_session = (ushort)(Get8(6) | (Get8(11) << 8));

            b = Get8(7);
            if ((b & 0x80) != 0)
            {
                m_disk_id_valid = true;
                m_disk_identification = Get32(12);
            }
            else
                m_disk_id_valid = false;

            if ((b & 0x40) != 0)
            {
                m_disk_bar_code_valid = true;
                m_disk_bar_code = new byte[8];
                for (int i = 24; i <= 31; i++)
                    m_disk_bar_code[i - 24] = Get8(i);
            }
            else
            {
                m_disk_bar_code_valid = false;
                m_disk_bar_code = null;
            }

            if ((b & 0x20) != 0)
                m_unrestricted_disk_use = true;
            else
                m_unrestricted_disk_use = false;

            if ((b & 0x10) != 0)
            {
                m_disk_application_code_valid = true;
                m_disk_application_code = Get8(32);
            }
            else
                m_disk_application_code_valid = false;

            if ((b & 0x04) != 0)
                m_dirty_bit = true;
            else
                m_dirty_bit = false;

            m_background_format_status = (BackgroundFormatStatusType)(b & 0x03);

            m_last_session_lead_in_start_address = new MinuteSecondFrame(Get8(16) * 60 + Get8(17), Get8(18), Get8(19));
            m_last_possible_leadout_start_address = new MinuteSecondFrame(Get8(20) * 60 + Get8(21), Get8(22), Get8(23));

            OpcTable = new List<OpcTableEntry>();

            if (BufferSize > 33)
            {
                byte cnt = Get8(33);
                int offset = 34;

                for(byte i = 0 ; i < cnt && offset < BufferSize ; i++)
                {
                    OpcTableEntry entry = new OpcTableEntry(Buffer, BufferSize, offset);
                    OpcTable.Add(entry);
                    offset += 8;
                }
            }
        }