Пример #1
0
        /// <summary>
        /// writes a file out to cd. Generate the Boot Info Table if necessary
        /// </summary>
        /// <param Name="f">the file to write</param>
        /// <param Name="primaryVolumeDescriptor">the PVD block, passed in case we need to generate the Boot Info Table</param>
        public void WriteFile(IsoFile f, int primaryVolumeDescriptor)
        {
            if (f.fileInfo.Length > 0xffffffff)
            {
                throw new NotImplementedException(">4G files not implemented");
            }

            int bytes = (int)f.fileInfo.Length;

            if (this.fs == null)
            {
                this.Index += bytes;
                return;
            }

            // TODO FIXME - create smaller reusable buffer and read fixed-size chunks at a time...
            byte[] b = new byte[bytes];

            using (FileStream stream = f.fileInfo.OpenRead()) {
                if (bytes != stream.Read(b, 0, bytes))
                {
                    throw new Exception("number of bytes read from file != reported length of file: " + f.fileInfo.Name);
                }
            }

            if (f.BootInfoTable)
            {
                // TODO FIXME - this is TERRIBLE. This should be implemented at a higher level, and
                // doing it here requires passing the primaryVolumeDescriptor to every call of WriteFile()
                // The reason it is here is because this is the only place where the file actually gets
                // pulled into memory and I didn't want to modify the boot image on-disk like mkisofs does.
                Bytes(b, 0, 8);
                Bytes(ConvertTo.Int2LSB(primaryVolumeDescriptor));
                Bytes(ConvertTo.Int2LSB(f.DataBlock));
                Bytes(ConvertTo.Int2LSB((int)f.fileInfo.Length));
                Bytes(ConvertTo.Int2LSB(0));    // TODO FIXME - checksum
                DupByte(0, 40);                 // reserved
                Bytes(b, 64, bytes - 64);
            }
            else
            {
                Bytes(b);
            }
        }
Пример #2
0
 public void ShortMSB(short i, int start, int end)
 {
     BeginField(start);
     this.generator.Bytes(ConvertTo.Short2MSB(i));
     EndField(end);
 }
Пример #3
0
 public void IntLSB(int i, int start, int end)
 {
     BeginField(start);
     this.generator.Bytes(ConvertTo.Int2LSB(i));
     EndField(end);
 }