예제 #1
0
        public int WritePathTable(BinaryWriter writer, bool isRoot, Endian endian, VolumeType type)
        {
            UInt32 extent = (type == VolumeType.Primary) ? Extent1 : Extent2;
            string name   = (type == VolumeType.Primary) ? ShortName : LongName;

            var pathTableRecord = new PathTableRecordWrapper(extent, Parent.Number, isRoot ? "." : name)
            {
                VolumeDescriptorType = type,
                Endian = endian
            };

            return(pathTableRecord.Write(writer));
        }
예제 #2
0
        public int WritePathTable(BinaryWriter writer, bool isRoot, Endian endian, VolumeType type)
        {
            PathTableRecordWrapper pathTableRecord;
            UInt32 extent = (type == VolumeType.Primary) ? this.Extent1 : this.Extent2;
            string name   = (type == VolumeType.Primary) ? this.ShortName : this.LongName;

            if (isRoot)
            {
                pathTableRecord = new PathTableRecordWrapper(extent, this.Parent.Number, ".");
            }
            else
            {
                pathTableRecord = new PathTableRecordWrapper(extent, this.Parent.Number, name);
            }
            pathTableRecord.VolumeDescriptorType = type;
            pathTableRecord.Endian = endian;

            return(pathTableRecord.Write(writer));
        }
