Code cleanup.

This commit is contained in:
2018-06-22 08:08:38 +01:00
parent 82f474c7e3
commit 88da8fc019
581 changed files with 22423 additions and 20839 deletions

View File

@@ -69,7 +69,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
// TODO: Implement Finder namespace (requires decoding Desktop database)
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
new(string name, Type type, string description)[] { };
new (string name, Type type, string description)[] { };
static Dictionary<string, string> GetDefaultOptions()
{

View File

@@ -39,13 +39,13 @@ namespace DiscImageChef.Filesystems.AppleMFS
// "LK"
const ushort MFSBB_MAGIC = 0x4C4B;
const short DIRID_TRASH = -3;
const short DIRID_DESKTOP = -2;
const short DIRID_TRASH = -3;
const short DIRID_DESKTOP = -2;
const short DIRID_TEMPLATE = -1;
const short DIRID_ROOT = 0;
const short DIRID_ROOT = 0;
const int BMAP_FREE = 0;
const int BMAP_LAST = 1;
const int BMAP_DIR = 0xFFF;
const int BMAP_DIR = 0xFFF;
}
}

View File

@@ -65,7 +65,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
bool FillDirectory()
{
idToFilename = new Dictionary<uint, string>();
idToEntry = new Dictionary<uint, MFS_FileEntry>();
idToEntry = new Dictionary<uint, MFS_FileEntry>();
filenameToId = new Dictionary<string, uint>();
int offset = 0;
@@ -74,29 +74,29 @@ namespace DiscImageChef.Filesystems.AppleMFS
MFS_FileEntry entry = new MFS_FileEntry
{
flUsrWds = new byte[16],
flFlags = (MFS_FileFlags)directoryBlocks[offset + 0]
flFlags = (MFS_FileFlags)directoryBlocks[offset + 0]
};
if(!entry.flFlags.HasFlag(MFS_FileFlags.Used)) break;
entry.flTyp = directoryBlocks[offset + 1];
Array.Copy(directoryBlocks, offset + 2, entry.flUsrWds, 0, 16);
entry.flFlNum = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 18);
entry.flStBlk = BigEndianBitConverter.ToUInt16(directoryBlocks, offset + 22);
entry.flLgLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 24);
entry.flPyLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 28);
entry.flFlNum = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 18);
entry.flStBlk = BigEndianBitConverter.ToUInt16(directoryBlocks, offset + 22);
entry.flLgLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 24);
entry.flPyLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 28);
entry.flRStBlk = BigEndianBitConverter.ToUInt16(directoryBlocks, offset + 32);
entry.flRLgLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 34);
entry.flRPyLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 38);
entry.flCrDat = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 42);
entry.flMdDat = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 46);
entry.flNam = new byte[directoryBlocks[offset + 50] + 1];
entry.flCrDat = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 42);
entry.flMdDat = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 46);
entry.flNam = new byte[directoryBlocks[offset + 50] + 1];
Array.Copy(directoryBlocks, offset + 50, entry.flNam, 0, entry.flNam.Length);
string lowerFilename = StringHandlers
.PascalToString(entry.flNam, Encoding).ToLowerInvariant().Replace('/', ':');
.PascalToString(entry.flNam, Encoding).ToLowerInvariant().Replace('/', ':');
if(entry.flFlags.HasFlag(MFS_FileFlags.Used) && !idToFilename.ContainsKey(entry.flFlNum) &&
!idToEntry.ContainsKey(entry.flFlNum) && !filenameToId.ContainsKey(lowerFilename) &&
!idToEntry.ContainsKey(entry.flFlNum) && !filenameToId.ContainsKey(lowerFilename) &&
entry.flFlNum > 0)
{
idToEntry.Add(entry.flFlNum, entry);
@@ -104,12 +104,12 @@ namespace DiscImageChef.Filesystems.AppleMFS
StringHandlers.PascalToString(entry.flNam, Encoding).Replace('/', ':'));
filenameToId.Add(lowerFilename, entry.flFlNum);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flFlags = {0}", entry.flFlags);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flTyp = {0}", entry.flTyp);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flFlNum = {0}", entry.flFlNum);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flStBlk = {0}", entry.flStBlk);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flLgLen = {0}", entry.flLgLen);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flPyLen = {0}", entry.flPyLen);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flFlags = {0}", entry.flFlags);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flTyp = {0}", entry.flTyp);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flFlNum = {0}", entry.flFlNum);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flStBlk = {0}", entry.flStBlk);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flLgLen = {0}", entry.flLgLen);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flPyLen = {0}", entry.flPyLen);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flRStBlk = {0}", entry.flRStBlk);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flRLgLen = {0}", entry.flRLgLen);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flRPyLen = {0}", entry.flRPyLen);

