Example #1
0
 public D64FileEntry(D64Archive archive, string name, byte[] diskImage, int offset, FileType fileType)
 {
     this.archive  = archive;
     this.Name     = name;
     this.image    = diskImage;
     this.offset   = offset;
     this.FileType = fileType;
 }
Example #2
0
        public bool ReadDirectorySector(ImageReader rdr, D64Archive archive, 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(
                                    archive,
                                    sName,
                                    RawImage,
                                    SectorOffset(fileTrack, fileSector),
                                    fileType));
                }
            }
            if (nextDirTrack != 0)
            {
                rdr.Offset = (uint)SectorOffset(nextDirTrack, nextDirSector);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public IArchive LoadDiskDirectory()
        {
            var  entries = new List <ArchiveDirectoryEntry>();
            var  rdr     = new ByteImageReader(RawImage, (uint)SectorOffset(18, 0));
            byte track   = rdr.ReadByte();
            var  archive = new D64Archive(Services, ImageLocation, entries);

            if (track != 0)
            {
                byte sector = rdr.ReadByte();
                rdr.Offset = (uint)D64Loader.SectorOffset(track, sector);
                while (ReadDirectorySector(rdr, archive, entries))
                {
                    ;
                }
            }
            return(archive);
        }