|
@@ -0,0 +1,164 @@
|
|
|
+using System;
|
|
|
+using System.IO;
|
|
|
+using System.Text;
|
|
|
+
|
|
|
+namespace IsoFilePatcher.Iso9660
|
|
|
+{
|
|
|
+ internal class VolumeDescriptor
|
|
|
+ {
|
|
|
+ public static VolumeDescriptor Parse(Stream stream)
|
|
|
+ {
|
|
|
+ var obj = new VolumeDescriptor();
|
|
|
+ obj.Read(stream);
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Read(Stream stream)
|
|
|
+ {
|
|
|
+ var begin = stream.Position; // For DEBUGGING watch
|
|
|
+
|
|
|
+ using (var br = new BinaryReader(stream, Encoding.ASCII, true))
|
|
|
+ {
|
|
|
+ Type = br.ReadByte();
|
|
|
+ StandardIdentifier = br.ReadString(5);
|
|
|
+
|
|
|
+ Version = br.ReadByte();
|
|
|
+
|
|
|
+ switch (Type)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ SystemIdentifier = br.ReadString(32);
|
|
|
+ VolumeIdentifier = br.ReadString(32);
|
|
|
+ BootData = br.ReadBytes(1977);
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ //case 255:
|
|
|
+ stream.Position += Constants.SectorSize - 6;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ case 2:
|
|
|
+ Encoding = Encoding.ASCII;
|
|
|
+ if (Type == 2) Encoding = Encoding.BigEndianUnicode;
|
|
|
+
|
|
|
+ UnusedByte0007 = br.ReadByte();
|
|
|
+
|
|
|
+ SystemIdentifier = br.ReadString(32, Encoding);
|
|
|
+ VolumeIdentifier = br.ReadString(32, Encoding);
|
|
|
+
|
|
|
+ UnusedField0072 = br.ReadBytes(8);
|
|
|
+
|
|
|
+ VolumeSpaceSize = br.ReadUInt32LsbMsb();
|
|
|
+
|
|
|
+ UnusedField0088 = br.ReadBytes(32);
|
|
|
+
|
|
|
+ VolumeSetSize = br.ReadUInt16LsbMsb();
|
|
|
+ VolumeSequenceNumber = br.ReadUInt16LsbMsb();
|
|
|
+
|
|
|
+ LogicalBlockSize = br.ReadUInt16LsbMsb();
|
|
|
+ PathTableSize = br.ReadUInt32LsbMsb();
|
|
|
+
|
|
|
+ PathTableL = br.ReadUInt32();
|
|
|
+ PathTableLOptional = br.ReadUInt32();
|
|
|
+
|
|
|
+ PathTableM = br.ReadUInt32();
|
|
|
+ PathTableMOptional = br.ReadUInt32();
|
|
|
+
|
|
|
+ RootPathEntry = PathEntry.Parse(stream, this);
|
|
|
+
|
|
|
+ VolumeSetIdentifier = br.ReadString(128, Encoding);
|
|
|
+ PublisherIdentifier = br.ReadString(128, Encoding);
|
|
|
+ DataPreparerIdentifier = br.ReadString(128, Encoding);
|
|
|
+ ApplicationIdentifier = br.ReadString(128, Encoding);
|
|
|
+ CopyrightFileIdentifier = br.ReadString(38, Encoding);
|
|
|
+ AbstractFileIdentifier = br.ReadString(36, Encoding);
|
|
|
+ BibliographicFileIdentifier = br.ReadString(37, Encoding);
|
|
|
+
|
|
|
+ VolumeCreationDate = br.ReadDecDateTime();
|
|
|
+ VolumeModificationDate = br.ReadDecDateTime();
|
|
|
+ VolumeExpirationDate = br.ReadDecDateTime();
|
|
|
+ VolumeEffectiveDate = br.ReadDecDateTime();
|
|
|
+
|
|
|
+ FileStructureVersion = br.ReadByte();
|
|
|
+ UnusedByte0882 = br.ReadByte();
|
|
|
+
|
|
|
+ ApplicationUsed = br.ReadBytes(512);
|
|
|
+ Reserved = br.ReadBytes(653);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Encoding Encoding { get; set; }
|
|
|
+
|
|
|
+ public byte UnusedByte0882 { get; set; }
|
|
|
+
|
|
|
+ public byte[] BootData { get; set; }
|
|
|
+
|
|
|
+ public byte[] Reserved { get; set; }
|
|
|
+
|
|
|
+ public byte[] ApplicationUsed { get; set; }
|
|
|
+
|
|
|
+ public byte FileStructureVersion { get; set; }
|
|
|
+
|
|
|
+ public DateTime VolumeEffectiveDate { get; set; }
|
|
|
+
|
|
|
+ public DateTime VolumeExpirationDate { get; set; }
|
|
|
+
|
|
|
+ public DateTime VolumeModificationDate { get; set; }
|
|
|
+
|
|
|
+ public DateTime VolumeCreationDate { get; set; }
|
|
|
+
|
|
|
+ public string BibliographicFileIdentifier { get; set; }
|
|
|
+
|
|
|
+ public string AbstractFileIdentifier { get; set; }
|
|
|
+
|
|
|
+ public string CopyrightFileIdentifier { get; set; }
|
|
|
+
|
|
|
+ public string ApplicationIdentifier { get; set; }
|
|
|
+
|
|
|
+ public string DataPreparerIdentifier { get; set; }
|
|
|
+
|
|
|
+ public string PublisherIdentifier { get; set; }
|
|
|
+
|
|
|
+ public string VolumeSetIdentifier { get; set; }
|
|
|
+
|
|
|
+ public PathEntry RootPathEntry { get; set; }
|
|
|
+
|
|
|
+ public uint PathTableMOptional { get; set; }
|
|
|
+
|
|
|
+ public uint PathTableM { get; set; }
|
|
|
+
|
|
|
+ public uint PathTableLOptional { get; set; }
|
|
|
+
|
|
|
+ public uint PathTableL { get; set; }
|
|
|
+
|
|
|
+ public uint PathTableSize { get; set; }
|
|
|
+
|
|
|
+ public ushort LogicalBlockSize { get; set; }
|
|
|
+
|
|
|
+ public ushort VolumeSequenceNumber { get; set; }
|
|
|
+
|
|
|
+ public ushort VolumeSetSize { get; set; }
|
|
|
+
|
|
|
+ public byte[] UnusedField0088 { get; set; }
|
|
|
+
|
|
|
+ public uint VolumeSpaceSize { get; set; }
|
|
|
+
|
|
|
+ public byte[] UnusedField0072 { get; set; }
|
|
|
+
|
|
|
+ public string VolumeIdentifier { get; set; }
|
|
|
+
|
|
|
+ public string SystemIdentifier { get; set; }
|
|
|
+
|
|
|
+ public byte Version { get; set; }
|
|
|
+
|
|
|
+ public string StandardIdentifier { get; private set; }
|
|
|
+
|
|
|
+ public byte Type { get; private set; }
|
|
|
+
|
|
|
+ public bool IsVolumeDescriptorSetTerminator => Type == 0xff;
|
|
|
+ public byte UnusedByte0007 { get; set; }
|
|
|
+ }
|
|
|
+}
|