View File

@@ -56,7 +56,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
if(fileBlock > entry.flPyLen / volMDB.drAlBlkSiz) return Errno.InvalidArgument;
uint nextBlock = entry.flStBlk;
long relBlock = 0;
long relBlock = 0;
while(true)
{
@@ -89,16 +89,16 @@ namespace DiscImageChef.Filesystems.AppleMFS
MFS_FinderFlags fdFlags = (MFS_FinderFlags)BigEndianBitConverter.ToUInt16(entry.flUsrWds, 0x08);
if(fdFlags.HasFlag(MFS_FinderFlags.kIsAlias)) attributes |= FileAttributes.Alias;
if(fdFlags.HasFlag(MFS_FinderFlags.kHasBundle)) attributes |= FileAttributes.Bundle;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsAlias)) attributes |= FileAttributes.Alias;
if(fdFlags.HasFlag(MFS_FinderFlags.kHasBundle)) attributes |= FileAttributes.Bundle;
if(fdFlags.HasFlag(MFS_FinderFlags.kHasBeenInited)) attributes |= FileAttributes.HasBeenInited;
if(fdFlags.HasFlag(MFS_FinderFlags.kHasCustomIcon)) attributes |= FileAttributes.HasCustomIcon;
if(fdFlags.HasFlag(MFS_FinderFlags.kHasNoINITs)) attributes |= FileAttributes.HasNoINITs;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsInvisible)) attributes |= FileAttributes.Hidden;
if(entry.flFlags.HasFlag(MFS_FileFlags.Locked)) attributes |= FileAttributes.Immutable;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsOnDesk)) attributes |= FileAttributes.IsOnDesk;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsShared)) attributes |= FileAttributes.Shared;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsStationery)) attributes |= FileAttributes.Stationery;
if(fdFlags.HasFlag(MFS_FinderFlags.kHasNoINITs)) attributes |= FileAttributes.HasNoINITs;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsInvisible)) attributes |= FileAttributes.Hidden;
if(entry.flFlags.HasFlag(MFS_FileFlags.Locked)) attributes |= FileAttributes.Immutable;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsOnDesk)) attributes |= FileAttributes.IsOnDesk;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsShared)) attributes |= FileAttributes.Shared;
if(fdFlags.HasFlag(MFS_FinderFlags.kIsStationery)) attributes |= FileAttributes.Stationery;
if(!attributes.HasFlag(FileAttributes.Alias) && !attributes.HasFlag(FileAttributes.Bundle) &&
!attributes.HasFlag(FileAttributes.Stationery)) attributes |= FileAttributes.File;
@@ -113,15 +113,18 @@ namespace DiscImageChef.Filesystems.AppleMFS
if(!mounted) return Errno.AccessDenied;
byte[] file;
Errno error = Errno.NoError;
Errno error = Errno.NoError;
if(debug && string.Compare(path, "$", StringComparison.InvariantCulture) == 0) file = directoryBlocks;
else if(debug && string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 && bootBlocks != null
) file = bootBlocks;
else if(debug && string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 &&
bootBlocks != null)
file = bootBlocks;
else if(debug && string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0)
file = blockMapBytes;
file = blockMapBytes;
else if(debug && string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) file = mdbBlocks;
else error = ReadFile(path, out file, false, false);
else
error =
ReadFile(path, out file, false, false);
if(error != Errno.NoError) return error;
@@ -151,20 +154,20 @@ namespace DiscImageChef.Filesystems.AppleMFS
if(pathElements.Length != 1) return Errno.NotSupported;
if(debug)
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
{
stat = new FileEntryInfo
{
BlockSize = device.Info.SectorSize,
DeviceNo = 0,
GID = 0,
Inode = 0,
Links = 1,
Mode = 0x124,
UID = 0,
BlockSize = device.Info.SectorSize,
DeviceNo = 0,
GID = 0,
Inode = 0,
Links = 1,
Mode = 0x124,
UID = 0,
Attributes = FileAttributes.System
};
@@ -202,18 +205,18 @@ namespace DiscImageChef.Filesystems.AppleMFS
stat = new FileEntryInfo
{
Attributes = attr,
Blocks = entry.flLgLen / volMDB.drAlBlkSiz,
BlockSize = volMDB.drAlBlkSiz,
CreationTime = DateHandlers.MacToDateTime(entry.flCrDat),
DeviceNo = 0,
GID = 0,
Inode = entry.flFlNum,
Attributes = attr,
Blocks = entry.flLgLen / volMDB.drAlBlkSiz,
BlockSize = volMDB.drAlBlkSiz,
CreationTime = DateHandlers.MacToDateTime(entry.flCrDat),
DeviceNo = 0,
GID = 0,
Inode = entry.flFlNum,
LastWriteTime = DateHandlers.MacToDateTime(entry.flMdDat),
Length = entry.flPyLen,
Links = 1,
Mode = 0x124,
UID = 0
Length = entry.flPyLen,
Links = 1,
Mode = 0x124,
UID = 0
};
return Errno.NoError;
@@ -291,7 +294,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
else
{
if(resourceFork)
if(ms.Length < entry.flRLgLen) buf = ms.ToArray();
if(ms.Length < entry.flRLgLen)
buf = ms.ToArray();
else
{
buf = new byte[entry.flRLgLen];

View File

@@ -57,39 +57,39 @@ namespace DiscImageChef.Filesystems.AppleMFS
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
Encoding encoding)
Encoding encoding)
{
Encoding = encoding ?? new MacRoman();
Encoding = encoding ?? new MacRoman();
information = "";
StringBuilder sb = new StringBuilder();
MFS_MasterDirectoryBlock mdb = new MFS_MasterDirectoryBlock();
MFS_BootBlock bb = new MFS_BootBlock();
MFS_BootBlock bb = new MFS_BootBlock();
byte[] pString = new byte[16];
byte[] mdbSector = imagePlugin.ReadSector(2 + partition.Start);
byte[] bbSector = imagePlugin.ReadSector(0 + partition.Start);
byte[] bbSector = imagePlugin.ReadSector(0 + partition.Start);
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
mdb.drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000);
if(mdb.drSigWord != MFS_MAGIC) return;
mdb.drCrDate = BigEndianBitConverter.ToUInt32(mdbSector, 0x002);
mdb.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbSector, 0x006);
mdb.drAtrb = BigEndianBitConverter.ToUInt16(mdbSector, 0x00A);
mdb.drNmFls = BigEndianBitConverter.ToUInt16(mdbSector, 0x00C);
mdb.drDirSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x00E);
mdb.drBlLen = BigEndianBitConverter.ToUInt16(mdbSector, 0x010);
mdb.drCrDate = BigEndianBitConverter.ToUInt32(mdbSector, 0x002);
mdb.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbSector, 0x006);
mdb.drAtrb = BigEndianBitConverter.ToUInt16(mdbSector, 0x00A);
mdb.drNmFls = BigEndianBitConverter.ToUInt16(mdbSector, 0x00C);
mdb.drDirSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x00E);
mdb.drBlLen = BigEndianBitConverter.ToUInt16(mdbSector, 0x010);
mdb.drNmAlBlks = BigEndianBitConverter.ToUInt16(mdbSector, 0x012);
mdb.drAlBlkSiz = BigEndianBitConverter.ToUInt32(mdbSector, 0x014);
mdb.drClpSiz = BigEndianBitConverter.ToUInt32(mdbSector, 0x018);
mdb.drAlBlSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x01C);
mdb.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbSector, 0x01E);
mdb.drFreeBks = BigEndianBitConverter.ToUInt16(mdbSector, 0x022);
mdb.drVNSiz = mdbSector[0x024];
mdb.drClpSiz = BigEndianBitConverter.ToUInt32(mdbSector, 0x018);
mdb.drAlBlSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x01C);
mdb.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbSector, 0x01E);
mdb.drFreeBks = BigEndianBitConverter.ToUInt16(mdbSector, 0x022);
mdb.drVNSiz = mdbSector[0x024];
byte[] variableSize = new byte[mdb.drVNSiz + 1];
Array.Copy(mdbSector, 0x024, variableSize, 0, mdb.drVNSiz + 1);
mdb.drVN = StringHandlers.PascalToString(variableSize, Encoding);
@@ -98,8 +98,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
if(bb.signature == MFSBB_MAGIC)
{
bb.branch = BigEndianBitConverter.ToUInt32(bbSector, 0x002);
bb.boot_flags = bbSector[0x006];
bb.branch = BigEndianBitConverter.ToUInt32(bbSector, 0x002);
bb.boot_flags = bbSector[0x006];
bb.boot_version = bbSector[0x007];
bb.sec_sv_pages = BigEndianBitConverter.ToInt16(bbSector, 0x008);
@@ -119,11 +119,11 @@ namespace DiscImageChef.Filesystems.AppleMFS
Array.Copy(mdbSector, 0x06A, pString, 0, 16);
bb.clipbrd_name = StringHandlers.PascalToString(pString, Encoding);
bb.max_files = BigEndianBitConverter.ToUInt16(bbSector, 0x07A);
bb.max_files = BigEndianBitConverter.ToUInt16(bbSector, 0x07A);
bb.queue_size = BigEndianBitConverter.ToUInt16(bbSector, 0x07C);
bb.heap_128k = BigEndianBitConverter.ToUInt32(bbSector, 0x07E);
bb.heap_256k = BigEndianBitConverter.ToUInt32(bbSector, 0x082);
bb.heap_512k = BigEndianBitConverter.ToUInt32(bbSector, 0x086);
bb.heap_128k = BigEndianBitConverter.ToUInt32(bbSector, 0x07E);
bb.heap_256k = BigEndianBitConverter.ToUInt32(bbSector, 0x082);
bb.heap_512k = BigEndianBitConverter.ToUInt32(bbSector, 0x086);
}
else bb.signature = 0x0000;
@@ -132,7 +132,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
sb.AppendLine("Master Directory Block:");
sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(mdb.drCrDate)).AppendLine();
sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(mdb.drLsBkUp)).AppendLine();
if((mdb.drAtrb & 0x80) == 0x80) sb.AppendLine("Volume is locked by hardware.");
if((mdb.drAtrb & 0x80) == 0x80) sb.AppendLine("Volume is locked by hardware.");
if((mdb.drAtrb & 0x8000) == 0x8000) sb.AppendLine("Volume is locked by software.");
sb.AppendFormat("{0} files on volume", mdb.drNmFls).AppendLine();
sb.AppendFormat("First directory sector: {0}", mdb.drDirSt).AppendLine();
@@ -154,7 +154,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
if((bb.boot_flags & 0x80) == 0x80) sb.AppendLine("Boot block is in new unknown format.");
else
{
if(bb.sec_sv_pages > 0) sb.AppendLine("Allocate secondary sound buffer at boot.");
if(bb.sec_sv_pages > 0) sb.AppendLine("Allocate secondary sound buffer at boot.");
else if(bb.sec_sv_pages < 0) sb.AppendLine("Allocate secondary sound and video buffers at boot.");
sb.AppendFormat("System filename: {0}", bb.system_name).AppendLine();
@@ -178,23 +178,25 @@ namespace DiscImageChef.Filesystems.AppleMFS
XmlFsType = new FileSystemType();
if(mdb.drLsBkUp > 0)
{
XmlFsType.BackupDate = DateHandlers.MacToDateTime(mdb.drLsBkUp);
XmlFsType.BackupDate = DateHandlers.MacToDateTime(mdb.drLsBkUp);
XmlFsType.BackupDateSpecified = true;
}
XmlFsType.Bootable = bb.signature == MFSBB_MAGIC;
XmlFsType.Clusters = mdb.drNmAlBlks;
XmlFsType.Bootable = bb.signature == MFSBB_MAGIC;
XmlFsType.Clusters = mdb.drNmAlBlks;
XmlFsType.ClusterSize = (int)mdb.drAlBlkSiz;
if(mdb.drCrDate > 0)
{
XmlFsType.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate);
XmlFsType.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate);
XmlFsType.CreationDateSpecified = true;
}
XmlFsType.Files = mdb.drNmFls;
XmlFsType.FilesSpecified = true;
XmlFsType.FreeClusters = mdb.drFreeBks;
XmlFsType.Files = mdb.drNmFls;
XmlFsType.FilesSpecified = true;
XmlFsType.FreeClusters = mdb.drFreeBks;
XmlFsType.FreeClustersSpecified = true;
XmlFsType.Type = "MFS";
XmlFsType.VolumeName = mdb.drVN;
XmlFsType.Type = "MFS";
XmlFsType.VolumeName = mdb.drVN;
}
}
}

