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

View File

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

View File

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