private void SetVolumeDescriptor(byte[] systemId, byte[] volumeId, ulong volumeSpaceSize, ulong pathTableSize, uint typeLPathTable, uint typeMPathTable, DirectoryRecord rootDirRecord, AsciiDateRecord creationDate, AsciiDateRecord modificationDate, AsciiDateRecord expirationDate, AsciiDateRecord effectiveDate) { if (m_volumeDescriptor == null) { m_volumeDescriptor = new VolumeDescriptor(); } m_volumeDescriptor.VolumeDescType = (byte)m_volumeDescriptorType; systemId.CopyTo(m_volumeDescriptor.SystemId, 0); volumeId.CopyTo(m_volumeDescriptor.VolumeId, 0); m_volumeDescriptor.VolumeSpaceSize = volumeSpaceSize; m_volumeDescriptor.PathTableSize = pathTableSize; m_volumeDescriptor.TypeLPathTable = typeLPathTable; m_volumeDescriptor.TypeMPathTable = typeMPathTable; m_volumeDescriptor.RootDirRecord = rootDirRecord; m_rootDirRecord = new DirectoryRecordWrapper(rootDirRecord); m_volumeDescriptor.CreationDate = creationDate; m_creationDate = new DateWrapper(creationDate); m_volumeDescriptor.ModificationDate = modificationDate; m_modificationDate = new DateWrapper(modificationDate); m_volumeDescriptor.ExpirationDate = expirationDate; m_expirationDate = new DateWrapper(expirationDate); m_volumeDescriptor.EffectiveDate = effectiveDate; m_effectiveDate = new DateWrapper(effectiveDate); }
private void SetVolumeDescriptor(string systemId, string volumeId, uint volumeSpaceSize, uint pathTableSize, uint typeLPathTable, uint typeMPathTable, DirectoryRecordWrapper rootDir, DateTime creationDate, DateTime modificationDate, sbyte timeZone) { byte[] lSystemId; byte[] lVolumeId; if (VolumeDescriptorType == VolumeType.Primary) { lSystemId = IsoAlgorithm.StringToByteArray(systemId, IsoAlgorithm.SystemIdLength); lVolumeId = IsoAlgorithm.StringToByteArray(volumeId, IsoAlgorithm.VolumeIdLength); } else if (VolumeDescriptorType == VolumeType.Suplementary) { lSystemId = IsoAlgorithm.AsciiToUnicode(systemId, IsoAlgorithm.SystemIdLength); lVolumeId = IsoAlgorithm.AsciiToUnicode(volumeId, IsoAlgorithm.VolumeIdLength); } else { if (m_volumeDescriptor == null) { m_volumeDescriptor = new VolumeDescriptor(); } m_volumeDescriptor.VolumeDescType = (byte)m_volumeDescriptorType; return; } ulong lVolumeSpaceSize = IsoAlgorithm.BothEndian(volumeSpaceSize); ulong lPathTableSize = IsoAlgorithm.BothEndian(pathTableSize); // typeLPathTable remains unchanged, but typeMPathTable has to change byte order. uint lTypeMPathTable = IsoAlgorithm.ChangeEndian(typeMPathTable); DateWrapper lCreationDate = new DateWrapper(creationDate, timeZone); DateWrapper lModificationDate = new DateWrapper(modificationDate, timeZone); DateWrapper bufferDate = new DateWrapper(IsoAlgorithm.NoDate); SetVolumeDescriptor(lSystemId, lVolumeId, lVolumeSpaceSize, lPathTableSize, typeLPathTable, lTypeMPathTable, rootDir.Record, lCreationDate.AsciiDateRecord, lModificationDate.AsciiDateRecord, bufferDate.AsciiDateRecord, bufferDate.AsciiDateRecord); }
public VolumeDescriptorWrapper(string volumeName, uint volumeSpaceSize, uint pathTableSize, uint typeLPathTable, uint typeMPathTable, DirectoryRecordWrapper root, DateTime creationDate, DateTime modificationDate, sbyte timeZone) { SetVolumeDescriptor(volumeName, volumeSpaceSize, pathTableSize, typeLPathTable, typeMPathTable, root, creationDate, modificationDate, timeZone); }
public VolumeDescriptorWrapper(string volumeName, DirectoryRecordWrapper root, DateTime creationDate, DateTime modificationDate) { this.SetVolumeDescriptor(volumeName, 0, 0, 0, 0, root, creationDate, modificationDate, 8); }
public VolumeDescriptorWrapper( string volumeName, UInt32 volumeSpaceSize, UInt32 pathTableSize, UInt32 typeLPathTable, UInt32 typeMPathTable, DirectoryRecordWrapper root, DateTime creationDate, DateTime modificationDate, sbyte timeZone ) { this.SetVolumeDescriptor( volumeName, volumeSpaceSize, pathTableSize, typeLPathTable, typeMPathTable, root, creationDate, modificationDate, timeZone ); }
public void SetVolumeDescriptor(string volumeName, UInt32 volumeSpaceSize, UInt32 pathTableSize, UInt32 typeLPathTable, UInt32 typeMPathTable, DirectoryRecordWrapper root, DateTime creationDate, DateTime modificationDate, sbyte timeZone) { this.SetVolumeDescriptor(" ", volumeName, volumeSpaceSize, pathTableSize, typeLPathTable, typeMPathTable, root, creationDate, modificationDate, timeZone); }
public VolumeDescriptorWrapper( string volumeName, DirectoryRecordWrapper root, DateTime creationDate, DateTime modificationDate ) { this.SetVolumeDescriptor( volumeName, 0, 0, 0, 0, root, creationDate, modificationDate, 8 ); }
private void SetVolumeDescriptor( string systemId, string volumeId, UInt32 volumeSpaceSize, UInt32 pathTableSize, UInt32 typeLPathTable, UInt32 typeMPathTable, DirectoryRecordWrapper rootDir, DateTime creationDate, DateTime modificationDate, sbyte timeZone ) { byte[] lSystemId; byte[] lVolumeId; if ( VolumeDescriptorType == VolumeType.Primary ) { lSystemId = IsoAlgorithm.StringToByteArray( systemId, IsoAlgorithm.SystemIdLength ); lVolumeId = IsoAlgorithm.StringToByteArray( volumeId, IsoAlgorithm.VolumeIdLength ); } else if ( VolumeDescriptorType == VolumeType.Suplementary ) { lSystemId = IsoAlgorithm.AsciiToUnicode( systemId, IsoAlgorithm.SystemIdLength ); lVolumeId = IsoAlgorithm.AsciiToUnicode( volumeId, IsoAlgorithm.VolumeIdLength ); } else { if ( m_volumeDescriptor == null ) { m_volumeDescriptor = new VolumeDescriptor(); } m_volumeDescriptor.VolumeDescType = (byte)m_volumeDescriptorType; return; } UInt64 lVolumeSpaceSize = IsoAlgorithm.BothEndian( volumeSpaceSize ); UInt64 lPathTableSize = IsoAlgorithm.BothEndian( pathTableSize ); // typeLPathTable remains unchanged, but typeMPathTable has to change byte order. UInt32 lTypeMPathTable = IsoAlgorithm.ChangeEndian( typeMPathTable ); DateWrapper lCreationDate = new DateWrapper( creationDate, timeZone ); DateWrapper lModificationDate = new DateWrapper( modificationDate, timeZone ); DateWrapper bufferDate = new DateWrapper( IsoAlgorithm.NoDate ); this.SetVolumeDescriptor( lSystemId, lVolumeId, lVolumeSpaceSize, lPathTableSize, typeLPathTable, lTypeMPathTable, rootDir.Record, lCreationDate.AsciiDateRecord, lModificationDate.AsciiDateRecord, bufferDate.AsciiDateRecord, bufferDate.AsciiDateRecord ); }
private void SetVolumeDescriptor( byte[] systemId, byte[] volumeId, UInt64 volumeSpaceSize, UInt64 pathTableSize, UInt32 typeLPathTable, UInt32 typeMPathTable, DirectoryRecord rootDirRecord, AsciiDateRecord creationDate, AsciiDateRecord modificationDate, AsciiDateRecord expirationDate, AsciiDateRecord effectiveDate ) { if ( m_volumeDescriptor == null ) { m_volumeDescriptor = new VolumeDescriptor(); } m_volumeDescriptor.VolumeDescType = (byte)m_volumeDescriptorType; systemId.CopyTo( m_volumeDescriptor.SystemId, 0 ); volumeId.CopyTo( m_volumeDescriptor.VolumeId, 0 ); m_volumeDescriptor.VolumeSpaceSize = volumeSpaceSize; m_volumeDescriptor.PathTableSize = pathTableSize; m_volumeDescriptor.TypeLPathTable = typeLPathTable; m_volumeDescriptor.TypeMPathTable = typeMPathTable; m_volumeDescriptor.RootDirRecord = rootDirRecord; m_rootDirRecord = new DirectoryRecordWrapper( rootDirRecord ); m_volumeDescriptor.CreationDate = creationDate; m_creationDate = new DateWrapper( creationDate ); m_volumeDescriptor.ModificationDate = modificationDate; m_modificationDate = new DateWrapper( modificationDate ); m_volumeDescriptor.ExpirationDate = expirationDate; m_expirationDate = new DateWrapper( expirationDate ); m_volumeDescriptor.EffectiveDate = effectiveDate; m_effectiveDate = new DateWrapper( effectiveDate ); }
/// <summary> /// Writes three volume descriptors speciffic to the ISO 9660 Joliet: /// 1. Primary volume descriptor; /// 2. Suplementary volume descriptor; /// 3. Volume descriptor set terminator. /// </summary> /// <param name="writer">A binary writer to write the data.</param> /// <param name="volumeName">A normal string representing the desired name of the volume. /// (the maximum standard length for this string is 16 for Joliet, so if the name is larger /// than 16 characters, it is truncated.)</param> /// <param name="root">The root IsoDirectory, representing the root directory for the volume.</param> /// <param name="volumeSpaceSize">The ISO total space size IN SECTORS. /// (For example, if the ISO space size is 1,427,456 bytes, then the volumeSpaceSize will be 697)</param> /// <param name="pathTableSize1">The first path table size (for the primary volume) IN BYTES.</param> /// <param name="pathTableSize2">The second path table size (for the suplementary volume) IN BYTES.</param> /// <param name="typeLPathTable1">The location (sector) of the first LITTLE ENDIAN path table.</param> /// <param name="typeMPathTable1">The location (sector) of the first BIG ENDIAN path table.</param> /// <param name="typeLPathTable2">The location (sector) of the second LITTLE ENDIAN path table.</param> /// <param name="typeMPathTable2">The location (sector) of the second BIG ENDIAN path table.</param> private void WriteVolumeDescriptors( BinaryWriter writer, string volumeName, IsoDirectory root, UInt32 volumeSpaceSize, UInt32 pathTableSize1, UInt32 pathTableSize2, UInt32 typeLPathTable1, UInt32 typeMPathTable1, UInt32 typeLPathTable2, UInt32 typeMPathTable2 ) { // Throughout this program I have respected the convention of refering to the root as "."; // However, one should not confuse the root with the current directory, also known as "." (along with the parent directory, ".."). // Primary Volume Descriptor: // Create a Directory Record of the root and the volume descriptor. DirectoryRecordWrapper rootRecord = new DirectoryRecordWrapper( root.Extent1, root.Size1, root.Date, root.IsDirectory, "." ); VolumeDescriptorWrapper volumeDescriptor = new VolumeDescriptorWrapper( volumeName, volumeSpaceSize, pathTableSize1, typeLPathTable1, typeMPathTable1, rootRecord, DateTime.Now, DateTime.Now, 8 ); volumeDescriptor.VolumeDescriptorType = VolumeType.Primary; volumeDescriptor.Write( writer ); // Suplementary volume descriptor: rootRecord = new DirectoryRecordWrapper( root.Extent2, root.Size2, root.Date, root.IsDirectory, "." ); volumeDescriptor = new VolumeDescriptorWrapper( volumeName, volumeSpaceSize, pathTableSize2, typeLPathTable2, typeMPathTable2, rootRecord, DateTime.Now, DateTime.Now, 8 ); volumeDescriptor.VolumeDescriptorType = VolumeType.Suplementary; volumeDescriptor.Write( writer ); // Volume descriptor set terminator: volumeDescriptor.VolumeDescriptorType = VolumeType.SetTerminator; volumeDescriptor.Write( writer ); }
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] ); }