View File

@@ -124,26 +124,26 @@ namespace DiscImageChef.Filesystems.AppleMFS
enum MFS_FileFlags : byte
{
Locked = 0x01,
Used = 0x80
Used = 0x80
}
[Flags]
enum MFS_FinderFlags : ushort
{
kIsOnDesk = 0x0001,
kColor = 0x000E,
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
kIsShared = 0x0040,
kHasNoINITs = 0x0080,
kHasBeenInited = 0x0100,
kHasCustomIcon = 0x0400,
kLetter = 0x0200,
kChanged = 0x0200,
kIsStationery = 0x0800,
kNameLocked = 0x1000,
kHasBundle = 0x2000,
kIsInvisible = 0x4000,
kIsAlias = 0x8000
}
struct MFS_Point
@@ -154,11 +154,11 @@ namespace DiscImageChef.Filesystems.AppleMFS
struct MFS_FinderInfo
{
public uint fdType;
public uint fdCreator;
public uint fdType;
public uint fdCreator;
public MFS_FinderFlags fdFlags;
public MFS_Point fdLocation;
public short fdFldr;
public MFS_Point fdLocation;
public short fdFldr;
}
struct MFS_FileEntry

View File

@@ -45,9 +45,9 @@ namespace DiscImageChef.Filesystems.AppleMFS
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
Dictionary<string, string> options)
{
device = imagePlugin;
partitionStart = partition.Start;
Encoding = encoding ?? Encoding.GetEncoding("macintosh");
device = imagePlugin;
partitionStart = partition.Start;
Encoding = encoding ?? Encoding.GetEncoding("macintosh");
if(options == null) options = GetDefaultOptions();
if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out debug);
volMDB = new MFS_MasterDirectoryBlock();
@@ -60,64 +60,63 @@ namespace DiscImageChef.Filesystems.AppleMFS
volMDB.drSigWord = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x000);
if(volMDB.drSigWord != MFS_MAGIC) return Errno.InvalidArgument;
volMDB.drCrDate = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x002);
volMDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x006);
volMDB.drAtrb = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00A);
volMDB.drNmFls = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00C);
volMDB.drDirSt = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00E);
volMDB.drBlLen = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x010);
volMDB.drNmAlBlks = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x012);
volMDB.drAlBlkSiz = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x014);
volMDB.drClpSiz = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x018);
volMDB.drAlBlSt = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x01C);
volMDB.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x01E);
volMDB.drFreeBks = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x022);
volMDB.drVNSiz = mdbBlocks[0x024];
byte[] variableSize = new byte[volMDB.drVNSiz + 1];
volMDB.drCrDate = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x002);
volMDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x006);
volMDB.drAtrb = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00A);
volMDB.drNmFls = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00C);
volMDB.drDirSt = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00E);
volMDB.drBlLen = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x010);
volMDB.drNmAlBlks = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x012);
volMDB.drAlBlkSiz = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x014);
volMDB.drClpSiz = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x018);
volMDB.drAlBlSt = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x01C);
volMDB.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x01E);
volMDB.drFreeBks = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x022);
volMDB.drVNSiz = mdbBlocks[0x024];
byte[] variableSize = new byte[volMDB.drVNSiz + 1];
Array.Copy(mdbBlocks, 0x024, variableSize, 0, volMDB.drVNSiz + 1);
volMDB.drVN = StringHandlers.PascalToString(variableSize, Encoding);
directoryBlocks = device.ReadSectors(volMDB.drDirSt + partitionStart, volMDB.drBlLen);
int bytesInBlockMap = volMDB.drNmAlBlks * 12 / 8 + volMDB.drNmAlBlks * 12 % 8;
directoryBlocks = device.ReadSectors(volMDB.drDirSt + partitionStart, volMDB.drBlLen);
int bytesInBlockMap = volMDB.drNmAlBlks * 12 / 8 + volMDB.drNmAlBlks * 12 % 8;
const int BYTES_BEFORE_BLOCK_MAP = 64;
int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP;
int sectorsInWholeMdb = bytesInWholeMdb / (int)device.Info.SectorSize +
bytesInWholeMdb % (int)device.Info.SectorSize;
int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP;
int sectorsInWholeMdb = bytesInWholeMdb / (int)device.Info.SectorSize +
bytesInWholeMdb % (int)device.Info.SectorSize;
byte[] wholeMdb = device.ReadSectors(partitionStart + 2, (uint)sectorsInWholeMdb);
blockMapBytes = new byte[bytesInBlockMap];
blockMapBytes = new byte[bytesInBlockMap];
Array.Copy(wholeMdb, BYTES_BEFORE_BLOCK_MAP, blockMapBytes, 0, blockMapBytes.Length);
int offset = 0;
blockMap = new uint[volMDB.drNmAlBlks + 2 + 1];
for(int i = 2; i < volMDB.drNmAlBlks + 2; i += 8)
blockMap = new uint[volMDB.drNmAlBlks + 2 + 1];
for(int i = 2; i < volMDB.drNmAlBlks + 2; i += 8)
{
uint tmp1 = 0;
uint tmp2 = 0;
uint tmp3 = 0;
if(offset + 4 <= blockMapBytes.Length)
tmp1 = BigEndianBitConverter.ToUInt32(blockMapBytes, offset);
if(offset + 4 + 4 <= blockMapBytes.Length)
if(offset + 4 <= blockMapBytes.Length) tmp1 = BigEndianBitConverter.ToUInt32(blockMapBytes, offset);
if(offset + 4 + 4 <= blockMapBytes.Length)
tmp2 = BigEndianBitConverter.ToUInt32(blockMapBytes, offset + 4);
if(offset + 8 + 4 <= blockMapBytes.Length)
if(offset + 8 + 4 <= blockMapBytes.Length)
tmp3 = BigEndianBitConverter.ToUInt32(blockMapBytes, offset + 8);
if(i < blockMap.Length) blockMap[i] = (tmp1 & 0xFFF00000) >> 20;
if(i + 2 < blockMap.Length) blockMap[i + 1] = (tmp1 & 0xFFF00) >> 8;
if(i + 3 < blockMap.Length) blockMap[i + 2] = ((tmp1 & 0xFF) << 4) + ((tmp2 & 0xF0000000) >> 28);
if(i + 4 < blockMap.Length) blockMap[i + 3] = (tmp2 & 0xFFF0000) >> 16;
if(i + 5 < blockMap.Length) blockMap[i + 4] = (tmp2 & 0xFFF0) >> 4;
if(i + 6 < blockMap.Length) blockMap[i + 5] = ((tmp2 & 0xF) << 8) + ((tmp3 & 0xFF000000) >> 24);
if(i + 7 < blockMap.Length) blockMap[i + 6] = (tmp3 & 0xFFF000) >> 12;
if(i + 8 < blockMap.Length) blockMap[i + 7] = tmp3 & 0xFFF;
if(i < blockMap.Length) blockMap[i] = (tmp1 & 0xFFF00000) >> 20;
if(i + 2 < blockMap.Length) blockMap[i + 1] = (tmp1 & 0xFFF00) >> 8;
if(i + 3 < blockMap.Length) blockMap[i + 2] = ((tmp1 & 0xFF) << 4) + ((tmp2 & 0xF0000000) >> 28);
if(i + 4 < blockMap.Length) blockMap[i + 3] = (tmp2 & 0xFFF0000) >> 16;
if(i + 5 < blockMap.Length) blockMap[i + 4] = (tmp2 & 0xFFF0) >> 4;
if(i + 6 < blockMap.Length) blockMap[i + 5] = ((tmp2 & 0xF) << 8) + ((tmp3 & 0xFF000000) >> 24);
if(i + 7 < blockMap.Length) blockMap[i + 6] = (tmp3 & 0xFFF000) >> 12;
if(i + 8 < blockMap.Length) blockMap[i + 7] = tmp3 & 0xFFF;
offset += 12;
}
if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
{
mdbTags = device.ReadSectorTag(2 + partitionStart, SectorTagType.AppleSectorTag);
bootTags = device.ReadSectorTag(0 + partitionStart, SectorTagType.AppleSectorTag);
mdbTags = device.ReadSectorTag(2 + partitionStart, SectorTagType.AppleSectorTag);
bootTags = device.ReadSectorTag(0 + partitionStart, SectorTagType.AppleSectorTag);
directoryTags = device.ReadSectorsTag(volMDB.drDirSt + partitionStart, volMDB.drBlLen,
SectorTagType.AppleSectorTag);
bitmapTags = device.ReadSectorsTag(partitionStart + 2, (uint)sectorsInWholeMdb,

View File

@@ -51,10 +51,10 @@ namespace DiscImageChef.Filesystems.AppleMFS
xattrs = new List<string>();
if(debug)
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
{
if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
xattrs.Add("com.apple.macintosh.tags");
@@ -91,10 +91,10 @@ namespace DiscImageChef.Filesystems.AppleMFS
if(pathElements.Length != 1) return Errno.NotSupported;
if(debug)
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) &&
string.Compare(xattr, "com.apple.macintosh.tags", StringComparison.InvariantCulture) == 0)
{
@@ -126,7 +126,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
}
else return Errno.NoSuchExtendedAttribute;
else
return Errno.NoSuchExtendedAttribute;
Errno error;
@@ -134,14 +135,14 @@ namespace DiscImageChef.Filesystems.AppleMFS
if(!idToEntry.TryGetValue(fileId, out MFS_FileEntry entry)) return Errno.NoSuchFile;
if(entry.flRLgLen > 0 &&
if(entry.flRLgLen > 0 &&
string.Compare(xattr, "com.apple.ResourceFork", StringComparison.InvariantCulture) == 0)
{
error = ReadFile(path, out buf, true, false);
return error;
}
if(entry.flRLgLen > 0 &&
if(entry.flRLgLen > 0 &&
string.Compare(xattr, "com.apple.ResourceFork.tags", StringComparison.InvariantCulture) == 0)
{
error = ReadFile(path, out buf, true, true);