Fix TODOs and code cleanup.

This commit is contained in:
2019-07-31 19:53:47 +01:00
parent 62e14f275e
commit c51847b734
11 changed files with 143 additions and 150 deletions

View File

@@ -5,7 +5,7 @@ namespace DiscImageChef.Filesystems.ISO9660
{ {
public partial class ISO9660 public partial class ISO9660
{ {
DateTime? DecodeIsoDateTime(byte[] timestamp) static DateTime? DecodeIsoDateTime(byte[] timestamp)
{ {
switch(timestamp?.Length) switch(timestamp?.Length)
{ {
@@ -15,7 +15,7 @@ namespace DiscImageChef.Filesystems.ISO9660
} }
} }
DateTime? DecodeIsoDateTime(IsoTimestamp timestamp) static DateTime? DecodeIsoDateTime(IsoTimestamp timestamp)
{ {
try try
{ {
@@ -26,14 +26,14 @@ namespace DiscImageChef.Filesystems.ISO9660
return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT")); return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT"));
} }
catch(Exception e) catch(Exception)
{ {
// ISO says timestamp can be unspecified // ISO says timestamp can be unspecified
return null; return null;
} }
} }
DateTime? DecodeHighSierraDateTime(HighSierraTimestamp timestamp) static DateTime? DecodeHighSierraDateTime(HighSierraTimestamp timestamp)
{ {
try try
{ {
@@ -42,7 +42,7 @@ namespace DiscImageChef.Filesystems.ISO9660
return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT")); return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT"));
} }
catch(Exception e) catch(Exception)
{ {
// ISO says timestamp can be unspecified, suppose same for High Sierra // ISO says timestamp can be unspecified, suppose same for High Sierra
return null; return null;

View File

@@ -13,7 +13,6 @@ namespace DiscImageChef.Filesystems.ISO9660
{ {
Dictionary<string, Dictionary<string, DecodedDirectoryEntry>> directoryCache; Dictionary<string, Dictionary<string, DecodedDirectoryEntry>> directoryCache;
// TODO: Implement path table traversal
public Errno ReadDir(string path, out List<string> contents) public Errno ReadDir(string path, out List<string> contents)
{ {
contents = null; contents = null;
@@ -86,7 +85,6 @@ namespace DiscImageChef.Filesystems.ISO9660
directoryBuffer = ms.ToArray(); directoryBuffer = ms.ToArray();
} }
// TODO: Decode Joliet
currentDirectory = cdi currentDirectory = cdi
? DecodeCdiDirectory(directoryBuffer, entry.Value.XattrLength) ? DecodeCdiDirectory(directoryBuffer, entry.Value.XattrLength)
: highSierra : highSierra
@@ -132,10 +130,10 @@ namespace DiscImageChef.Filesystems.ISO9660
return contents; return contents;
} }
Dictionary<string, DecodedDirectoryEntry> DecodeCdiDirectory(byte[] data, byte XattrLength) Dictionary<string, DecodedDirectoryEntry> DecodeCdiDirectory(byte[] data, byte xattrLength)
{ {
Dictionary<string, DecodedDirectoryEntry> entries = new Dictionary<string, DecodedDirectoryEntry>(); Dictionary<string, DecodedDirectoryEntry> entries = new Dictionary<string, DecodedDirectoryEntry>();
int entryOff = XattrLength; int entryOff = xattrLength;
while(entryOff + CdiDirectoryRecordSize < data.Length) while(entryOff + CdiDirectoryRecordSize < data.Length)
{ {
@@ -190,10 +188,10 @@ namespace DiscImageChef.Filesystems.ISO9660
return entries; return entries;
} }
Dictionary<string, DecodedDirectoryEntry> DecodeHighSierraDirectory(byte[] data, byte XattrLength) Dictionary<string, DecodedDirectoryEntry> DecodeHighSierraDirectory(byte[] data, byte xattrLength)
{ {
Dictionary<string, DecodedDirectoryEntry> entries = new Dictionary<string, DecodedDirectoryEntry>(); Dictionary<string, DecodedDirectoryEntry> entries = new Dictionary<string, DecodedDirectoryEntry>();
int entryOff = XattrLength; int entryOff = xattrLength;
while(entryOff + DirectoryRecordSize < data.Length) while(entryOff + DirectoryRecordSize < data.Length)
{ {
@@ -240,10 +238,10 @@ namespace DiscImageChef.Filesystems.ISO9660
return entries; return entries;
} }
Dictionary<string, DecodedDirectoryEntry> DecodeIsoDirectory(byte[] data, byte XattrLength) Dictionary<string, DecodedDirectoryEntry> DecodeIsoDirectory(byte[] data, byte xattrLength)
{ {
Dictionary<string, DecodedDirectoryEntry> entries = new Dictionary<string, DecodedDirectoryEntry>(); Dictionary<string, DecodedDirectoryEntry> entries = new Dictionary<string, DecodedDirectoryEntry>();
int entryOff = XattrLength; int entryOff = xattrLength;
while(entryOff + DirectoryRecordSize < data.Length) while(entryOff + DirectoryRecordSize < data.Length)
{ {
@@ -298,7 +296,6 @@ namespace DiscImageChef.Filesystems.ISO9660
if(joliet && entry.Filename.EndsWith(";1", StringComparison.Ordinal)) if(joliet && entry.Filename.EndsWith(";1", StringComparison.Ordinal))
entry.Filename = entry.Filename.Substring(0, entry.Filename.Length - 2); entry.Filename = entry.Filename.Substring(0, entry.Filename.Length - 2);
// TODO: XA
int systemAreaStart = entryOff + record.name_len + DirectoryRecordSize; int systemAreaStart = entryOff + record.name_len + DirectoryRecordSize;
int systemAreaLength = record.length - record.name_len - DirectoryRecordSize; int systemAreaLength = record.length - record.name_len - DirectoryRecordSize;
@@ -748,7 +745,6 @@ namespace DiscImageChef.Filesystems.ISO9660
systemAreaOff += nmLength; systemAreaOff += nmLength;
break; break;
case RRIP_CHILDLINK: case RRIP_CHILDLINK:
// TODO
byte clLength = data[systemAreaOff + 2]; byte clLength = data[systemAreaOff + 2];
// If we are not in Rock Ridge namespace, or we are using the Path Table, skip it // If we are not in Rock Ridge namespace, or we are using the Path Table, skip it
@@ -926,7 +922,7 @@ namespace DiscImageChef.Filesystems.ISO9660
PathTableEntryInternal[] GetPathTableEntries(string path) PathTableEntryInternal[] GetPathTableEntries(string path)
{ {
IEnumerable<PathTableEntryInternal> tableEntries = new PathTableEntryInternal[0]; IEnumerable<PathTableEntryInternal> tableEntries;
List<PathTableEntryInternal> pathTableList = new List<PathTableEntryInternal>(pathTable); List<PathTableEntryInternal> pathTableList = new List<PathTableEntryInternal>(pathTable);
if(path == "" || path == "/") tableEntries = pathTable.Where(p => p.Parent == 1 && p != pathTable[0]); if(path == "" || path == "/") tableEntries = pathTable.Where(p => p.Parent == 1 && p != pathTable[0]);
@@ -1028,7 +1024,6 @@ namespace DiscImageChef.Filesystems.ISO9660
if(record.size != 0) entry.Extents = new List<(uint extent, uint size)> {(record.extent, record.size)}; if(record.size != 0) entry.Extents = new List<(uint extent, uint size)> {(record.extent, record.size)};
// TODO: XA
int systemAreaStart = record.name_len + DirectoryRecordSize; int systemAreaStart = record.name_len + DirectoryRecordSize;
int systemAreaLength = record.length - record.name_len - DirectoryRecordSize; int systemAreaLength = record.length - record.name_len - DirectoryRecordSize;

View File

@@ -69,7 +69,6 @@ namespace DiscImageChef.Filesystems.ISO9660
offset += entry.XattrLength; offset += entry.XattrLength;
// TODO: XA
long firstSector = offset / 2048; long firstSector = offset / 2048;
long offsetInSector = offset % 2048; long offsetInSector = offset % 2048;
long sizeInSectors = (size + offsetInSector) / 2048; long sizeInSectors = (size + offsetInSector) / 2048;
@@ -227,7 +226,6 @@ namespace DiscImageChef.Filesystems.ISO9660
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerRead)) stat.Mode |= 256; if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerRead)) stat.Mode |= 256;
} }
// TODO: XA
uint eaSizeInSectors = (uint)(entry.XattrLength / 2048); uint eaSizeInSectors = (uint)(entry.XattrLength / 2048);
if(entry.XattrLength % 2048 > 0) eaSizeInSectors++; if(entry.XattrLength % 2048 > 0) eaSizeInSectors++;
@@ -270,7 +268,7 @@ namespace DiscImageChef.Filesystems.ISO9660
{ {
entry = null; entry = null;
string cutPath = path.StartsWith("/") string cutPath = path.StartsWith("/", StringComparison.Ordinal)
? path.Substring(1).ToLower(CultureInfo.CurrentUICulture) ? path.Substring(1).ToLower(CultureInfo.CurrentUICulture)
: path.ToLower(CultureInfo.CurrentUICulture); : path.ToLower(CultureInfo.CurrentUICulture);
string[] pieces = cutPath.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries); string[] pieces = cutPath.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
@@ -296,7 +294,6 @@ namespace DiscImageChef.Filesystems.ISO9660
if(string.IsNullOrEmpty(dirent.Key)) if(string.IsNullOrEmpty(dirent.Key))
{ {
// TODO: RRIP
if(!joliet && !pieces[pieces.Length - 1].EndsWith(";1", StringComparison.Ordinal)) if(!joliet && !pieces[pieces.Length - 1].EndsWith(";1", StringComparison.Ordinal))
{ {
dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) ==

View File

@@ -106,12 +106,12 @@ namespace DiscImageChef.Filesystems.ISO9660
byte[] vdSector = imagePlugin.ReadSector(16 + counter + partition.Start); byte[] vdSector = imagePlugin.ReadSector(16 + counter + partition.Start);
int xaOff = vdSector.Length == 2336 ? 8 : 0; int xaOff = vdSector.Length == 2336 ? 8 : 0;
Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5);
bool highSierra = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; bool highSierraInfo = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC;
int hsOff = 0; int hsOff = 0;
if(highSierra) hsOff = 8; if(highSierraInfo) hsOff = 8;
bool cdi = false; bool cdiInfo = false;
bool evd = false; bool evd = false;
bool vpd = false; bool vpd = false;
while(true) while(true)
{ {
@@ -144,7 +144,7 @@ namespace DiscImageChef.Filesystems.ISO9660
break; break;
} }
cdi |= Encoding.GetString(vdMagic) == CDI_MAGIC; cdiInfo |= Encoding.GetString(vdMagic) == CDI_MAGIC;
switch(vdType) switch(vdType)
{ {
@@ -167,10 +167,10 @@ namespace DiscImageChef.Filesystems.ISO9660
case 1: case 1:
{ {
if(highSierra) if(highSierraInfo)
hsvd = Marshal hsvd = Marshal
.ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector); .ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector);
else if(cdi) else if(cdiInfo)
fsvd = Marshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector); fsvd = Marshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector);
else pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector); else pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector);
@@ -218,9 +218,9 @@ namespace DiscImageChef.Filesystems.ISO9660
return; return;
} }
if(highSierra) decodedVd = DecodeVolumeDescriptor(hsvd.Value); if(highSierraInfo) decodedVd = DecodeVolumeDescriptor(hsvd.Value);
else if(cdi) decodedVd = DecodeVolumeDescriptor(fsvd.Value); else if(cdiInfo) decodedVd = DecodeVolumeDescriptor(fsvd.Value);
else decodedVd = DecodeVolumeDescriptor(pvd.Value); else decodedVd = DecodeVolumeDescriptor(pvd.Value);
if(jolietvd != null) decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); if(jolietvd != null) decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value);
@@ -228,13 +228,13 @@ namespace DiscImageChef.Filesystems.ISO9660
uint rootSize = 0; uint rootSize = 0;
// No need to read root on CD-i, as extensions are not supported... // No need to read root on CD-i, as extensions are not supported...
if(!cdi) if(!cdiInfo)
{ {
rootLocation = highSierra rootLocation = highSierraInfo
? hsvd.Value.root_directory_record.extent ? hsvd.Value.root_directory_record.extent
: pvd.Value.root_directory_record.extent; : pvd.Value.root_directory_record.extent;
if(highSierra) if(highSierraInfo)
{ {
rootSize = hsvd.Value.root_directory_record.size / hsvd.Value.logical_block_size; rootSize = hsvd.Value.root_directory_record.size / hsvd.Value.logical_block_size;
if(hsvd.Value.root_directory_record.size % hsvd.Value.logical_block_size > 0) rootSize++; if(hsvd.Value.root_directory_record.size % hsvd.Value.logical_block_size > 0) rootSize++;
@@ -263,7 +263,7 @@ namespace DiscImageChef.Filesystems.ISO9660
rootDir = imagePlugin.ReadSectors(rootLocation, rootSize); rootDir = imagePlugin.ReadSectors(rootLocation, rootSize);
// Walk thru root directory to see system area extensions in use // Walk thru root directory to see system area extensions in use
while(rootOff + Marshal.SizeOf<DirectoryRecord>() < rootDir.Length && !cdi) while(rootOff + Marshal.SizeOf<DirectoryRecord>() < rootDir.Length && !cdiInfo)
{ {
DirectoryRecord record = DirectoryRecord record =
Marshal.ByteArrayToStructureLittleEndian<DirectoryRecord>(rootDir, rootOff, Marshal.ByteArrayToStructureLittleEndian<DirectoryRecord>(rootDir, rootOff,
@@ -397,9 +397,9 @@ namespace DiscImageChef.Filesystems.ISO9660
foreach(ContinuationArea ca in contareas) foreach(ContinuationArea ca in contareas)
{ {
uint caLen = (ca.ca_length_be + ca.offset_be) / uint caLen = (ca.ca_length_be + ca.offset_be) /
(highSierra ? hsvd.Value.logical_block_size : pvd.Value.logical_block_size); (highSierraInfo ? hsvd.Value.logical_block_size : pvd.Value.logical_block_size);
if((ca.ca_length_be + ca.offset_be) % if((ca.ca_length_be + ca.offset_be) %
(highSierra ? hsvd.Value.logical_block_size : pvd.Value.logical_block_size) > 0) caLen++; (highSierraInfo ? hsvd.Value.logical_block_size : pvd.Value.logical_block_size) > 0) caLen++;
byte[] caSectors = imagePlugin.ReadSectors(ca.block_be, caLen); byte[] caSectors = imagePlugin.ReadSectors(ca.block_be, caLen);
byte[] caData = new byte[ca.ca_length_be]; byte[] caData = new byte[ca.ca_length_be];
@@ -469,9 +469,9 @@ namespace DiscImageChef.Filesystems.ISO9660
Dreamcast.IPBin? dreamcast = Dreamcast.DecodeIPBin(ipbinSector); Dreamcast.IPBin? dreamcast = Dreamcast.DecodeIPBin(ipbinSector);
string fsFormat; string fsFormat;
if(highSierra) fsFormat = "High Sierra Format"; if(highSierraInfo) fsFormat = "High Sierra Format";
else if(cdi) fsFormat = "CD-i"; else if(cdiInfo) fsFormat = "CD-i";
else fsFormat = "ISO9660"; else fsFormat = "ISO9660";
isoMetadata.AppendFormat("{0} file system", fsFormat).AppendLine(); isoMetadata.AppendFormat("{0} file system", fsFormat).AppendLine();
if(xaExtensions) isoMetadata.AppendLine("CD-ROM XA extensions present."); if(xaExtensions) isoMetadata.AppendLine("CD-ROM XA extensions present.");
@@ -504,9 +504,12 @@ namespace DiscImageChef.Filesystems.ISO9660
isoMetadata.AppendLine(Dreamcast.Prettify(dreamcast)); isoMetadata.AppendLine(Dreamcast.Prettify(dreamcast));
} }
isoMetadata.AppendFormat("{0}------------------------------", cdi ? "---------------" : "").AppendLine(); isoMetadata.AppendFormat("{0}------------------------------", cdiInfo ? "---------------" : "")
isoMetadata.AppendFormat("{0}VOLUME DESCRIPTOR INFORMATION:", cdi ? "FILE STRUCTURE " : "").AppendLine(); .AppendLine();
isoMetadata.AppendFormat("{0}------------------------------", cdi ? "---------------" : "").AppendLine(); isoMetadata.AppendFormat("{0}VOLUME DESCRIPTOR INFORMATION:", cdiInfo ? "FILE STRUCTURE " : "")
.AppendLine();
isoMetadata.AppendFormat("{0}------------------------------", cdiInfo ? "---------------" : "")
.AppendLine();
isoMetadata.AppendFormat("System identifier: {0}", decodedVd.SystemIdentifier).AppendLine(); isoMetadata.AppendFormat("System identifier: {0}", decodedVd.SystemIdentifier).AppendLine();
isoMetadata.AppendFormat("Volume identifier: {0}", decodedVd.VolumeIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume identifier: {0}", decodedVd.VolumeIdentifier).AppendLine();
isoMetadata.AppendFormat("Volume set identifier: {0}", decodedVd.VolumeSetIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume set identifier: {0}", decodedVd.VolumeSetIdentifier).AppendLine();

View File

@@ -39,10 +39,10 @@ namespace DiscImageChef.Filesystems.ISO9660
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AmigaEntry struct AmigaEntry
{ {
public ushort signature; public readonly ushort signature;
public byte length; public readonly byte length;
public byte version; public readonly byte version;
public AmigaFlags flags; public readonly AmigaFlags flags;
// Followed by AmigaProtection if present // Followed by AmigaProtection if present
// Followed by length-prefixed string for comment if present // Followed by length-prefixed string for comment if present
} }
@@ -50,10 +50,10 @@ namespace DiscImageChef.Filesystems.ISO9660
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct AmigaProtection struct AmigaProtection
{ {
public byte User; public readonly byte User;
public byte Reserved; public readonly byte Reserved;
public AmigaMultiuser Multiuser; public readonly AmigaMultiuser Multiuser;
public AmigaAttributes Protection; public readonly AmigaAttributes Protection;
} }
} }
} }

View File

@@ -39,77 +39,77 @@ namespace DiscImageChef.Filesystems.ISO9660
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ElToritoBootRecord struct ElToritoBootRecord
{ {
public byte type; public readonly byte type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] id; public readonly byte[] id;
public byte version; public readonly byte version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] system_id; public readonly byte[] system_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] boot_id; public readonly byte[] boot_id;
public uint catalog_sector; public readonly uint catalog_sector;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1974)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1974)]
public byte[] boot_use; public readonly byte[] boot_use;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ElToritoValidationEntry struct ElToritoValidationEntry
{ {
public ElToritoIndicator header_id; public readonly ElToritoIndicator header_id;
public ElToritoPlatform platform_id; public readonly ElToritoPlatform platform_id;
public ushort reserved; public readonly ushort reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
public byte[] developer_id; public readonly byte[] developer_id;
public ushort checksum; public readonly ushort checksum;
public ushort signature; public readonly ushort signature;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ElToritoInitialEntry struct ElToritoInitialEntry
{ {
public ElToritoIndicator bootable; public readonly ElToritoIndicator bootable;
public ElToritoEmulation boot_type; public ElToritoEmulation boot_type;
public ushort load_seg; public readonly ushort load_seg;
public byte system_type; public readonly byte system_type;
public byte reserved1; public readonly byte reserved1;
public ushort sector_count; public readonly ushort sector_count;
public uint load_rba; public readonly uint load_rba;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public byte[] reserved2; public readonly byte[] reserved2;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ElToritoSectionHeaderEntry struct ElToritoSectionHeaderEntry
{ {
public ElToritoIndicator header_id; public readonly ElToritoIndicator header_id;
public ElToritoPlatform platform_id; public readonly ElToritoPlatform platform_id;
public ushort entries; public readonly ushort entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)]
public byte[] identifier; public readonly byte[] identifier;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ElToritoSectionEntry struct ElToritoSectionEntry
{ {
public ElToritoIndicator bootable; public readonly ElToritoIndicator bootable;
public ElToritoEmulation boot_type; public readonly ElToritoEmulation boot_type;
public ushort load_seg; public readonly ushort load_seg;
public byte system_type; public readonly byte system_type;
public byte reserved1; public readonly byte reserved1;
public ushort sector_count; public readonly ushort sector_count;
public uint load_rba; public readonly uint load_rba;
public byte selection_criteria_type; public readonly byte selection_criteria_type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 19)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 19)]
public byte[] selection_criterias; public readonly byte[] selection_criterias;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ElToritoSectionEntryExtension struct ElToritoSectionEntryExtension
{ {
public ElToritoIndicator extension_indicator; public readonly ElToritoIndicator extension_indicator;
public ElToritoFlags extension_flags; public readonly ElToritoFlags extension_flags;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
public byte[] selection_criterias; public readonly byte[] selection_criterias;
} }
} }
} }

View File

@@ -39,53 +39,53 @@ namespace DiscImageChef.Filesystems.ISO9660
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ContinuationArea struct ContinuationArea
{ {
public ushort signature; public readonly ushort signature;
public byte length; public readonly byte length;
public byte version; public readonly byte version;
public uint block; public readonly uint block;
public uint block_be; public readonly uint block_be;
public uint offset; public readonly uint offset;
public uint offset_be; public readonly uint offset_be;
public uint ca_length; public readonly uint ca_length;
public uint ca_length_be; public readonly uint ca_length_be;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct PaddingArea struct PaddingArea
{ {
public ushort signature; public readonly ushort signature;
public byte length; public readonly byte length;
public byte version; public readonly byte version;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct IndicatorArea struct IndicatorArea
{ {
public ushort signature; public readonly ushort signature;
public byte length; public readonly byte length;
public byte version; public readonly byte version;
public ushort magic; public readonly ushort magic;
public byte skipped; public readonly byte skipped;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct TerminatorArea struct TerminatorArea
{ {
public ushort signature; public readonly ushort signature;
public byte length; public readonly byte length;
public byte version; public readonly byte version;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ReferenceArea struct ReferenceArea
{ {
public ushort signature; public readonly ushort signature;
public byte length; public readonly byte length;
public byte version; public readonly byte version;
public byte id_len; public readonly byte id_len;
public byte des_len; public readonly byte des_len;
public byte src_len; public readonly byte src_len;
public byte ext_ver; public readonly byte ext_ver;
// Follows extension identifier for id_len bytes // Follows extension identifier for id_len bytes
// Follows extension descriptor for des_len bytes // Follows extension descriptor for des_len bytes
// Follows extension source for src_len bytes // Follows extension source for src_len bytes
@@ -94,10 +94,10 @@ namespace DiscImageChef.Filesystems.ISO9660
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct SelectorArea struct SelectorArea
{ {
public ushort signature; public readonly ushort signature;
public byte length; public readonly byte length;
public byte version; public readonly byte version;
public byte sequence; public readonly byte sequence;
} }
} }
} }

View File

@@ -40,13 +40,13 @@ namespace DiscImageChef.Filesystems.ISO9660
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct CdromXa struct CdromXa
{ {
public XaAttributes attributes; public readonly XaAttributes attributes;
public byte filenumber; public readonly byte filenumber;
public ushort group; public readonly ushort group;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] reserved; public readonly byte[] reserved;
public ushort signature; public readonly ushort signature;
public ushort user; public readonly ushort user;
} }
} }
} }

View File

@@ -39,24 +39,24 @@ namespace DiscImageChef.Filesystems.ISO9660
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ZisofsHeader struct ZisofsHeader
{ {
public ulong magic; public readonly ulong magic;
public uint uncomp_len; public readonly uint uncomp_len;
public uint uncomp_len_be; public readonly uint uncomp_len_be;
public byte header_size; // Shifted >> 2 public readonly byte header_size; // Shifted >> 2
public byte block_size_log; // log2(block_size) public readonly byte block_size_log; // log2(block_size)
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ZisofsEntry struct ZisofsEntry
{ {
public ushort signature; public readonly ushort signature;
public byte length; public readonly byte length;
public byte version; public readonly byte version;
public ushort alogirhtm; public readonly ushort alogirhtm;
public byte header_size; // Shifted >> 2 public readonly byte header_size; // Shifted >> 2
public byte block_size_log; // log2(block_size) public readonly byte block_size_log; // log2(block_size)
public uint uncomp_len; public readonly uint uncomp_len;
public uint uncomp_len_be; public readonly uint uncomp_len_be;
} }
} }
} }

View File

@@ -199,7 +199,7 @@ namespace DiscImageChef.Filesystems.ISO9660
string fsFormat; string fsFormat;
byte[] pathTableData; byte[] pathTableData;
uint pathTableSizeInSectors = 0; uint pathTableSizeInSectors;
uint pathTableMsbLocation; uint pathTableMsbLocation;
uint pathTableLsbLocation = 0; // Initialize to 0 as ignored in CD-i uint pathTableLsbLocation = 0; // Initialize to 0 as ignored in CD-i
@@ -253,8 +253,8 @@ namespace DiscImageChef.Filesystems.ISO9660
if(jolietvd is null && this.@namespace == Namespace.Joliet) this.@namespace = Namespace.Normal; if(jolietvd is null && this.@namespace == Namespace.Joliet) this.@namespace = Namespace.Normal;
uint rootLocation = 0; uint rootLocation;
uint rootSize = 0; uint rootSize;
byte rootXattrLength = 0; byte rootXattrLength = 0;
if(!cdi) if(!cdi)
@@ -341,11 +341,10 @@ namespace DiscImageChef.Filesystems.ISO9660
rootDirectoryCache.Add("$PATH_TABLE.LSB", rootDirectoryCache.Add("$PATH_TABLE.LSB",
new DecodedDirectoryEntry new DecodedDirectoryEntry
{ {
Extents = Extents = new List<(uint extent, uint size)>
new List<(uint extent, uint size)> {
{ (pathTableLsbLocation, (uint)pathTableData.Length)
(rootLocation, (uint)pathTableData.Length) },
},
Filename = "$PATH_TABLE.LSB", Filename = "$PATH_TABLE.LSB",
Size = (uint)pathTableData.Length, Size = (uint)pathTableData.Length,
Timestamp = decodedVd.CreationTime Timestamp = decodedVd.CreationTime
@@ -357,7 +356,7 @@ namespace DiscImageChef.Filesystems.ISO9660
Extents = Extents =
new List<(uint extent, uint size)> new List<(uint extent, uint size)>
{ {
(rootLocation, (uint)pathTableData.Length) (pathTableMsbLocation, (uint)pathTableData.Length)
}, },
Filename = "$PATH_TABLE.MSB", Filename = "$PATH_TABLE.MSB",
Size = (uint)pathTableData.Length, Size = (uint)pathTableData.Length,

View File

@@ -43,7 +43,6 @@ namespace DiscImageChef.Filesystems.ISO9660
if(entry.Extents is null) return Errno.InvalidArgument; if(entry.Extents is null) return Errno.InvalidArgument;
// TODO: XA
uint eaSizeInSectors = (uint)(entry.XattrLength / 2048); uint eaSizeInSectors = (uint)(entry.XattrLength / 2048);
if(entry.XattrLength % 2048 > 0) eaSizeInSectors++; if(entry.XattrLength % 2048 > 0) eaSizeInSectors++;