Exemple #1
0
        public ISOFileReader(Stream file)
            : base(file)
        {
            if (file.Length < 17 * sectorSize)
            {
                throw new InvalidDataException("ISO too small to be valid");
            }
            IsUDF = false;
            int i      = 15;
            int BNT    = 0;
            var sector = new byte[sectorSize];

            do
            {
                string type;
                if (!ReadSector(sector, 0, ++i) || !VolumeDesciptor.isValid(sector, out type))
                {
                    break;
                }
                Debug.WriteLine("Volume Structure Descriptor type: " + type);
                if (pvd == null && type == "CD001" && sector[0] == 1)
                {
                    pvdSector = i;
                    pvd       = new PrimaryVolumeDescriptor(sector, file);
                }
                else if (BNT < 3)
                {
                    if (BNT == 0 && type == "BEA01")
                    {
                        ++BNT;
                        BEASector = i;
                        Debug.WriteLine("Found UDF descriptors starting at sector " + i);
                    }
                    else if (BNT == 1 && (type == "NSR02" || type == "NSR03"))
                    {
                        IsUDF = true;
                        NSRSector.Add(TEASector = i);
                    }
                    else if (BNT == 1 && type == "TEA01")
                    {
                        ++BNT;
                        TEASector = i;
                        Debug.WriteLine("Found UDF descriptors ending at sector " + i);
                    }
                }
            } while (true);
            if (pvd == null)
            {
                throw new InvalidDataException("Failed to find root directory on ISO");
            }
            Debug.WriteLine("Successfully opened ISO image");
        }
Exemple #2
0
 public virtual void Dispose(bool disposing)
 {
     if (file != null)
     {
         file.Dispose();
         file = null;
     }
     if (disposing)
     {
         if (pvd != null)
         {
             pvd = null;
         }
     }
 }