예제 #3
0
        public void WriteDemoImage(BinaryWriter writer)
        {
            int currentSector;

            for (currentSector = 0; currentSector < 16; currentSector++)
            {
                IsoAlgorithm.WriteEmptySector(writer);
            }

            DirectoryRecordWrapper  rootDir          = new DirectoryRecordWrapper(19, IsoAlgorithm.SectorSize, DateTime.Now, true, ".");
            VolumeDescriptorWrapper volumeDescriptor = new VolumeDescriptorWrapper("EPURASU", 28, 26, 21, 22, rootDir, DateTime.Now, DateTime.Now.Subtract(TimeSpan.FromDays(2)), 8);

            //rootDir.SetDirectoryRecord( 19, ISO9660.SectorSize, DateTime.Now, true, "." );

            // [ Sect 16 ] Primary volume descriptor
            volumeDescriptor.VolumeDescriptorType = VolumeType.Primary;
            //			volumeDescriptor.SetVolumeDescriptor( "EPURASU", 28, 26, 21, 22, rootDir, DateTime.Now, DateTime.Now.Subtract( TimeSpan.FromDays( 2 ) ), 8 );

            volumeDescriptor.Write(writer);

            // [ Sect 17 ] Suplementary volume descriptor (in care scriem cu unicode)
            rootDir.SetDirectoryRecord(23, IsoAlgorithm.SectorSize, DateTime.Now, true, ".");
            volumeDescriptor.VolumeDescriptorType = VolumeType.Suplementary;
            volumeDescriptor.SetVolumeDescriptor("Epurasu", 28, 38, 25, 26, rootDir, DateTime.Now, DateTime.Now.Subtract(TimeSpan.FromDays(2)), 8);

            volumeDescriptor.Write(writer);

            // [ Sect 18 ] Volume descriptor set termnator
            volumeDescriptor.VolumeDescriptorType = VolumeType.SetTerminator;

            volumeDescriptor.Write(writer);


            // [ Sect 19 ] Continutul directorului radacina:
            // Directorul curent: "."
            rootDir.SetDirectoryRecord(19, IsoAlgorithm.SectorSize, DateTime.Now, true, ".");
            rootDir.Write(writer);

            // Directorul parinte: "..". Fiind vorba de radacina, directorul parinte e o referinta la directorul curent.
            rootDir.SetDirectoryRecord(19, IsoAlgorithm.SectorSize, DateTime.Now, true, "..");
            rootDir.Write(writer);

            // Director copil: "Director"
            DirectoryRecordWrapper childDir = new DirectoryRecordWrapper(20, IsoAlgorithm.SectorSize, DateTime.Now, true, "DIRECTOR");
            //childDir.SetDirectoryRecord( 20, ISO9660.SectorSize, DateTime.Now, true, "DIRECTOR" );
            int bytesWritten = childDir.Write(writer);

            writer.Write(new byte[2048 - 34 - 34 - bytesWritten]);

            // [ Sect 20 ] Continutul directorului "Director"
            childDir.SetDirectoryRecord(20, IsoAlgorithm.SectorSize, DateTime.Now, true, ".");
            childDir.Write(writer);
            childDir.SetDirectoryRecord(19, IsoAlgorithm.SectorSize, DateTime.Now, true, "..");
            childDir.Write(writer);
            childDir.SetDirectoryRecord(27, 45, DateTime.Now, false, "NUMELEFI.TXT");
            bytesWritten = childDir.Write(writer);

            writer.Write(new byte[2048 - 34 - 34 - bytesWritten]);

            // [ Sect 21 ] Pathtable pt little endian

            // Root:
            PathTableRecordWrapper record = new PathTableRecordWrapper();

            record.Endian = Endian.LittleEndian;
            record.SetPathTableRecord(19, 1, ".");
            bytesWritten = record.Write(writer);

            // "Director":
            record.SetPathTableRecord(20, 1, "DIRECTOR");
            bytesWritten += record.Write(writer);

            writer.Write(new byte[2048 - bytesWritten]);

            // [ Sect 22 ] Pathtable pt big endian

            // Root:
            record        = new PathTableRecordWrapper();
            record.Endian = Endian.BigEndian;
            record.SetPathTableRecord(19, 1, ".");
            record.Write(writer);

            // "Director":
            record.SetPathTableRecord(20, 1, "DIRECTOR");
            record.Write(writer);

            writer.Write(new byte[2048 - bytesWritten]);



            // [ Sect 23 ] Continutul directorului radacina:
            rootDir.VolumeDescriptorType = VolumeType.Suplementary;

            // Directorul curent: "."
            rootDir.SetDirectoryRecord(23, IsoAlgorithm.SectorSize, DateTime.Now, true, ".");
            rootDir.Write(writer);

            // Directorul parinte: "..". Fiind vorba de radacina, directorul parinte e o referinta la directorul curent.
            rootDir.SetDirectoryRecord(23, IsoAlgorithm.SectorSize, DateTime.Now, true, "..");
            rootDir.Write(writer);

            // Director copil: "Director"
            childDir = new DirectoryRecordWrapper(24, IsoAlgorithm.SectorSize, DateTime.Now, true, "Directorul");
            //childDir.SetDirectoryRecord( 24, ISO9660.SectorSize, DateTime.Now, true, "Directorul" );
            childDir.VolumeDescriptorType = VolumeType.Suplementary;
            bytesWritten = childDir.Write(writer);

            writer.Write(new byte[2048 - 34 - 34 - bytesWritten]);

            // [ Sect 24 ] Continutul directorului "Director"
            childDir.SetDirectoryRecord(24, IsoAlgorithm.SectorSize, DateTime.Now, true, ".");
            childDir.Write(writer);
            childDir.SetDirectoryRecord(23, IsoAlgorithm.SectorSize, DateTime.Now, true, "..");
            childDir.Write(writer);
            childDir.SetDirectoryRecord(27, 45, DateTime.Now, false, "numeleFisierului.txt");
            bytesWritten = childDir.Write(writer);

            writer.Write(new byte[2048 - 34 - 34 - bytesWritten]);

            // [ Sect 25 ] Pathtable pt little endian

            // Root:
            record        = new PathTableRecordWrapper();
            record.Endian = Endian.LittleEndian;
            record.VolumeDescriptorType = VolumeType.Suplementary;
            record.SetPathTableRecord(23, 1, ".");
            bytesWritten = record.Write(writer);

            // "Director":
            record.SetPathTableRecord(24, 1, "Directorul");
            bytesWritten += record.Write(writer);

            writer.Write(new byte[2048 - bytesWritten]);

            // [ Sect 26 ] Pathtable pt big endian

            // Root:
            record        = new PathTableRecordWrapper();
            record.Endian = Endian.BigEndian;
            record.VolumeDescriptorType = VolumeType.Suplementary;
            record.SetPathTableRecord(23, 1, ".");
            record.Write(writer);

            // "Director":
            record.SetPathTableRecord(24, 1, "Directorul");
            record.Write(writer);

            writer.Write(new byte[2048 - bytesWritten]);

            // [ Sect 27 ] Continutul fisierului (45 B):
            writer.Write(IsoAlgorithm.StringToByteArray("Catelus cu parul cretz fura ratza din cotetz."));
            writer.Write(new byte[2048 - 45]);
        }