public byte[] GetBytes() { byte[] data; var stm = new MemoryStream(); var rdr = new LeImageReader(image, (uint) offset); byte trackNext = rdr.ReadByte(); while (trackNext != 0) { byte sectorNext = rdr.ReadByte(); data = rdr.ReadBytes(0xFE); stm.Write(data, 0, data.Length); rdr.Offset = (uint) SectorOffset(trackNext, sectorNext); trackNext = rdr.ReadByte(); } byte lastUsed = rdr.ReadByte(); data = rdr.ReadBytes(lastUsed - 2); stm.Write(data, 0, data.Length); return stm.ToArray(); }
public bool ReadDirectorySector(LeImageReader rdr, List<ArchiveDirectoryEntry> entries) { byte nextDirTrack = 0; byte nextDirSector = 0; for (int i = 0; i < 8; ++i) { if (i == 0) { nextDirTrack = rdr.ReadByte(); nextDirSector = rdr.ReadByte(); } else { rdr.Seek(2); } var fileType = (FileType) rdr.ReadByte(); var fileTrack = rdr.ReadByte(); var fileSector = rdr.ReadByte(); var sName = Encoding.ASCII.GetString(rdr.ReadBytes(16)) .TrimEnd((char) 0xA0); var relTrack = rdr.ReadByte(); var relSector = rdr.ReadByte(); var rel = rdr.ReadByte(); rdr.Seek(6); var sectorSize = rdr.ReadLeInt16(); if ((fileType & FileType.FileTypeMask) != FileType.DEL) { entries.Add(new D64FileEntry( sName, RawImage, SectorOffset(fileTrack, fileSector), fileType)); } } if (nextDirTrack != 0) { rdr.Offset = (uint) SectorOffset(nextDirTrack, nextDirSector); return true; } else { return false; } }