コード例 #1
0
        // Methods

        /// <summary>
        /// Read a sector's data
        /// </summary>
        /// <param name="mode">Sector's mode</param>
        public byte[] ReadSector(SectorMode mode)
        {
            try
            {
                byte[] buffer;

                int dataSize = GetSectorDataSize(mode);
                buffer = new byte[dataSize];

                if (mode != SectorMode.RAW)
                {
                    _stream.Position += (SYNC_SIZE + HEADER_SIZE);
                }

                if (mode == SectorMode.XA_FORM1 || mode == SectorMode.XA_FORM2)
                {
                    _stream.Position += SUBHEADER_SIZE;
                }

                _stream.Read(buffer, 0, dataSize);

                if (mode == SectorMode.MODE1 || mode == SectorMode.XA_FORM1)
                {
                    _stream.Position += EDC_SIZE;
                }

                if (mode == SectorMode.MODE1)
                {
                    _stream.Position += INTERMEDIATE_SIZE;
                }

                if (mode == SectorMode.MODE1 || mode == SectorMode.XA_FORM1)
                {
                    _stream.Position += ECC_SIZE;
                }

                if (mode == SectorMode.XA_FORM2)
                {
                    _stream.Position += EDC_SIZE;
                }

                return(buffer);
            }
            catch (FrameworkException ex)
            {
                throw ex;
            }
            catch (EndOfStreamException)
            {
                throw new FrameworkException("Errow while reading sector : end of file occured");
            }
            catch (Exception)
            {
                throw new FrameworkException("Errow while reading sector : unable to read sector");
            }
        }