Ejemplo n.º 1
0
        /// <summary>
        /// Returns list of catalog entries with files
        /// </summary>
        /// <param name="diskImage"></param>
        /// <returns></returns>
        public IEnumerable <CatalogEntry> GetCatalogs(Stream diskImage)
        {
            var vtoc = GetVolumeTableOfContents(diskImage);

            var track        = vtoc.FirstCatalogTrack;
            var sector       = vtoc.FirstCatalogSector;
            var trackSectors = vtoc.NumberOfSectorsPerTrack;
            var sectorLength = vtoc.NumberOfBytesPerSector;

            var buffer = new byte[sectorLength];

next:

            Span <byte> catalogSpan = buffer;
            var location            = track * trackSectors * sectorLength + sector * sectorLength;

            diskImage.Position = location;
            var read = diskImage.Read(catalogSpan);
            var item = new CatalogEntry(catalogSpan.Slice(0, read));

            yield return(item);

            if (item.NextCatalogTrack != 0 && item.NextSectorTrack != 0)
            {
                track  = item.NextCatalogTrack;
                sector = item.NextSectorTrack;
                goto next;
            }
        }
Ejemplo n.º 2
0
        //private byte[] _data;
        public IEnumerable <CatalogEntry> GetCatalogs(Stream diskImage, VolumeTableOfContents vtoc)
        {
            var catalogTrack  = vtoc.FirstCatalogTrack;
            var catalogSector = vtoc.FirstCatalogSector;
            var trackSectors  = vtoc.NumberOfSectorsPerTrack;
            var sectorLength  = vtoc.NumberOfBytesPerSector;

nextCatalog:

            var catalogLocation = catalogTrack * trackSectors * sectorLength + catalogSector * sectorLength;

            var catalogSpan = new byte[sectorLength];

            diskImage.Position = catalogLocation;
            diskImage.Read(catalogSpan, 0, 0);
            var catalog = new CatalogEntry
            {
                // Unused0 = catalogSpan[0x0],
                NextCatalogTrack = catalogSpan[0x01],
                NextSectorTrack  = catalogSpan[0x02],
                //Unused3_A = sectorSpan.Slice(0x03, 0x0a - 0x03 + 1).ToArray(),

                FileEntries = GetFileEntries(diskImage, catalogSpan, 0x0b, 0x2e, 0x51, 0x74, 0x97, 0xba, 0xdd),
            };

            yield return(catalog);

            Console.WriteLine($"Catalog: {catalog}");

            if (catalog.NextCatalogTrack != 0 && catalog.NextSectorTrack != 0)
            {
                catalogTrack  = catalog.NextCatalogTrack;
                catalogSector = catalog.NextSectorTrack;
                goto nextCatalog;
            }
        }