Exemplo n.º 1
0
 public static CdtextData ReadCdtextData(char driveLetter)
 {
     using (CdromReader reader = new CdromReader(driveLetter))
     {
         return(reader.ReadCdtext());
     }
 }
Exemplo n.º 2
0
        private IEnumerator <ArraySegment <byte> > ReadData(CdromReader reader, uint diskOffset, uint sectorCount, bool includeRiffHeader)
        {
            try
            {
                uint totalBytes = (uint)CdromReader.SectorSize * sectorCount;

                if (includeRiffHeader)
                {
                    const uint RiffHeaderSize            = 0x28;
                    const uint RiffHeaderSizeWithoutSize = 0x24;

                    streamTotalLength = totalBytes + RiffHeaderSize;

                    byte[] waveHeader = new byte[] {
                        0x52, 0x49, 0x46, 0x46, 0x24, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45,
                        0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
                        0x44, 0xAC, 0x00, 0x00, 0x10, 0xB1, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00,
                        0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00
                    };

                    Array.Copy(BitConverter.GetBytes(totalBytes + RiffHeaderSizeWithoutSize), 0, waveHeader, 0x04, 4);
                    Array.Copy(BitConverter.GetBytes(totalBytes), 0, waveHeader, 0x28, 4);

                    yield return(new ArraySegment <byte>(waveHeader));
                }
                else
                {
                    streamTotalLength = totalBytes;
                }

                const uint BufferSizeInSectors = 20;
                const int  BufferSize          = (int)BufferSizeInSectors * CdromReader.SectorSize;
                byte[]     buffer   = new byte[BufferSize];
                uint       position = 0;
                while (position + BufferSizeInSectors < sectorCount)
                {
                    reader.ReadSectors(diskOffset + position, BufferSizeInSectors, buffer);
                    yield return(new ArraySegment <byte>(buffer));

                    position += BufferSizeInSectors;
                }

                uint tail = sectorCount - position;
                reader.ReadSectors(diskOffset + position, tail, buffer);
                yield return(new ArraySegment <byte>(buffer, 0, (int)tail * CdromReader.SectorSize));
            }
            finally
            {
                reader.Close();
            }
        }
Exemplo n.º 3
0
        public CdromFileStream(CdromFileInfo fileInfo, bool includeWaveHeader)
        {
            if (fileInfo == null) throw new ArgumentNullException("fileInfo");

            CdromReader reader = new CdromReader(fileInfo.DriveLetter);
            try
            {
                this.dataSource = ReadData(reader,
                    fileInfo.StartSector, fileInfo.SectorCount, includeWaveHeader);

                InitializeData();
            }
            catch
            {
                reader.Close();
                throw;
            }
        }
Exemplo n.º 4
0
        public CdromFileStream(CdromFileInfo fileInfo, bool includeWaveHeader)
        {
            if (fileInfo == null)
            {
                throw new ArgumentNullException("fileInfo");
            }

            CdromReader reader = new CdromReader(fileInfo.DriveLetter);

            try
            {
                this.dataSource = ReadData(reader,
                                           fileInfo.StartSector, fileInfo.SectorCount, includeWaveHeader);

                InitializeData();
            }
            catch
            {
                reader.Close();
                throw;
            }
        }
Exemplo n.º 5
0
 public static CdtextData ReadCdtextData(char driveLetter)
 {
     using (CdromReader reader = new CdromReader(driveLetter))
     {
         return reader.ReadCdtext();
     }
 }
Exemplo n.º 6
0
        private IEnumerator<ArraySegment<byte>> ReadData(CdromReader reader, uint diskOffset, uint sectorCount, bool includeRiffHeader)
        {
            try
            {
                uint totalBytes = (uint)CdromReader.SectorSize * sectorCount;

                if (includeRiffHeader)
                {
                    const uint RiffHeaderSize = 0x28;
                    const uint RiffHeaderSizeWithoutSize = 0x24;

                    streamTotalLength = totalBytes + RiffHeaderSize;

                    byte[] waveHeader = new byte[] {
                        0x52, 0x49, 0x46, 0x46, 0x24, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45,
                        0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
                        0x44, 0xAC, 0x00, 0x00, 0x10, 0xB1, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00,
                        0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00 };

                    Array.Copy(BitConverter.GetBytes(totalBytes + RiffHeaderSizeWithoutSize), 0, waveHeader, 0x04, 4);
                    Array.Copy(BitConverter.GetBytes(totalBytes), 0, waveHeader, 0x28, 4);

                    yield return new ArraySegment<byte>(waveHeader);
                }
                else
                    streamTotalLength = totalBytes;

                const uint BufferSizeInSectors = 20;
                const int BufferSize = (int)BufferSizeInSectors * CdromReader.SectorSize;
                byte[] buffer = new byte[BufferSize];
                uint position = 0;
                while (position + BufferSizeInSectors < sectorCount)
                {
                    reader.ReadSectors(diskOffset + position, BufferSizeInSectors, buffer);
                    yield return new ArraySegment<byte>(buffer);
                    position += BufferSizeInSectors;
                }

                uint tail = sectorCount - position;
                reader.ReadSectors(diskOffset + position, tail, buffer);
                yield return new ArraySegment<byte>(buffer, 0, (int)tail * CdromReader.SectorSize);
            }
            finally
            {
                reader.Close();
            }
        }