mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move common data structures for MFS, HFS and ISO9660 (Apple Extensions) to common class.
This commit is contained in:
@@ -518,8 +518,9 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
{
|
||||
int systemAreaOff = start;
|
||||
hasResourceFork = false;
|
||||
bool continueSymlink = false;
|
||||
bool continueSymlinkComponent = false;
|
||||
bool continueSymlink = false;
|
||||
bool continueSymlinkComponent = false;
|
||||
AppleCommon.FInfo fInfo;
|
||||
|
||||
while(systemAreaOff + 2 <= end)
|
||||
{
|
||||
@@ -563,10 +564,11 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
hasResourceFork = true;
|
||||
|
||||
entry.FinderInfo = new FinderInfo();
|
||||
entry.FinderInfo.fdCreator = appleHfsSystemUse.creator;
|
||||
entry.FinderInfo.fdFlags = (FinderFlags)appleHfsSystemUse.finder_flags;
|
||||
entry.FinderInfo.fdType = appleHfsSystemUse.type;
|
||||
fInfo = new AppleCommon.FInfo();
|
||||
fInfo.fdCreator = appleHfsSystemUse.creator;
|
||||
fInfo.fdFlags = appleHfsSystemUse.finder_flags;
|
||||
fInfo.fdType = appleHfsSystemUse.type;
|
||||
entry.FinderInfo = fInfo;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -606,9 +608,10 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
hasResourceFork = true;
|
||||
|
||||
entry.FinderInfo = new FinderInfo();
|
||||
entry.FinderInfo.fdCreator = appleHfsTypeCreatorSystemUse.creator;
|
||||
entry.FinderInfo.fdType = appleHfsTypeCreatorSystemUse.type;
|
||||
fInfo = new AppleCommon.FInfo();
|
||||
fInfo.fdCreator = appleHfsTypeCreatorSystemUse.creator;
|
||||
fInfo.fdType = appleHfsTypeCreatorSystemUse.type;
|
||||
entry.FinderInfo = fInfo;
|
||||
|
||||
systemAreaOff += Marshal.SizeOf<AppleHFSTypeCreatorSystemUse>();
|
||||
|
||||
@@ -624,10 +627,11 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
hasResourceFork = true;
|
||||
|
||||
entry.FinderInfo = new FinderInfo();
|
||||
entry.FinderInfo.fdCreator = appleHfsIconSystemUse.creator;
|
||||
entry.FinderInfo.fdType = appleHfsIconSystemUse.type;
|
||||
entry.AppleIcon = appleHfsIconSystemUse.icon;
|
||||
fInfo = new AppleCommon.FInfo();
|
||||
fInfo.fdCreator = appleHfsIconSystemUse.creator;
|
||||
fInfo.fdType = appleHfsIconSystemUse.type;
|
||||
entry.FinderInfo = fInfo;
|
||||
entry.AppleIcon = appleHfsIconSystemUse.icon;
|
||||
|
||||
systemAreaOff += Marshal.SizeOf<AppleHFSIconSystemUse>();
|
||||
|
||||
@@ -642,10 +646,11 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
hasResourceFork = true;
|
||||
|
||||
entry.FinderInfo = new FinderInfo();
|
||||
entry.FinderInfo.fdCreator = appleHfsSystemUse.creator;
|
||||
entry.FinderInfo.fdFlags = (FinderFlags)appleHfsSystemUse.finder_flags;
|
||||
entry.FinderInfo.fdType = appleHfsSystemUse.type;
|
||||
fInfo = new AppleCommon.FInfo();
|
||||
fInfo.fdCreator = appleHfsSystemUse.creator;
|
||||
fInfo.fdFlags = (AppleCommon.FinderFlags)appleHfsSystemUse.finder_flags;
|
||||
fInfo.fdType = appleHfsSystemUse.type;
|
||||
entry.FinderInfo = fInfo;
|
||||
|
||||
systemAreaOff += Marshal.SizeOf<AppleHFSOldSystemUse>();
|
||||
|
||||
|
||||
@@ -177,31 +177,33 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
if(entry.FinderInfo != null)
|
||||
{
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kIsAlias))
|
||||
AppleCommon.FInfo finderInfo = entry.FinderInfo.Value;
|
||||
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsAlias))
|
||||
stat.Attributes |= FileAttributes.Alias;
|
||||
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kIsInvisible))
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsInvisible))
|
||||
stat.Attributes |= FileAttributes.Hidden;
|
||||
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kHasBeenInited))
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasBeenInited))
|
||||
stat.Attributes |= FileAttributes.HasBeenInited;
|
||||
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kHasCustomIcon))
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasCustomIcon))
|
||||
stat.Attributes |= FileAttributes.HasCustomIcon;
|
||||
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kHasNoINITs))
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasNoINITs))
|
||||
stat.Attributes |= FileAttributes.HasNoINITs;
|
||||
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kIsOnDesk))
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsOnDesk))
|
||||
stat.Attributes |= FileAttributes.IsOnDesk;
|
||||
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kIsShared))
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsShared))
|
||||
stat.Attributes |= FileAttributes.Shared;
|
||||
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kIsStationery))
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsStationery))
|
||||
stat.Attributes |= FileAttributes.Stationery;
|
||||
|
||||
if(entry.FinderInfo.fdFlags.HasFlag(FinderFlags.kHasBundle))
|
||||
if(finderInfo.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasBundle))
|
||||
stat.Attributes |= FileAttributes.Bundle;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct AppleHFSSystemUse
|
||||
{
|
||||
public readonly ushort signature;
|
||||
public readonly byte length;
|
||||
public readonly AppleId id;
|
||||
public readonly uint type;
|
||||
public readonly uint creator;
|
||||
public readonly FinderFlags finder_flags;
|
||||
public readonly ushort signature;
|
||||
public readonly byte length;
|
||||
public readonly AppleId id;
|
||||
public readonly uint type;
|
||||
public readonly uint creator;
|
||||
public readonly AppleCommon.FinderFlags finder_flags;
|
||||
}
|
||||
|
||||
// Little-endian
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
public List<(uint extent, uint size)> Extents;
|
||||
public string Filename;
|
||||
public byte FileUnitSize;
|
||||
public FinderInfo FinderInfo;
|
||||
public AppleCommon.FInfo? FinderInfo;
|
||||
public FileFlags Flags;
|
||||
public byte Interleave;
|
||||
public PosixAttributes? PosixAttributes;
|
||||
@@ -95,40 +95,6 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
public override string ToString() => Filename;
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum FinderFlags : ushort
|
||||
{
|
||||
kIsOnDesk = 0x0001,
|
||||
kColor = 0x000E,
|
||||
kRequireSwitchLaunch = 0x0020,
|
||||
kIsShared = 0x0040,
|
||||
kHasNoINITs = 0x0080,
|
||||
kHasBeenInited = 0x0100,
|
||||
kHasCustomIcon = 0x0400,
|
||||
kLetter = 0x0200,
|
||||
kChanged = 0x0200,
|
||||
kIsStationery = 0x0800,
|
||||
kNameLocked = 0x1000,
|
||||
kHasBundle = 0x2000,
|
||||
kIsInvisible = 0x4000,
|
||||
kIsAlias = 0x8000
|
||||
}
|
||||
|
||||
struct Point
|
||||
{
|
||||
public short x;
|
||||
public short y;
|
||||
}
|
||||
|
||||
class FinderInfo
|
||||
{
|
||||
public uint fdCreator;
|
||||
public FinderFlags fdFlags;
|
||||
public short fdFldr;
|
||||
public Point fdLocation;
|
||||
public uint fdType;
|
||||
}
|
||||
|
||||
class PathTableEntryInternal
|
||||
{
|
||||
public uint Extent;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Helpers;
|
||||
|
||||
namespace DiscImageChef.Filesystems.ISO9660
|
||||
{
|
||||
@@ -42,21 +43,40 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
public Errno ListXAttr(string path, out List<string> xattrs)
|
||||
{
|
||||
xattrs = null;
|
||||
if(!mounted) return Errno.AccessDenied;
|
||||
|
||||
if(!mounted)
|
||||
return Errno.AccessDenied;
|
||||
|
||||
Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry);
|
||||
if(err != Errno.NoError) return err;
|
||||
|
||||
if(err != Errno.NoError)
|
||||
return err;
|
||||
|
||||
xattrs = new List<string>();
|
||||
|
||||
if(entry.XattrLength > 0) xattrs.Add("org.iso.9660.ea");
|
||||
if(entry.AssociatedFile != null) xattrs.Add("org.iso.9660.AssociatedFile");
|
||||
if(entry.AppleDosType != null) xattrs.Add("com.apple.dos.type");
|
||||
if(entry.AppleProDosType != null) xattrs.Add("com.apple.prodos.type");
|
||||
if(entry.ResourceFork != null) xattrs.Add("com.apple.ResourceFork");
|
||||
if(entry.FinderInfo != null) xattrs.Add("com.apple.FinderInfo");
|
||||
if(entry.AppleIcon != null) xattrs.Add("com.apple.Macintosh.Icon");
|
||||
if(entry.AmigaComment != null) xattrs.Add("com.amiga.comments");
|
||||
if(entry.XattrLength > 0)
|
||||
xattrs.Add("org.iso.9660.ea");
|
||||
|
||||
if(entry.AssociatedFile != null)
|
||||
xattrs.Add("org.iso.9660.AssociatedFile");
|
||||
|
||||
if(entry.AppleDosType != null)
|
||||
xattrs.Add("com.apple.dos.type");
|
||||
|
||||
if(entry.AppleProDosType != null)
|
||||
xattrs.Add("com.apple.prodos.type");
|
||||
|
||||
if(entry.ResourceFork != null)
|
||||
xattrs.Add("com.apple.ResourceFork");
|
||||
|
||||
if(entry.FinderInfo != null)
|
||||
xattrs.Add("com.apple.FinderInfo");
|
||||
|
||||
if(entry.AppleIcon != null)
|
||||
xattrs.Add("com.apple.Macintosh.Icon");
|
||||
|
||||
if(entry.AmigaComment != null)
|
||||
xattrs.Add("com.amiga.comments");
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
@@ -64,20 +84,28 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
public Errno GetXattr(string path, string xattr, ref byte[] buf)
|
||||
{
|
||||
buf = null;
|
||||
if(!mounted) return Errno.AccessDenied;
|
||||
|
||||
if(!mounted)
|
||||
return Errno.AccessDenied;
|
||||
|
||||
Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry);
|
||||
if(err != Errno.NoError) return err;
|
||||
|
||||
if(err != Errno.NoError)
|
||||
return err;
|
||||
|
||||
switch(xattr)
|
||||
{
|
||||
case "org.iso.9660.ea":
|
||||
if(entry.XattrLength == 0) return Errno.NoSuchExtendedAttribute;
|
||||
case"org.iso.9660.ea":
|
||||
if(entry.XattrLength == 0)
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
if(entry.Extents is null) return Errno.InvalidArgument;
|
||||
if(entry.Extents is null)
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
uint eaSizeInSectors = (uint)(entry.XattrLength / 2048);
|
||||
if(entry.XattrLength % 2048 > 0) eaSizeInSectors++;
|
||||
|
||||
if(entry.XattrLength % 2048 > 0)
|
||||
eaSizeInSectors++;
|
||||
|
||||
byte[] ea = ReadSectors(entry.Extents[0].extent, eaSizeInSectors);
|
||||
|
||||
@@ -85,92 +113,99 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
Array.Copy(ea, 0, buf, 0, buf.LongLength);
|
||||
|
||||
return Errno.NoError;
|
||||
case "org.iso.9660.AssociatedFile":
|
||||
if(entry.AssociatedFile is null) return Errno.NoSuchExtendedAttribute;
|
||||
case"org.iso.9660.AssociatedFile":
|
||||
if(entry.AssociatedFile is null)
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
if(entry.AssociatedFile.Extents is null) return Errno.InvalidArgument;
|
||||
if(entry.AssociatedFile.Extents is null)
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
if(entry.AssociatedFile.Size == 0)
|
||||
{
|
||||
buf = new byte[0];
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
if(entry.AssociatedFile.Extents.Count == 1)
|
||||
{
|
||||
uint associatedFileSize = (uint)(entry.AssociatedFile.Size / 2048);
|
||||
if(entry.AssociatedFile.Size % 2048 > 0) associatedFileSize++;
|
||||
|
||||
if(entry.AssociatedFile.Size % 2048 > 0)
|
||||
associatedFileSize++;
|
||||
|
||||
byte[] buffer = ReadSectors(entry.AssociatedFile.Extents[0].extent, associatedFileSize);
|
||||
|
||||
buf = new byte[entry.AssociatedFile.Size];
|
||||
Array.Copy(buffer, 0, buf, 0, buf.LongLength);
|
||||
}
|
||||
else buf = ReadWithExtents(0, (long)entry.AssociatedFile.Size, entry.AssociatedFile.Extents);
|
||||
else
|
||||
buf = ReadWithExtents(0, (long)entry.AssociatedFile.Size, entry.AssociatedFile.Extents);
|
||||
|
||||
return Errno.NoError;
|
||||
case "com.apple.dos.type":
|
||||
if(entry.AppleDosType is null) return Errno.NoSuchExtendedAttribute;
|
||||
case"com.apple.dos.type":
|
||||
if(entry.AppleDosType is null)
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
buf = new byte[1];
|
||||
buf[0] = entry.AppleDosType.Value;
|
||||
|
||||
return Errno.NoError;
|
||||
case "com.apple.prodos.type":
|
||||
if(entry.AppleProDosType is null) return Errno.NoSuchExtendedAttribute;
|
||||
case"com.apple.prodos.type":
|
||||
if(entry.AppleProDosType is null)
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
buf = BitConverter.GetBytes(entry.AppleProDosType.Value);
|
||||
|
||||
return Errno.NoError;
|
||||
case "com.apple.ResourceFork":
|
||||
if(entry.ResourceFork is null) return Errno.NoSuchExtendedAttribute;
|
||||
case"com.apple.ResourceFork":
|
||||
if(entry.ResourceFork is null)
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
if(entry.ResourceFork.Extents is null) return Errno.InvalidArgument;
|
||||
if(entry.ResourceFork.Extents is null)
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
if(entry.ResourceFork.Size == 0)
|
||||
{
|
||||
buf = new byte[0];
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
if(entry.ResourceFork.Extents.Count == 1)
|
||||
{
|
||||
uint rsrcSizeInSectors = (uint)(entry.ResourceFork.Size / 2048);
|
||||
if(entry.AssociatedFile.Size % 2048 > 0) rsrcSizeInSectors++;
|
||||
|
||||
if(entry.AssociatedFile.Size % 2048 > 0)
|
||||
rsrcSizeInSectors++;
|
||||
|
||||
byte[] buffer = ReadSectors(entry.ResourceFork.Extents[0].extent, rsrcSizeInSectors);
|
||||
|
||||
buf = new byte[entry.ResourceFork.Size];
|
||||
Array.Copy(buffer, 0, buf, 0, buf.LongLength);
|
||||
}
|
||||
else buf = ReadWithExtents(0, (long)entry.ResourceFork.Size, entry.ResourceFork.Extents);
|
||||
else
|
||||
buf = ReadWithExtents(0, (long)entry.ResourceFork.Size, entry.ResourceFork.Extents);
|
||||
|
||||
return Errno.NoError;
|
||||
case "com.apple.FinderInfo":
|
||||
if(entry.FinderInfo is null) return Errno.NoSuchExtendedAttribute;
|
||||
case"com.apple.FinderInfo":
|
||||
if(entry.FinderInfo is null)
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
buf = new byte[16];
|
||||
byte[] tmp = BigEndianBitConverter.GetBytes(entry.FinderInfo.fdType);
|
||||
Array.Copy(tmp, 0, buf, 0, tmp.Length);
|
||||
tmp = BigEndianBitConverter.GetBytes(entry.FinderInfo.fdCreator);
|
||||
Array.Copy(tmp, 0, buf, 4, tmp.Length);
|
||||
tmp = BigEndianBitConverter.GetBytes((ushort)entry.FinderInfo.fdFlags);
|
||||
Array.Copy(tmp, 0, buf, 8, tmp.Length);
|
||||
tmp = BigEndianBitConverter.GetBytes(entry.FinderInfo.fdLocation.x);
|
||||
Array.Copy(tmp, 0, buf, 10, tmp.Length);
|
||||
tmp = BigEndianBitConverter.GetBytes(entry.FinderInfo.fdLocation.y);
|
||||
Array.Copy(tmp, 0, buf, 12, tmp.Length);
|
||||
tmp = BigEndianBitConverter.GetBytes(entry.FinderInfo.fdFldr);
|
||||
Array.Copy(tmp, 0, buf, 14, tmp.Length);
|
||||
buf = Marshal.StructureToByteArrayBigEndian(entry.FinderInfo.Value);
|
||||
|
||||
return Errno.NoError;
|
||||
case "com.apple.Macintosh.Icon":
|
||||
if(entry.AppleIcon is null) return Errno.NoSuchExtendedAttribute;
|
||||
case"com.apple.Macintosh.Icon":
|
||||
if(entry.AppleIcon is null)
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
buf = new byte[entry.AppleIcon.Length];
|
||||
Array.Copy(entry.AppleIcon, 0, buf, 0, entry.AppleIcon.Length);
|
||||
|
||||
return Errno.NoError;
|
||||
case "com.amiga.comments":
|
||||
if(entry.AmigaComment is null) return Errno.NoSuchExtendedAttribute;
|
||||
case"com.amiga.comments":
|
||||
if(entry.AmigaComment is null)
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
buf = new byte[entry.AmigaComment.Length];
|
||||
Array.Copy(entry.AmigaComment, 0, buf, 0, entry.AmigaComment.Length);
|
||||
|
||||
Reference in New Issue
Block a user