示例#1
0
        public ISOCopyWriter(Stream file, ISOFileReader source)
            : base(file)
        {
            this.source   = source;
            file.Position = 0;
            //Find lowest first LBA
            uint LBA = uint.MaxValue;

            foreach (FileDescriptor f in source)
            {
                if (f.ExtentLBA < LBA)
                {
                    LBA = f.ExtentLBA;
                }
            }
            if (LBA == uint.MaxValue)
            {
                throw new InvalidDataException("No files found");
            }
            //Copy first sectors, including the "encrypted" bootscreen
            source.Seek(0);
            source.CopyTo(file, LBA * sectorSize);
            //I don't have the code to update UDF, nor do I really want to write that... so I'll just destroy the NSR descriptor.
            //I'll move everything up too, and not just destroy the whole block. Gonna be nice here. ;)
            if (source.IsUDF)
            {
                var sector = new byte[sectorSize];
                for (int i = source.BEASector + 1, j = i; i <= source.TEASector; ++i, ++j)
                {
                    while (source.NSRSector.Contains(j))
                    {
                        ++j;
                    }
                    if (i != j)
                    {
                        if (i < source.TEASector)
                        {
                            Debug.WriteLine("Move sector " + j + " to " + i);
                            ReadSector(sector, 0, j);
                            WriteSector(sector, 0, i);
                        }
                        else
                        {
                            if (i == source.TEASector)
                            {
                                Array.Clear(sector, 0, sectorSize);
                            }
                            Debug.WriteLine("Clear sector " + source.TEASector);
                            WriteSector(sector, 0, i);
                        }
                    }
                }
            }
        }
示例#2
0
 public override void Dispose(bool disposing)
 {
     if (!final)
     {
         mFinalize();
     }
     if (source != null)
     {
         source.Dispose();
         source = null;
     }
     base.Dispose(disposing);
 }