[ISO9660] Use new source generator based big endian marshaller

This commit is contained in:
2025-10-21 02:00:44 +01:00
parent 18679890c2
commit 7c1253a088
11 changed files with 395 additions and 366 deletions

View File

@@ -43,160 +43,6 @@ public sealed partial class ISO9660
{ {
Dictionary<string, Dictionary<string, DecodedDirectoryEntry>> _directoryCache; Dictionary<string, Dictionary<string, DecodedDirectoryEntry>> _directoryCache;
#region IReadOnlyFilesystem Members
/// <inheritdoc />
public ErrorNumber OpenDir(string path, out IDirNode node)
{
node = null;
if(!_mounted) return ErrorNumber.AccessDenied;
if(string.IsNullOrWhiteSpace(path) || path == "/")
{
node = new Iso9660DirNode
{
Path = path,
Position = 0,
Entries = _rootDirectoryCache.Values.ToArray()
};
return ErrorNumber.NoError;
}
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
? path[1..].ToLower(CultureInfo.CurrentUICulture)
: path.ToLower(CultureInfo.CurrentUICulture);
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, DecodedDirectoryEntry> currentDirectory))
{
node = new Iso9660DirNode
{
Path = path,
Position = 0,
Entries = currentDirectory.Values.ToArray()
};
return ErrorNumber.NoError;
}
string[] pieces = cutPath.Split(new[]
{
'/'
},
StringSplitOptions.RemoveEmptyEntries);
KeyValuePair<string, DecodedDirectoryEntry> entry =
_rootDirectoryCache.FirstOrDefault(t => t.Key.Equals(pieces[0], StringComparison.CurrentCultureIgnoreCase));
if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile;
if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) return ErrorNumber.NotDirectory;
string currentPath = pieces[0];
currentDirectory = _rootDirectoryCache;
for(var p = 0; p < pieces.Length; p++)
{
entry = currentDirectory.FirstOrDefault(t => t.Key.Equals(pieces[p],
StringComparison.CurrentCultureIgnoreCase));
if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile;
if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) return ErrorNumber.NotDirectory;
currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}";
if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue;
if(entry.Value.Extents.Count == 0) return ErrorNumber.InvalidArgument;
currentDirectory = _cdi
? DecodeCdiDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength,
entry.Value.Extents[0].size)
: _highSierra
? DecodeHighSierraDirectory(entry.Value.Extents[0].extent +
entry.Value.XattrLength,
entry.Value.Extents[0].size)
: DecodeIsoDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength,
entry.Value.Extents[0].size);
if(_usePathTable)
{
foreach(DecodedDirectoryEntry subDirectory in _cdi
? GetSubdirsFromCdiPathTable(currentPath)
: _highSierra
? GetSubdirsFromHighSierraPathTable(currentPath)
: GetSubdirsFromIsoPathTable(currentPath))
currentDirectory[subDirectory.Filename] = subDirectory;
}
_directoryCache.Add(currentPath, currentDirectory);
}
if(currentDirectory is null) return ErrorNumber.NoSuchFile;
node = new Iso9660DirNode
{
Path = path,
Position = 0,
Entries = currentDirectory.Values.ToArray()
};
return ErrorNumber.NoError;
}
/// <inheritdoc />
public ErrorNumber ReadDir(IDirNode node, out string filename)
{
filename = null;
if(!_mounted) return ErrorNumber.AccessDenied;
if(node is not Iso9660DirNode mynode) return ErrorNumber.InvalidArgument;
if(mynode.Position < 0) return ErrorNumber.InvalidArgument;
if(mynode.Position >= mynode.Entries.Length) return ErrorNumber.NoError;
switch(_namespace)
{
case Namespace.Normal:
filename = mynode.Entries[mynode.Position].Filename.EndsWith(";1", StringComparison.Ordinal)
? mynode.Entries[mynode.Position].Filename[..^2]
: mynode.Entries[mynode.Position].Filename;
break;
case Namespace.Vms:
case Namespace.Joliet:
case Namespace.Rrip:
case Namespace.Romeo:
filename = mynode.Entries[mynode.Position].Filename;
break;
default:
return ErrorNumber.InvalidArgument;
}
mynode.Position++;
return ErrorNumber.NoError;
}
/// <inheritdoc />
public ErrorNumber CloseDir(IDirNode node)
{
if(node is not Iso9660DirNode mynode) return ErrorNumber.InvalidArgument;
mynode.Position = -1;
mynode.Entries = null;
return ErrorNumber.NoError;
}
#endregion
Dictionary<string, DecodedDirectoryEntry> DecodeCdiDirectory(ulong start, uint size) Dictionary<string, DecodedDirectoryEntry> DecodeCdiDirectory(ulong start, uint size)
{ {
Dictionary<string, DecodedDirectoryEntry> entries = new(); Dictionary<string, DecodedDirectoryEntry> entries = new();
@@ -209,7 +55,9 @@ public sealed partial class ISO9660
while(entryOff + _cdiDirectoryRecordSize < data.Length) while(entryOff + _cdiDirectoryRecordSize < data.Length)
{ {
CdiDirectoryRecord record = CdiDirectoryRecord record =
Marshal.ByteArrayToStructureBigEndian<CdiDirectoryRecord>(data, entryOff, _cdiDirectoryRecordSize); Marshal.ByteArrayToStructureBigEndianGenerated<CdiDirectoryRecord>(data,
entryOff,
_cdiDirectoryRecordSize);
if(record.length == 0) if(record.length == 0)
{ {
@@ -259,7 +107,9 @@ public sealed partial class ISO9660
if(systemAreaStart % 2 != 0) systemAreaStart++; if(systemAreaStart % 2 != 0) systemAreaStart++;
entry.CdiSystemArea = entry.CdiSystemArea =
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(data, systemAreaStart, _cdiSystemAreaSize); Marshal.ByteArrayToStructureBigEndianGenerated<CdiSystemArea>(data,
systemAreaStart,
_cdiSystemAreaSize);
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory)) if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory))
entry.Flags |= FileFlags.Directory; entry.Flags |= FileFlags.Directory;
@@ -609,7 +459,7 @@ public sealed partial class ISO9660
break; break;
case AppleId.HFS: case AppleId.HFS:
AppleHFSSystemUse appleHfsSystemUse = AppleHFSSystemUse appleHfsSystemUse =
Marshal.ByteArrayToStructureBigEndian<AppleHFSSystemUse>(data, Marshal.ByteArrayToStructureBigEndianGenerated<AppleHFSSystemUse>(data,
systemAreaOff, systemAreaOff,
Marshal.SizeOf<AppleHFSSystemUse>()); Marshal.SizeOf<AppleHFSSystemUse>());
@@ -650,7 +500,7 @@ public sealed partial class ISO9660
case AppleOldId.TypeCreator: case AppleOldId.TypeCreator:
case AppleOldId.TypeCreatorBundle: case AppleOldId.TypeCreatorBundle:
AppleHFSTypeCreatorSystemUse appleHfsTypeCreatorSystemUse = AppleHFSTypeCreatorSystemUse appleHfsTypeCreatorSystemUse =
Marshal.ByteArrayToStructureBigEndian<AppleHFSTypeCreatorSystemUse>(data, Marshal.ByteArrayToStructureBigEndianGenerated<AppleHFSTypeCreatorSystemUse>(data,
systemAreaOff, systemAreaOff,
Marshal.SizeOf<AppleHFSTypeCreatorSystemUse>()); Marshal.SizeOf<AppleHFSTypeCreatorSystemUse>());
@@ -670,7 +520,7 @@ public sealed partial class ISO9660
case AppleOldId.TypeCreatorIcon: case AppleOldId.TypeCreatorIcon:
case AppleOldId.TypeCreatorIconBundle: case AppleOldId.TypeCreatorIconBundle:
AppleHFSIconSystemUse appleHfsIconSystemUse = AppleHFSIconSystemUse appleHfsIconSystemUse =
Marshal.ByteArrayToStructureBigEndian<AppleHFSIconSystemUse>(data, Marshal.ByteArrayToStructureBigEndianGenerated<AppleHFSIconSystemUse>(data,
systemAreaOff, systemAreaOff,
Marshal.SizeOf<AppleHFSIconSystemUse>()); Marshal.SizeOf<AppleHFSIconSystemUse>());
@@ -690,7 +540,7 @@ public sealed partial class ISO9660
break; break;
case AppleOldId.HFS: case AppleOldId.HFS:
AppleHFSOldSystemUse appleHfsSystemUse = AppleHFSOldSystemUse appleHfsSystemUse =
Marshal.ByteArrayToStructureBigEndian<AppleHFSOldSystemUse>(data, Marshal.ByteArrayToStructureBigEndianGenerated<AppleHFSOldSystemUse>(data,
systemAreaOff, systemAreaOff,
Marshal.SizeOf<AppleHFSOldSystemUse>()); Marshal.SizeOf<AppleHFSOldSystemUse>());
@@ -717,9 +567,9 @@ public sealed partial class ISO9660
break; break;
case XA_MAGIC: case XA_MAGIC:
entry.XA = Marshal.ByteArrayToStructureBigEndian<CdromXa>(data, entry.XA = Marshal.ByteArrayToStructureBigEndianGenerated<CdromXa>(data,
systemAreaOff, systemAreaOff,
Marshal.SizeOf<CdromXa>()); Marshal.SizeOf<CdromXa>());
systemAreaOff += Marshal.SizeOf<CdromXa>(); systemAreaOff += Marshal.SizeOf<CdromXa>();
@@ -729,16 +579,16 @@ public sealed partial class ISO9660
case AAIP_MAGIC: case AAIP_MAGIC:
case AMIGA_MAGIC: case AMIGA_MAGIC:
AmigaEntry amiga = AmigaEntry amiga =
Marshal.ByteArrayToStructureBigEndian<AmigaEntry>(data, Marshal.ByteArrayToStructureBigEndianGenerated<AmigaEntry>(data,
systemAreaOff, systemAreaOff,
Marshal.SizeOf<AmigaEntry>()); Marshal.SizeOf<AmigaEntry>());
var protectionLength = 0; var protectionLength = 0;
if(amiga.flags.HasFlag(AmigaFlags.Protection)) if(amiga.flags.HasFlag(AmigaFlags.Protection))
{ {
entry.AmigaProtection = entry.AmigaProtection =
Marshal.ByteArrayToStructureBigEndian<AmigaProtection>(data, Marshal.ByteArrayToStructureBigEndianGenerated<AmigaProtection>(data,
systemAreaOff + Marshal.SizeOf<AmigaEntry>(), systemAreaOff + Marshal.SizeOf<AmigaEntry>(),
Marshal.SizeOf<AmigaProtection>()); Marshal.SizeOf<AmigaProtection>());
@@ -1145,9 +995,9 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) continue; if(errno != ErrorNumber.NoError) continue;
CdiDirectoryRecord record = CdiDirectoryRecord record =
Marshal.ByteArrayToStructureBigEndian<CdiDirectoryRecord>(sector, Marshal.ByteArrayToStructureBigEndianGenerated<CdiDirectoryRecord>(sector,
tEntry.XattrLength, tEntry.XattrLength,
_cdiDirectoryRecordSize); _cdiDirectoryRecordSize);
if(record.length == 0) break; if(record.length == 0) break;
@@ -1170,7 +1020,9 @@ public sealed partial class ISO9660
if(systemAreaStart % 2 != 0) systemAreaStart++; if(systemAreaStart % 2 != 0) systemAreaStart++;
entry.CdiSystemArea = entry.CdiSystemArea =
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(sector, systemAreaStart, _cdiSystemAreaSize); Marshal.ByteArrayToStructureBigEndianGenerated<CdiSystemArea>(sector,
systemAreaStart,
_cdiSystemAreaSize);
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory)) if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory))
entry.Flags |= FileFlags.Directory; entry.Flags |= FileFlags.Directory;
@@ -1266,4 +1118,158 @@ public sealed partial class ISO9660
return entries.ToArray(); return entries.ToArray();
} }
#region IReadOnlyFilesystem Members
/// <inheritdoc />
public ErrorNumber OpenDir(string path, out IDirNode node)
{
node = null;
if(!_mounted) return ErrorNumber.AccessDenied;
if(string.IsNullOrWhiteSpace(path) || path == "/")
{
node = new Iso9660DirNode
{
Path = path,
Position = 0,
Entries = _rootDirectoryCache.Values.ToArray()
};
return ErrorNumber.NoError;
}
string cutPath = path.StartsWith("/", StringComparison.Ordinal)
? path[1..].ToLower(CultureInfo.CurrentUICulture)
: path.ToLower(CultureInfo.CurrentUICulture);
if(_directoryCache.TryGetValue(cutPath, out Dictionary<string, DecodedDirectoryEntry> currentDirectory))
{
node = new Iso9660DirNode
{
Path = path,
Position = 0,
Entries = currentDirectory.Values.ToArray()
};
return ErrorNumber.NoError;
}
string[] pieces = cutPath.Split(new[]
{
'/'
},
StringSplitOptions.RemoveEmptyEntries);
KeyValuePair<string, DecodedDirectoryEntry> entry =
_rootDirectoryCache.FirstOrDefault(t => t.Key.Equals(pieces[0], StringComparison.CurrentCultureIgnoreCase));
if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile;
if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) return ErrorNumber.NotDirectory;
string currentPath = pieces[0];
currentDirectory = _rootDirectoryCache;
for(var p = 0; p < pieces.Length; p++)
{
entry = currentDirectory.FirstOrDefault(t => t.Key.Equals(pieces[p],
StringComparison.CurrentCultureIgnoreCase));
if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile;
if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) return ErrorNumber.NotDirectory;
currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}";
if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue;
if(entry.Value.Extents.Count == 0) return ErrorNumber.InvalidArgument;
currentDirectory = _cdi
? DecodeCdiDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength,
entry.Value.Extents[0].size)
: _highSierra
? DecodeHighSierraDirectory(entry.Value.Extents[0].extent +
entry.Value.XattrLength,
entry.Value.Extents[0].size)
: DecodeIsoDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength,
entry.Value.Extents[0].size);
if(_usePathTable)
{
foreach(DecodedDirectoryEntry subDirectory in _cdi
? GetSubdirsFromCdiPathTable(currentPath)
: _highSierra
? GetSubdirsFromHighSierraPathTable(currentPath)
: GetSubdirsFromIsoPathTable(currentPath))
currentDirectory[subDirectory.Filename] = subDirectory;
}
_directoryCache.Add(currentPath, currentDirectory);
}
if(currentDirectory is null) return ErrorNumber.NoSuchFile;
node = new Iso9660DirNode
{
Path = path,
Position = 0,
Entries = currentDirectory.Values.ToArray()
};
return ErrorNumber.NoError;
}
/// <inheritdoc />
public ErrorNumber ReadDir(IDirNode node, out string filename)
{
filename = null;
if(!_mounted) return ErrorNumber.AccessDenied;
if(node is not Iso9660DirNode mynode) return ErrorNumber.InvalidArgument;
if(mynode.Position < 0) return ErrorNumber.InvalidArgument;
if(mynode.Position >= mynode.Entries.Length) return ErrorNumber.NoError;
switch(_namespace)
{
case Namespace.Normal:
filename = mynode.Entries[mynode.Position].Filename.EndsWith(";1", StringComparison.Ordinal)
? mynode.Entries[mynode.Position].Filename[..^2]
: mynode.Entries[mynode.Position].Filename;
break;
case Namespace.Vms:
case Namespace.Joliet:
case Namespace.Rrip:
case Namespace.Romeo:
filename = mynode.Entries[mynode.Position].Filename;
break;
default:
return ErrorNumber.InvalidArgument;
}
mynode.Position++;
return ErrorNumber.NoError;
}
/// <inheritdoc />
public ErrorNumber CloseDir(IDirNode node)
{
if(node is not Iso9660DirNode mynode) return ErrorNumber.InvalidArgument;
mynode.Position = -1;
mynode.Entries = null;
return ErrorNumber.NoError;
}
#endregion
} }

