Fix CD-i attributes reading.

This commit is contained in:
2019-07-31 23:02:43 +01:00
parent 2d71a7574d
commit 6ab2f51178
3 changed files with 38 additions and 28 deletions

View File

@@ -189,16 +189,17 @@ namespace DiscImageChef.Filesystems.ISO9660
continue; continue;
} }
entry.CdiSystemArea = int systemAreaStart = entryOff + record.name_len + CdiDirectoryRecordSize;
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(data,
entryOff + record.name_len +
CdiDirectoryRecordSize, CdiSystemAreaSize);
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory)) if(systemAreaStart % 2 != 0) systemAreaStart++;
entry.CdiSystemArea =
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(data, systemAreaStart, CdiSystemAreaSize);
if(((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.Directory))
entry.Flags |= FileFlags.Directory; entry.Flags |= FileFlags.Directory;
if(!entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory) || !usePathTable) if(!((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.Directory) ||
entries[entry.Filename] = entry; !usePathTable) entries[entry.Filename] = entry;
entryOff += record.length; entryOff += record.length;
} }
@@ -1021,12 +1022,14 @@ namespace DiscImageChef.Filesystems.ISO9660
if(record.flags.HasFlag(CdiFileFlags.Hidden)) entry.Flags |= FileFlags.Hidden; if(record.flags.HasFlag(CdiFileFlags.Hidden)) entry.Flags |= FileFlags.Hidden;
entry.CdiSystemArea = int systemAreaStart = record.name_len + CdiDirectoryRecordSize;
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(sector,
record.name_len + CdiDirectoryRecordSize,
CdiSystemAreaSize);
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory)) if(systemAreaStart % 2 != 0) systemAreaStart++;
entry.CdiSystemArea =
Marshal.ByteArrayToStructureBigEndian<CdiSystemArea>(sector, systemAreaStart, CdiSystemAreaSize);
if(((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.Directory))
entry.Flags |= FileFlags.Directory; entry.Flags |= FileFlags.Directory;
entries.Add(entry); entries.Add(entry);

View File

@@ -109,9 +109,10 @@ namespace DiscImageChef.Filesystems.ISO9660
if(entry.Extents.Count == 1) if(entry.Extents.Count == 1)
{ {
// No need to check mode, if we know it is CD-DA // No need to check mode, if we know it is CD-DA
byte[] buffer = entry.CdiSystemArea?.attributes.HasFlag(CdiAttributes.DigitalAudio) == true byte[] buffer =
? image.ReadSectors((ulong)(entry.Extents[0].extent + firstSector), entry.CdiSystemArea != null &&
(uint)sizeInSectors) ((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.DigitalAudio)
? image.ReadSectors((ulong)(entry.Extents[0].extent + firstSector), (uint)sizeInSectors)
: ReadSectors((ulong)(entry.Extents[0].extent + firstSector), (uint)sizeInSectors); : ReadSectors((ulong)(entry.Extents[0].extent + firstSector), (uint)sizeInSectors);
buf = new byte[size]; buf = new byte[size];
@@ -250,12 +251,18 @@ namespace DiscImageChef.Filesystems.ISO9660
{ {
stat.UID = entry.CdiSystemArea.Value.owner; stat.UID = entry.CdiSystemArea.Value.owner;
stat.GID = entry.CdiSystemArea.Value.group; stat.GID = entry.CdiSystemArea.Value.group;
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.GroupExecute)) stat.Mode |= 8; if(((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.GroupExecute))
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.GroupRead)) stat.Mode |= 32; stat.Mode |= 8;
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OtherExecute)) stat.Mode |= 1; if(((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.GroupRead))
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OtherRead)) stat.Mode |= 4; stat.Mode |= 32;
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerExecute)) stat.Mode |= 64; if(((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.OtherExecute))
if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerRead)) stat.Mode |= 256; stat.Mode |= 1;
if(((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.OtherRead))
stat.Mode |= 4;
if(((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.OwnerExecute))
stat.Mode |= 64;
if(((CdiAttributes)entry.CdiSystemArea.Value.attributes).HasFlag(CdiAttributes.OwnerRead))
stat.Mode |= 256;
} }
uint eaSizeInSectors = (uint)(entry.XattrLength / 2048); uint eaSizeInSectors = (uint)(entry.XattrLength / 2048);

View File

@@ -178,7 +178,7 @@ namespace DiscImageChef.Filesystems.ISO9660
{ {
public readonly ushort group; public readonly ushort group;
public readonly ushort owner; public readonly ushort owner;
public readonly CdiAttributes attributes; public readonly ushort attributes;
public readonly ushort reserved1; public readonly ushort reserved1;
public readonly byte file_no; public readonly byte file_no;
public readonly byte reserved2; public readonly byte reserved2;