public void ExtractVideo(DirectoryRecord dr, string path) { int sectorId = (int)dr.ExtentLocation; int filecounter = 0; List <byte> bytes = new List <byte>(); SectorHeader sh = fs.Sectors[sectorId]; while ((sh.Submode & Submodes.EOF) == 0) { if ((sh.Submode & Submodes.Audio) == 0) { XASectorForm1 s = fs.ReadXA1Sector(sectorId); bytes.AddRange(s.Data); if ((sh.Submode & Submodes.EOR) > 0) { FileStream f = new FileStream(Path.Combine(path, "track" + filecounter.ToString("00") + ".str"), FileMode.Create); f.Write(bytes.ToArray(), 0, bytes.Count); bytes = new List <byte>(); filecounter++; } } sectorId++; sh = fs.Sectors[sectorId]; } }
private XASectorForm1 ReadSector(int index) { byte[] buffer = new byte[2352]; XASectorForm1 sector = new XASectorForm1(); fs.Seek(index * 2352, SeekOrigin.Begin); fs.Read(buffer, 0, 2352); sector.ReadBytes(buffer); return sector; }
public XASectorForm1 ReadXA1Sector(int LBAIndex) { byte[] buffer = new byte[2352]; SectorHeader header = _sectors[LBAIndex]; XASectorForm1 sector = new XASectorForm1(); FileStream fs = _streams[header.FileStreamId].Item1; fs.Seek(header.FileStreamOffset, SeekOrigin.Begin); fs.Read(buffer, 0, 2352); sector.ReadBytes(buffer); return(sector); }
private void readDirectoryRecord(int sectorId) { PrimaryVolumeDescriptor pvd = (PrimaryVolumeDescriptor)volumeDescriptors[0]; XASectorForm1 sector = fs.ReadXA1Sector(sectorId); int offset = 0; while (sector.Data[offset] != 0) { int size = sector.Data[offset]; byte[] data = new byte[size]; Array.Copy(sector.Data, offset, data, 0, size); DirectoryRecord dr = new DirectoryRecord(data); if (dr.FileIdentifierLength > 1) { dr.FileIdentifier = Encoding.ASCII.GetString(data, 33, dr.FileIdentifierLength - 2); } else { switch (data[33]) { case 0: dr.FileIdentifier = "."; break; case 1: dr.FileIdentifier = ".."; break; default: dr.FileIdentifier = ""; break; } } rootDirectory.Children.Add(dr); offset += size; } }