View File

@@ -59,13 +59,13 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) return false; if(errno != ErrorNumber.NoError) return false;
int xaOff = 0; var xaOff = 0;
if(vdSector.Length == 2336) xaOff = 8; if(vdSector.Length == 2336) xaOff = 8;
byte vdType = vdSector[0 + xaOff]; byte vdType = vdSector[0 + xaOff];
byte[] vdMagic = new byte[5]; var vdMagic = new byte[5];
byte[] hsMagic = new byte[5]; var hsMagic = new byte[5];
// This indicates the end of a volume descriptor. HighSierra here would have 16 so no problem // This indicates the end of a volume descriptor. HighSierra here would have 16 so no problem
if(vdType == 255) return false; if(vdType == 255) return false;
@@ -88,11 +88,11 @@ public sealed partial class ISO9660
encoding ??= Encoding.ASCII; encoding ??= Encoding.ASCII;
information = ""; information = "";
metadata = new FileSystem(); metadata = new FileSystem();
var isoMetadata = new StringBuilder(); var isoMetadata = new StringBuilder();
byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001" var vdMagic = new byte[5]; // Volume Descriptor magic "CD001"
byte[] hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" var hsMagic = new byte[5]; // Volume Descriptor magic "CDROM"
string bootSpec = ""; var bootSpec = "";
PrimaryVolumeDescriptor? pvd = null; PrimaryVolumeDescriptor? pvd = null;
PrimaryVolumeDescriptor? jolietvd = null; PrimaryVolumeDescriptor? jolietvd = null;
@@ -116,13 +116,13 @@ public sealed partial class ISO9660
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 highSierraInfo = encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; bool highSierraInfo = encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC;
int hsOff = 0; var hsOff = 0;
if(highSierraInfo) hsOff = 8; if(highSierraInfo) hsOff = 8;
bool cdiInfo = false; var cdiInfo = false;
bool evd = false; var evd = false;
bool vpd = false; var vpd = false;
while(true) while(true)
{ {
@@ -185,7 +185,7 @@ public sealed partial class ISO9660
if(highSierraInfo) if(highSierraInfo)
hsvd = Marshal.ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector); hsvd = Marshal.ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector);
else if(cdiInfo) else if(cdiInfo)
fsvd = Marshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector); fsvd = Marshal.ByteArrayToStructureBigEndianGenerated<FileStructureVolumeDescriptor>(vdSector);
else else
pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector); pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector);
@@ -276,14 +276,14 @@ public sealed partial class ISO9660
} }
byte[] rootDir = []; byte[] rootDir = [];
int rootOff = 0; var rootOff = 0;
bool xaExtensions = false; var xaExtensions = false;
bool apple = false; var apple = false;
bool susp = false; var susp = false;
bool rrip = false; var rrip = false;
bool ziso = false; var ziso = false;
bool amiga = false; var amiga = false;
bool aaip = false; var aaip = false;
List<ContinuationArea> contareas = []; List<ContinuationArea> contareas = [];
List<byte[]> refareas = []; List<byte[]> refareas = [];
var suspInformation = new StringBuilder(); var suspInformation = new StringBuilder();
@@ -309,17 +309,17 @@ public sealed partial class ISO9660
if(saLen > 0 && rootOff + saOff + saLen <= rootDir.Length) if(saLen > 0 && rootOff + saOff + saLen <= rootDir.Length)
{ {
byte[] sa = new byte[saLen]; var sa = new byte[saLen];
Array.Copy(rootDir, rootOff + saOff, sa, 0, saLen); Array.Copy(rootDir, rootOff + saOff, sa, 0, saLen);
saOff = 0; saOff = 0;
while(saOff < saLen) while(saOff < saLen)
{ {
bool noneFound = true; var noneFound = true;
if(Marshal.SizeOf<CdromXa>() + saOff <= saLen) if(Marshal.SizeOf<CdromXa>() + saOff <= saLen)
{ {
CdromXa xa = Marshal.ByteArrayToStructureBigEndian<CdromXa>(sa); CdromXa xa = Marshal.ByteArrayToStructureBigEndianGenerated<CdromXa>(sa);
if(xa.signature == XA_MAGIC) if(xa.signature == XA_MAGIC)
{ {
@@ -331,7 +331,7 @@ public sealed partial class ISO9660
if(saOff + 2 >= saLen) break; if(saOff + 2 >= saLen) break;
ushort nextSignature = BigEndianBitConverter.ToUInt16(sa, saOff); var nextSignature = BigEndianBitConverter.ToUInt16(sa, saOff);
switch(nextSignature) switch(nextSignature)
{ {
@@ -393,17 +393,17 @@ public sealed partial class ISO9660
break; break;
case SUSP_CONTINUATION when saOff + sa[saOff + 2] <= saLen: case SUSP_CONTINUATION when saOff + sa[saOff + 2] <= saLen:
byte[] ce = new byte[sa[saOff + 2]]; var ce = new byte[sa[saOff + 2]];
Array.Copy(sa, saOff, ce, 0, ce.Length); Array.Copy(sa, saOff, ce, 0, ce.Length);
ContinuationArea ca = ContinuationArea ca =
Marshal.ByteArrayToStructureBigEndian<ContinuationArea>(ce); Marshal.ByteArrayToStructureBigEndianGenerated<ContinuationArea>(ce);
contareas.Add(ca); contareas.Add(ca);
break; break;
case SUSP_REFERENCE when saOff + sa[saOff + 2] <= saLen: case SUSP_REFERENCE when saOff + sa[saOff + 2] <= saLen:
byte[] er = new byte[sa[saOff + 2]]; var er = new byte[sa[saOff + 2]];
Array.Copy(sa, saOff, er, 0, er.Length); Array.Copy(sa, saOff, er, 0, er.Length);
refareas.Add(er); refareas.Add(er);
@@ -458,13 +458,13 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) return; if(errno != ErrorNumber.NoError) return;
byte[] caData = new byte[ca.ca_length_be]; var caData = new byte[ca.ca_length_be];
Array.Copy(caSectors, ca.offset_be, caData, 0, ca.ca_length_be); Array.Copy(caSectors, ca.offset_be, caData, 0, ca.ca_length_be);
int caOff = 0; var caOff = 0;
while(caOff < ca.ca_length_be) while(caOff < ca.ca_length_be)
{ {
ushort nextSignature = BigEndianBitConverter.ToUInt16(caData, caOff); var nextSignature = BigEndianBitConverter.ToUInt16(caData, caOff);
switch(nextSignature) switch(nextSignature)
{ {
@@ -477,7 +477,7 @@ public sealed partial class ISO9660
break; break;
case SUSP_REFERENCE when caOff + caData[caOff + 2] <= ca.ca_length_be: case SUSP_REFERENCE when caOff + caData[caOff + 2] <= ca.ca_length_be:
byte[] er = new byte[caData[caOff + 2]]; var er = new byte[caData[caOff + 2]];
Array.Copy(caData, caOff, er, 0, er.Length); Array.Copy(caData, caOff, er, 0, er.Length);
refareas.Add(er); refareas.Add(er);
@@ -515,7 +515,7 @@ public sealed partial class ISO9660
foreach(byte[] erb in refareas) foreach(byte[] erb in refareas)
{ {
ReferenceArea er = Marshal.ByteArrayToStructureBigEndian<ReferenceArea>(erb); ReferenceArea er = Marshal.ByteArrayToStructureBigEndianGenerated<ReferenceArea>(erb);
string extId = encoding.GetString(erb, Marshal.SizeOf<ReferenceArea>(), er.id_len); string extId = encoding.GetString(erb, Marshal.SizeOf<ReferenceArea>(), er.id_len);
string extDes = encoding.GetString(erb, Marshal.SizeOf<ReferenceArea>() + er.id_len, er.des_len); string extDes = encoding.GetString(erb, Marshal.SizeOf<ReferenceArea>() + er.id_len, er.des_len);
@@ -684,7 +684,7 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) return; if(errno != ErrorNumber.NoError) return;
int toritoOff = 0; var toritoOff = 0;
if(vdSector[toritoOff] != 1) goto exit_torito; if(vdSector[toritoOff] != 1) goto exit_torito;
@@ -806,7 +806,7 @@ public sealed partial class ISO9660
isoMetadata.AppendFormat("\t" + Localization.Section_ID_0, encoding.GetString(sectionHeader.identifier)) isoMetadata.AppendFormat("\t" + Localization.Section_ID_0, encoding.GetString(sectionHeader.identifier))
.AppendLine(); .AppendLine();
for(int entryCounter = 1; for(var entryCounter = 1;
entryCounter <= sectionHeader.entries && toritoOff < vdSector.Length; entryCounter <= sectionHeader.entries && toritoOff < vdSector.Length;
entryCounter++) entryCounter++)
{ {

View File

@@ -43,7 +43,7 @@ public sealed partial class ISO9660
var off = 0; var off = 0;
PathTableEntry entry = PathTableEntry entry =
Marshal.ByteArrayToStructureBigEndian<PathTableEntry>(data, off, Marshal.SizeOf<PathTableEntry>()); Marshal.ByteArrayToStructureBigEndianGenerated<PathTableEntry>(data, off, Marshal.SizeOf<PathTableEntry>());
if(entry.name_len != 1 || if(entry.name_len != 1 ||
entry.parent_dirno != 1 || entry.parent_dirno != 1 ||
@@ -53,7 +53,9 @@ public sealed partial class ISO9660
while(off < data.Length) while(off < data.Length)
{ {
entry = Marshal.ByteArrayToStructureBigEndian<PathTableEntry>(data, off, Marshal.SizeOf<PathTableEntry>()); entry = Marshal.ByteArrayToStructureBigEndianGenerated<PathTableEntry>(data,
off,
Marshal.SizeOf<PathTableEntry>());
if(entry.name_len == 0) break; if(entry.name_len == 0) break;
@@ -88,11 +90,9 @@ public sealed partial class ISO9660
while(off < data.Length) while(off < data.Length)
{ {
HighSierraPathTableEntry entry = HighSierraPathTableEntry entry =
Marshal.ByteArrayToStructureBigEndian<HighSierraPathTableEntry>(data, Marshal.ByteArrayToStructureBigEndianGenerated<HighSierraPathTableEntry>(data,
off, off,
Marshal Marshal.SizeOf<HighSierraPathTableEntry>());
.SizeOf<
HighSierraPathTableEntry>());
if(entry.name_len == 0) break; if(entry.name_len == 0) break;

View File

@@ -28,6 +28,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
namespace Aaru.Filesystems; namespace Aaru.Filesystems;
@@ -36,12 +37,13 @@ public sealed partial class ISO9660
#region Nested type: AmigaEntry #region Nested type: AmigaEntry
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct AmigaEntry [SwapEndian]
partial struct AmigaEntry
{ {
public readonly ushort signature; public ushort signature;
public readonly byte length; public byte length;
public readonly byte version; public byte version;
public readonly AmigaFlags flags; public 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
@@ -52,12 +54,13 @@ public sealed partial class ISO9660
#region Nested type: AmigaProtection #region Nested type: AmigaProtection
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct AmigaProtection [SwapEndian]
partial struct AmigaProtection
{ {
public readonly byte User; public byte User;
public readonly byte Reserved; public byte Reserved;
public readonly AmigaMultiuser Multiuser; public AmigaMultiuser Multiuser;
public readonly AmigaAttributes Protection; public AmigaAttributes Protection;
} }
#endregion #endregion

View File

@@ -28,6 +28,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
namespace Aaru.Filesystems; namespace Aaru.Filesystems;
@@ -37,14 +38,15 @@ public sealed partial class ISO9660
// Big-endian // Big-endian
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct AppleHFSIconSystemUse [SwapEndian]
partial struct AppleHFSIconSystemUse
{ {
public readonly ushort signature; public ushort signature;
public readonly AppleOldId id; public AppleOldId id;
public readonly uint type; public uint type;
public readonly uint creator; public uint creator;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] icon; public byte[] icon;
} }
#endregion #endregion
@@ -53,13 +55,14 @@ public sealed partial class ISO9660
// Big-endian // Big-endian
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct AppleHFSOldSystemUse [SwapEndian]
partial struct AppleHFSOldSystemUse
{ {
public readonly ushort signature; public ushort signature;
public readonly AppleOldId id; public AppleOldId id;
public readonly uint type; public uint type;
public readonly uint creator; public uint creator;
public readonly ushort finder_flags; public ushort finder_flags;
} }
#endregion #endregion
@@ -68,14 +71,15 @@ public sealed partial class ISO9660
// Big-endian // Big-endian
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct AppleHFSSystemUse [SwapEndian]
partial struct AppleHFSSystemUse
{ {
public readonly ushort signature; public ushort signature;
public readonly byte length; public byte length;
public readonly AppleId id; public AppleId id;
public readonly uint type; public uint type;
public readonly uint creator; public uint creator;
public readonly AppleCommon.FinderFlags finder_flags; public AppleCommon.FinderFlags finder_flags;
} }
#endregion #endregion
@@ -84,12 +88,13 @@ public sealed partial class ISO9660
// Big-endian // Big-endian
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct AppleHFSTypeCreatorSystemUse [SwapEndian]
partial struct AppleHFSTypeCreatorSystemUse
{ {
public readonly ushort signature; public ushort signature;
public readonly AppleOldId id; public AppleOldId id;
public readonly uint type; public uint type;
public readonly uint creator; public uint creator;
} }
#endregion #endregion

View File

@@ -33,6 +33,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
using Aaru.Helpers; using Aaru.Helpers;
namespace Aaru.Filesystems; namespace Aaru.Filesystems;
@@ -89,21 +90,22 @@ public sealed partial class ISO9660
#region Nested type: CdiDirectoryRecord #region Nested type: CdiDirectoryRecord
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct CdiDirectoryRecord [SwapEndian]
partial struct CdiDirectoryRecord
{ {
public readonly byte length; public byte length;
public readonly byte xattr_len; public byte xattr_len;
public readonly uint reserved1; public uint reserved1;
public readonly uint start_lbn; public uint start_lbn;
public readonly uint reserved2; public uint reserved2;
public readonly uint size; public uint size;
public readonly HighSierraTimestamp date; public HighSierraTimestamp date;
public readonly byte reserved3; public byte reserved3;
public readonly CdiFileFlags flags; public CdiFileFlags flags;
public readonly ushort file_unit_size; public ushort file_unit_size;
public readonly ushort reserved4; public ushort reserved4;
public readonly ushort volume_sequence_number; public ushort volume_sequence_number;
public readonly byte name_len; public byte name_len;
// Followed by name[name_len] and then CdiSystemArea until length arrives // Followed by name[name_len] and then CdiSystemArea until length arrives
} }
@@ -114,14 +116,15 @@ public sealed partial class ISO9660
// Follows filename on directory record // Follows filename on directory record
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct CdiSystemArea [SwapEndian]
partial struct CdiSystemArea
{ {
public readonly ushort group; public ushort group;
public readonly ushort owner; public ushort owner;
public readonly CdiAttributes attributes; public CdiAttributes attributes;
public readonly ushort reserved1; public ushort reserved1;
public readonly byte file_no; public byte file_no;
public readonly byte reserved2; public byte reserved2;
} }
#endregion #endregion
@@ -129,74 +132,75 @@ public sealed partial class ISO9660
#region Nested type: FileStructureVolumeDescriptor #region Nested type: FileStructureVolumeDescriptor
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct FileStructureVolumeDescriptor [SwapEndian]
partial struct FileStructureVolumeDescriptor
{ {
public readonly byte type; public byte type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public readonly byte[] id; public byte[] id;
public readonly byte version; public byte version;
public readonly CdiVolumeFlags flags; public CdiVolumeFlags flags;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] system_id; public byte[] system_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] volume_id; public byte[] volume_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public readonly byte[] reserved1; public byte[] reserved1;
public readonly uint volume_space_size; public uint volume_space_size;
// Only used in SVDs // Only used in SVDs
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] escape_sequences; public byte[] escape_sequences;
public readonly ushort reserved2; public ushort reserved2;
public readonly ushort volume_set_size; public ushort volume_set_size;
public readonly ushort reserved3; public ushort reserved3;
public readonly ushort volume_sequence_number; public ushort volume_sequence_number;
public readonly ushort reserved4; public ushort reserved4;
public readonly ushort logical_block_size; public ushort logical_block_size;
public readonly uint reserved5; public uint reserved5;
public readonly uint path_table_size; public uint path_table_size;
public readonly ulong reserved6; public ulong reserved6;
public readonly uint path_table_addr; public uint path_table_addr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 38)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 38)]
public readonly byte[] reserved7; public byte[] reserved7;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] volume_set_id; public byte[] volume_set_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] publisher_id; public byte[] publisher_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] preparer_id; public byte[] preparer_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] application_id; public byte[] application_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] copyright_file_id; public byte[] copyright_file_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public readonly byte[] reserved8; public byte[] reserved8;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] abstract_file_id; public byte[] abstract_file_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public readonly byte[] reserved9; public byte[] reserved9;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] bibliographic_file_id; public byte[] bibliographic_file_id;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public readonly byte[] reserved10; public byte[] reserved10;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] creation_date; public byte[] creation_date;
public readonly byte reserved11; public byte reserved11;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] modification_date; public byte[] modification_date;
public readonly byte reserved12; public byte reserved12;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] expiration_date; public byte[] expiration_date;
public readonly byte reserved13; public byte reserved13;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] effective_date; public byte[] effective_date;
public readonly byte reserved14; public byte reserved14;
public readonly byte file_structure_version; public byte file_structure_version;
public readonly byte reserved15; public byte reserved15;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
public readonly byte[] application_data; public byte[] application_data;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 653)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 653)]
public readonly byte[] reserved16; public byte[] reserved16;
} }
#endregion #endregion

View File

@@ -30,6 +30,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Aaru.CommonTypes.Attributes;
using Aaru.Helpers; using Aaru.Helpers;
namespace Aaru.Filesystems; namespace Aaru.Filesystems;
@@ -112,12 +113,13 @@ public sealed partial class ISO9660
// There are two tables one in little endian one in big endian // There are two tables one in little endian one in big endian
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct HighSierraPathTableEntry [SwapEndian]
partial struct HighSierraPathTableEntry
{ {
public readonly uint start_lbn; public uint start_lbn;
public readonly byte xattr_len; public byte xattr_len;
public readonly byte name_len; public byte name_len;
public readonly ushort parent_dirno; public ushort parent_dirno;
// Followed by name[name_len] // Followed by name[name_len]
} }
@@ -198,14 +200,15 @@ public sealed partial class ISO9660
#region Nested type: HighSierraTimestamp #region Nested type: HighSierraTimestamp
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct HighSierraTimestamp [SwapEndian]
partial struct HighSierraTimestamp
{ {
public readonly byte Years; public byte Years;
public readonly byte Month; public byte Month;
public readonly byte Day; public byte Day;
public readonly byte Hour; public byte Hour;
public readonly byte Minute; public byte Minute;
public readonly byte Second; public byte Second;
} }
#endregion #endregion

View File

@@ -32,6 +32,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Aaru.CommonTypes.Attributes;
using Aaru.Helpers; using Aaru.Helpers;
namespace Aaru.Filesystems; namespace Aaru.Filesystems;
@@ -210,12 +211,13 @@ public sealed partial class ISO9660
// There are two tables one in little endian one in big endian // There are two tables one in little endian one in big endian
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct PathTableEntry [SwapEndian]
partial struct PathTableEntry
{ {
public readonly byte name_len; public byte name_len;
public readonly byte xattr_len; public byte xattr_len;
public readonly uint start_lbn; public uint start_lbn;
public readonly ushort parent_dirno; public ushort parent_dirno;
// Followed by name[name_len] // Followed by name[name_len]
} }

View File

@@ -30,6 +30,7 @@
// ReSharper disable UnusedType.Local // ReSharper disable UnusedType.Local
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
namespace Aaru.Filesystems; namespace Aaru.Filesystems;
@@ -38,17 +39,18 @@ public sealed partial class ISO9660
#region Nested type: ContinuationArea #region Nested type: ContinuationArea
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct ContinuationArea [SwapEndian]
partial struct ContinuationArea
{ {
public readonly ushort signature; public ushort signature;
public readonly byte length; public byte length;
public readonly byte version; public byte version;
public readonly uint block; public uint block;
public readonly uint block_be; public uint block_be;
public readonly uint offset; public uint offset;
public readonly uint offset_be; public uint offset_be;
public readonly uint ca_length; public uint ca_length;
public readonly uint ca_length_be; public uint ca_length_be;
} }
#endregion #endregion
@@ -82,15 +84,16 @@ public sealed partial class ISO9660
#region Nested type: ReferenceArea #region Nested type: ReferenceArea
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct ReferenceArea [SwapEndian]
partial struct ReferenceArea
{ {
public readonly ushort signature; public ushort signature;
public readonly byte length; public byte length;
public readonly byte version; public byte version;
public readonly byte id_len; public byte id_len;
public readonly byte des_len; public byte des_len;
public readonly byte src_len; public byte src_len;
public readonly byte ext_ver; public 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

View File

@@ -32,6 +32,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
namespace Aaru.Filesystems; namespace Aaru.Filesystems;
@@ -41,15 +42,16 @@ public sealed partial class ISO9660
// Big-endian // Big-endian
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct CdromXa [SwapEndian]
partial struct CdromXa
{ {
public readonly ushort group; public ushort group;
public readonly ushort user; public ushort user;
public readonly XaAttributes attributes; public XaAttributes attributes;
public readonly ushort signature; public ushort signature;
public readonly byte filenumber; public byte filenumber;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public readonly byte[] reserved; public byte[] reserved;
} }
#endregion #endregion

View File

@@ -55,8 +55,8 @@ public sealed partial class ISO9660
Dictionary<string, string> options, string @namespace) Dictionary<string, string> options, string @namespace)
{ {
_encoding = encoding ?? Encoding.GetEncoding(1252); _encoding = encoding ?? Encoding.GetEncoding(1252);
byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001" var vdMagic = new byte[5]; // Volume Descriptor magic "CD001"
byte[] hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" var hsMagic = new byte[5]; // Volume Descriptor magic "CDROM"
options ??= GetDefaultOptions(); options ??= GetDefaultOptions();
@@ -120,7 +120,7 @@ public sealed partial class ISO9660
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);
_highSierra = _encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; _highSierra = _encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC;
int hsOff = 0; var hsOff = 0;
if(_highSierra) hsOff = 8; if(_highSierra) hsOff = 8;
@@ -182,7 +182,7 @@ public sealed partial class ISO9660
if(_highSierra) if(_highSierra)
hsvd = Marshal.ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector); hsvd = Marshal.ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector);
else if(_cdi) else if(_cdi)
fsvd = Marshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector); fsvd = Marshal.ByteArrayToStructureBigEndianGenerated<FileStructureVolumeDescriptor>(vdSector);
else else
pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector); pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector);
@@ -360,7 +360,7 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) return errno; if(errno != ErrorNumber.NoError) return errno;
bool pvdWrongRoot = false; var pvdWrongRoot = false;
if(_highSierra) if(_highSierra)
{ {
@@ -382,7 +382,7 @@ public sealed partial class ISO9660
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.PVD_does_not_point_to_correct_root_directory_checking_path_table); Localization.PVD_does_not_point_to_correct_root_directory_checking_path_table);
bool pathTableWrongRoot = false; var pathTableWrongRoot = false;
rootLocation = _pathTable[0].Extent; rootLocation = _pathTable[0].Extent;
@@ -422,7 +422,8 @@ public sealed partial class ISO9660
if(errno != ErrorNumber.NoError) return errno; if(errno != ErrorNumber.NoError) return errno;
CdiDirectoryRecord rootEntry = Marshal.ByteArrayToStructureBigEndian<CdiDirectoryRecord>(firstRootSector); CdiDirectoryRecord rootEntry =
Marshal.ByteArrayToStructureBigEndianGenerated<CdiDirectoryRecord>(firstRootSector);
rootSize = rootEntry.size; rootSize = rootEntry.size;
@@ -619,7 +620,7 @@ public sealed partial class ISO9660
Timestamp = decodedVd.CreationTime Timestamp = decodedVd.CreationTime
}); });
for(int i = 0; i < bvdSectors.Count; i++) for(var i = 0; i < bvdSectors.Count; i++)
{ {
_rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}", _rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}",
new DecodedDirectoryEntry new DecodedDirectoryEntry
@@ -631,7 +632,7 @@ public sealed partial class ISO9660
}); });
} }
for(int i = 0; i < pvdSectors.Count; i++) for(var i = 0; i < pvdSectors.Count; i++)
{ {
_rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}", _rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}",
new DecodedDirectoryEntry new DecodedDirectoryEntry
@@ -643,7 +644,7 @@ public sealed partial class ISO9660
}); });
} }
for(int i = 0; i < svdSectors.Count; i++) for(var i = 0; i < svdSectors.Count; i++)
{ {
_rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}", _rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}",
new DecodedDirectoryEntry new DecodedDirectoryEntry
@@ -655,7 +656,7 @@ public sealed partial class ISO9660
}); });
} }
for(int i = 0; i < evdSectors.Count; i++) for(var i = 0; i < evdSectors.Count; i++)
{ {
_rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}", _rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}",
new DecodedDirectoryEntry new DecodedDirectoryEntry
@@ -667,7 +668,7 @@ public sealed partial class ISO9660
}); });
} }
for(int i = 0; i < vpdSectors.Count; i++) for(var i = 0; i < vpdSectors.Count; i++)
{ {
_rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}", _rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}",
new DecodedDirectoryEntry new DecodedDirectoryEntry
@@ -731,7 +732,7 @@ public sealed partial class ISO9660
Type = fsFormat Type = fsFormat
}; };
_directoryCache = new Dictionary<string, Dictionary<string, DecodedDirectoryEntry>>(); _directoryCache = [];
if(_usePathTable) if(_usePathTable)
{ {