REFACTOR: Reformat code.

This commit is contained in:
2017-12-19 20:33:03 +00:00
parent 77edc7c91c
commit e6f6ace80b
704 changed files with 82627 additions and 83641 deletions

View File

@@ -73,10 +73,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
Name = "Apple Macintosh File System";
PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
if(encoding == null)
CurrentEncoding = Encoding.GetEncoding("macintosh");
else
CurrentEncoding = encoding;
if(encoding == null) CurrentEncoding = Encoding.GetEncoding("macintosh");
else CurrentEncoding = encoding;
}
public AppleMFS(ImagePlugin imagePlugin, Partition partition, Encoding encoding)
@@ -85,10 +83,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
device = imagePlugin;
partitionStart = partition.Start;
if(encoding == null)
CurrentEncoding = Encoding.GetEncoding("macintosh");
else
CurrentEncoding = encoding;
if(encoding == null) CurrentEncoding = Encoding.GetEncoding("macintosh");
else CurrentEncoding = encoding;
}
}
}
}

View File

@@ -48,5 +48,4 @@ namespace DiscImageChef.Filesystems.AppleMFS
const int BMAP_LAST = 1;
const int BMAP_DIR = 0xFFF;
}
}
}

View File

@@ -41,23 +41,20 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
public override Errno ReadDir(string path, ref List<string> contents)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
return Errno.NotSupported;
contents = new List<string>();
foreach(KeyValuePair<uint, string> kvp in idToFilename)
contents.Add(kvp.Value);
foreach(KeyValuePair<uint, string> kvp in idToFilename) contents.Add(kvp.Value);
if(debug)
{
contents.Add("$");
contents.Add("$Bitmap");
contents.Add("$MDB");
if(bootBlocks != null)
contents.Add("$Boot");
if(bootBlocks != null) contents.Add("$Boot");
}
contents.Sort();
@@ -78,8 +75,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
entry.flUsrWds = new byte[16];
entry.flFlags = (MFS_FileFlags)directoryBlocks[offset + 0];
if(!entry.flFlags.HasFlag(MFS_FileFlags.Used))
break;
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);
@@ -93,14 +90,16 @@ namespace DiscImageChef.Filesystems.AppleMFS
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);
lowerFilename = StringHandlers.PascalToString(entry.flNam, CurrentEncoding).ToLowerInvariant().Replace('/', ':');
lowerFilename = StringHandlers.PascalToString(entry.flNam, CurrentEncoding).ToLowerInvariant()
.Replace('/', ':');
if(entry.flFlags.HasFlag(MFS_FileFlags.Used) && !idToFilename.ContainsKey(entry.flFlNum) &&
!idToEntry.ContainsKey(entry.flFlNum) && !filenameToId.ContainsKey(lowerFilename) &&
entry.flFlNum > 0)
{
idToEntry.Add(entry.flFlNum, entry);
idToFilename.Add(entry.flFlNum, StringHandlers.PascalToString(entry.flNam, CurrentEncoding).Replace('/', ':'));
idToFilename.Add(entry.flFlNum,
StringHandlers.PascalToString(entry.flNam, CurrentEncoding).Replace('/', ':'));
filenameToId.Add(lowerFilename, entry.flFlNum);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flFlags = {0}", entry.flFlags);
@@ -112,16 +111,18 @@ namespace DiscImageChef.Filesystems.AppleMFS
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);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flCrDat = {0}", DateHandlers.MacToDateTime(entry.flCrDat));
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flMdDat = {0}", DateHandlers.MacToDateTime(entry.flMdDat));
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flNam0 = {0}", StringHandlers.PascalToString(entry.flNam, CurrentEncoding));
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flCrDat = {0}",
DateHandlers.MacToDateTime(entry.flCrDat));
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flMdDat = {0}",
DateHandlers.MacToDateTime(entry.flMdDat));
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flNam0 = {0}",
StringHandlers.PascalToString(entry.flNam, CurrentEncoding));
}
offset += (50 + entry.flNam.Length);
// "Entries are always an integral number of words"
if((offset % 2) != 0)
offset++;
if((offset % 2) != 0) offset++;
// TODO: "Entries don't cross logical block boundaries"
}
@@ -129,5 +130,4 @@ namespace DiscImageChef.Filesystems.AppleMFS
return true;
}
}
}
}

View File

@@ -43,24 +43,19 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
deviceBlock = new long();
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
uint fileID;
MFS_FileEntry entry;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID))
return Errno.NoSuchFile;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID)) return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry))
return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry)) return Errno.NoSuchFile;
if(fileBlock > (entry.flPyLen / volMDB.drAlBlkSiz))
return Errno.InvalidArgument;
if(fileBlock > (entry.flPyLen / volMDB.drAlBlkSiz)) return Errno.InvalidArgument;
uint nextBlock = entry.flStBlk;
long relBlock = 0;
@@ -73,8 +68,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
if(blockMap[nextBlock] == BMAP_FREE || blockMap[nextBlock] == BMAP_LAST)
break;
if(blockMap[nextBlock] == BMAP_FREE || blockMap[nextBlock] == BMAP_LAST) break;
nextBlock = blockMap[nextBlock];
relBlock++;
@@ -85,77 +79,56 @@ namespace DiscImageChef.Filesystems.AppleMFS
public override Errno GetAttributes(string path, ref FileAttributes attributes)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
uint fileID;
MFS_FileEntry entry;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID))
return Errno.NoSuchFile;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID)) return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry))
return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry)) return Errno.NoSuchFile;
attributes = new FileAttributes();
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.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.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(!attributes.HasFlag(FileAttributes.Alias) &&
!attributes.HasFlag(FileAttributes.Bundle) &&
!attributes.HasFlag(FileAttributes.Stationery))
attributes |= FileAttributes.File;
if(!attributes.HasFlag(FileAttributes.Alias) && !attributes.HasFlag(FileAttributes.Bundle) &&
!attributes.HasFlag(FileAttributes.Stationery)) attributes |= FileAttributes.File;
attributes |= FileAttributes.BlockUnits;
return Errno.NoError;
}
public override Errno Read(string path, long offset, long size, ref byte[] buf)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
byte[] file;
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;
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, "$Bitmap", StringComparison.InvariantCulture) == 0)
file = blockMapBytes;
else if(debug && string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
file = mdbBlocks;
else
error = ReadFile(path, out file, false, false);
if(error != Errno.NoError)
return error;
else if(debug && string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) file = mdbBlocks;
else error = ReadFile(path, out file, false, false);
if(error != Errno.NoError) return error;
if(size == 0)
{
@@ -163,11 +136,9 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
if(offset >= file.Length)
return Errno.InvalidArgument;
if(offset >= file.Length) return Errno.InvalidArgument;
if(size + offset >= file.Length)
size = file.Length - offset;
if(size + offset >= file.Length) size = file.Length - offset;
buf = new byte[size];
@@ -178,12 +149,10 @@ namespace DiscImageChef.Filesystems.AppleMFS
public override Errno Stat(string path, ref FileEntryInfo stat)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
if(debug)
{
@@ -205,7 +174,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
{
stat.Blocks = (directoryBlocks.Length / stat.BlockSize) + (directoryBlocks.Length % stat.BlockSize);
stat.Blocks = (directoryBlocks.Length / stat.BlockSize) +
(directoryBlocks.Length % stat.BlockSize);
stat.Length = directoryBlocks.Length;
}
else if(string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0)
@@ -223,8 +193,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
stat.Blocks = (mdbBlocks.Length / stat.BlockSize) + (mdbBlocks.Length % stat.BlockSize);
stat.Length = mdbBlocks.Length;
}
else
return Errno.InvalidArgument;
else return Errno.InvalidArgument;
return Errno.NoError;
}
@@ -233,16 +202,13 @@ namespace DiscImageChef.Filesystems.AppleMFS
uint fileID;
MFS_FileEntry entry;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID))
return Errno.NoSuchFile;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID)) return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry))
return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry)) return Errno.NoSuchFile;
FileAttributes attr = new FileAttributes();
Errno error = GetAttributes(path, ref attr);
if(error != Errno.NoError)
return error;
if(error != Errno.NoError) return error;
stat = new FileEntryInfo();
stat.Attributes = attr;
@@ -270,21 +236,17 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
buf = null;
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
uint fileID;
MFS_FileEntry entry;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID))
return Errno.NoSuchFile;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID)) return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry))
return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry)) return Errno.NoSuchFile;
uint nextBlock;
@@ -295,6 +257,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
buf = new byte[0];
return Errno.NoError;
}
nextBlock = entry.flRStBlk;
}
else
@@ -314,9 +277,13 @@ namespace DiscImageChef.Filesystems.AppleMFS
do
{
if(tags)
sectors = device.ReadSectorsTag((ulong)((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + partitionStart, (uint)sectorsPerBlock, ImagePlugins.SectorTagType.AppleSectorTag);
sectors =
device.ReadSectorsTag((ulong)((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + partitionStart,
(uint)sectorsPerBlock, ImagePlugins.SectorTagType.AppleSectorTag);
else
sectors = device.ReadSectors((ulong)((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + partitionStart, (uint)sectorsPerBlock);
sectors =
device.ReadSectors((ulong)((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + partitionStart,
(uint)sectorsPerBlock);
ms.Write(sectors, 0, sectors.Length);
@@ -330,14 +297,12 @@ namespace DiscImageChef.Filesystems.AppleMFS
}
while(nextBlock > BMAP_LAST);
if(tags)
buf = ms.ToArray();
if(tags) buf = ms.ToArray();
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];
@@ -346,8 +311,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
}
else
{
if(ms.Length < entry.flLgLen)
buf = ms.ToArray();
if(ms.Length < entry.flLgLen) buf = ms.ToArray();
else
{
buf = new byte[entry.flLgLen];
@@ -359,5 +323,4 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
}
}
}

View File

@@ -43,8 +43,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
ushort drSigWord;
if((2 + partition.Start) >= partition.End)
return false;
if((2 + partition.Start) >= partition.End) return false;
byte[] mdb_sector = imagePlugin.ReadSector(2 + partition.Start);
@@ -55,7 +54,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
return drSigWord == MFS_MAGIC;
}
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, Partition partition, out string information)
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, Partition partition,
out string information)
{
information = "";
@@ -73,8 +73,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
MDB.drSigWord = BigEndianBitConverter.ToUInt16(mdb_sector, 0x000);
if(MDB.drSigWord != MFS_MAGIC)
return;
if(MDB.drSigWord != MFS_MAGIC) return;
MDB.drCrDate = BigEndianBitConverter.ToUInt32(mdb_sector, 0x002);
MDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdb_sector, 0x006);
@@ -89,8 +88,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
MDB.drNxtFNum = BigEndianBitConverter.ToUInt32(mdb_sector, 0x01E);
MDB.drFreeBks = BigEndianBitConverter.ToUInt16(mdb_sector, 0x022);
MDB.drVNSiz = mdb_sector[0x024];
variable_size = new byte[MDB.drVNSiz+1];
Array.Copy(mdb_sector, 0x024, variable_size, 0, MDB.drVNSiz+1);
variable_size = new byte[MDB.drVNSiz + 1];
Array.Copy(mdb_sector, 0x024, variable_size, 0, MDB.drVNSiz + 1);
MDB.drVN = StringHandlers.PascalToString(variable_size, CurrentEncoding);
BB.signature = BigEndianBitConverter.ToUInt16(bb_sector, 0x000);
@@ -124,18 +123,15 @@ namespace DiscImageChef.Filesystems.AppleMFS
BB.heap_256k = BigEndianBitConverter.ToUInt32(bb_sector, 0x082);
BB.heap_512k = BigEndianBitConverter.ToUInt32(bb_sector, 0x086);
}
else
BB.signature = 0x0000;
else BB.signature = 0x0000;
sb.AppendLine("Apple Macintosh File System");
sb.AppendLine();
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 & 0x8000) == 0x8000)
sb.AppendLine("Volume is locked by software.");
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();
sb.AppendFormat("{0} sectors in directory.", MDB.drBlLen).AppendLine();
@@ -152,18 +148,12 @@ namespace DiscImageChef.Filesystems.AppleMFS
sb.AppendLine("Volume is bootable.");
sb.AppendLine();
sb.AppendLine("Boot Block:");
if((BB.boot_flags & 0x40) == 0x40)
sb.AppendLine("Boot block should be executed.");
if((BB.boot_flags & 0x80) == 0x80)
{
sb.AppendLine("Boot block is in new unknown format.");
}
if((BB.boot_flags & 0x40) == 0x40) sb.AppendLine("Boot block should be executed.");
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.");
else if(BB.sec_sv_pages < 0)
sb.AppendLine("Allocate secondary sound and video buffers 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();
sb.AppendFormat("Finder filename: {0}", BB.finder_name).AppendLine();
@@ -179,8 +169,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
sb.AppendFormat("Heap size with 512KiB of RAM or more: {0} bytes", BB.heap_512k).AppendLine();
}
}
else
sb.AppendLine("Volume is not bootable.");
else sb.AppendLine("Volume is not bootable.");
information = sb.ToString();
@@ -208,5 +197,4 @@ namespace DiscImageChef.Filesystems.AppleMFS
return;
}
}
}
}

View File

@@ -186,5 +186,4 @@ namespace DiscImageChef.Filesystems.AppleMFS
public byte[] flNam;
}
}
}
}

View File

@@ -50,8 +50,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
volMDB.drSigWord = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x000);
if(volMDB.drSigWord != MFS_MAGIC)
return Errno.InvalidArgument;
if(volMDB.drSigWord != MFS_MAGIC) return Errno.InvalidArgument;
volMDB.drCrDate = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x002);
volMDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x006);
@@ -74,42 +73,34 @@ namespace DiscImageChef.Filesystems.AppleMFS
int bytesInBlockMap = ((volMDB.drNmAlBlks * 12) / 8) + ((volMDB.drNmAlBlks * 12) % 8);
int bytesBeforeBlockMap = 64;
int bytesInWholeMDB = bytesInBlockMap + bytesBeforeBlockMap;
int sectorsInWholeMDB = (bytesInWholeMDB / (int)device.ImageInfo.sectorSize) + (bytesInWholeMDB % (int)device.ImageInfo.sectorSize);
int sectorsInWholeMDB = (bytesInWholeMDB / (int)device.ImageInfo.sectorSize) +
(bytesInWholeMDB % (int)device.ImageInfo.sectorSize);
byte[] wholeMDB = device.ReadSectors(partitionStart + 2, (uint)sectorsInWholeMDB);
blockMapBytes = new byte[bytesInBlockMap];
Array.Copy(wholeMDB, bytesBeforeBlockMap, blockMapBytes, 0, blockMapBytes.Length);
int offset = 0;
blockMap = new uint[volMDB.drNmAlBlks + 2 + 1];
for(int i = 2; i < volMDB.drNmAlBlks + 2; i+=8)
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 <= 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)
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;
}
@@ -118,21 +109,21 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
mdbTags = device.ReadSectorTag(2 + partitionStart, ImagePlugins.SectorTagType.AppleSectorTag);
bootTags = device.ReadSectorTag(0 + partitionStart, ImagePlugins.SectorTagType.AppleSectorTag);
directoryTags = device.ReadSectorsTag(volMDB.drDirSt + partitionStart, volMDB.drBlLen, ImagePlugins.SectorTagType.AppleSectorTag);
bitmapTags = device.ReadSectorsTag(partitionStart + 2, (uint)sectorsInWholeMDB, ImagePlugins.SectorTagType.AppleSectorTag);
directoryTags = device.ReadSectorsTag(volMDB.drDirSt + partitionStart, volMDB.drBlLen,
ImagePlugins.SectorTagType.AppleSectorTag);
bitmapTags = device.ReadSectorsTag(partitionStart + 2, (uint)sectorsInWholeMDB,
ImagePlugins.SectorTagType.AppleSectorTag);
}
sectorsPerBlock = (int)(volMDB.drAlBlkSiz / device.ImageInfo.sectorSize);
if(!FillDirectory())
return Errno.InvalidArgument;
if(!FillDirectory()) return Errno.InvalidArgument;
mounted = true;
ushort bbSig = BigEndianBitConverter.ToUInt16(bootBlocks, 0x000);
if(bbSig != MFSBB_MAGIC)
bootBlocks = null;
if(bbSig != MFSBB_MAGIC) bootBlocks = null;
xmlFSType = new Schemas.FileSystemType();
if(volMDB.drLsBkUp > 0)
@@ -188,5 +179,4 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
}
}
}

View File

@@ -41,12 +41,10 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
public override Errno ListXAttr(string path, ref List<string> xattrs)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
xattrs = new List<string>();
@@ -67,11 +65,9 @@ namespace DiscImageChef.Filesystems.AppleMFS
uint fileID;
MFS_FileEntry entry;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID))
return Errno.NoSuchFile;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID)) return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry))
return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry)) return Errno.NoSuchFile;
if(entry.flRLgLen > 0)
{
@@ -80,11 +76,10 @@ namespace DiscImageChef.Filesystems.AppleMFS
xattrs.Add("com.apple.ResourceFork.tags");
}
if(!ArrayHelpers.ArrayIsNullOrEmpty(entry.flUsrWds))
xattrs.Add("com.apple.FinderInfo");
if(!ArrayHelpers.ArrayIsNullOrEmpty(entry.flUsrWds)) xattrs.Add("com.apple.FinderInfo");
if(debug && device.ImageInfo.readableSectorTags.Contains(ImagePlugins.SectorTagType.AppleSectorTag) && entry.flLgLen > 0)
xattrs.Add("com.apple.macintosh.tags");
if(debug && device.ImageInfo.readableSectorTags.Contains(ImagePlugins.SectorTagType.AppleSectorTag) &&
entry.flLgLen > 0) xattrs.Add("com.apple.macintosh.tags");
xattrs.Sort();
@@ -93,12 +88,10 @@ namespace DiscImageChef.Filesystems.AppleMFS
public override Errno GetXattr(string path, string xattr, ref byte[] buf)
{
if(!mounted)
return Errno.AccessDenied;
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return Errno.NotSupported;
string[] pathElements = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
if(debug)
{
@@ -138,8 +131,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
}
else
return Errno.NoSuchExtendedAttribute;
else return Errno.NoSuchExtendedAttribute;
}
}
@@ -147,25 +139,26 @@ namespace DiscImageChef.Filesystems.AppleMFS
MFS_FileEntry entry;
Errno error;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID))
return Errno.NoSuchFile;
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID)) return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry))
return Errno.NoSuchFile;
if(!idToEntry.TryGetValue(fileID, out entry)) return Errno.NoSuchFile;
if(entry.flRLgLen > 0 && string.Compare(xattr, "com.apple.ResourceFork", StringComparison.InvariantCulture) == 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 && string.Compare(xattr, "com.apple.ResourceFork.tags", StringComparison.InvariantCulture) == 0)
if(entry.flRLgLen > 0 &&
string.Compare(xattr, "com.apple.ResourceFork.tags", StringComparison.InvariantCulture) == 0)
{
error = ReadFile(path, out buf, true, true);
return error;
}
if(!ArrayHelpers.ArrayIsNullOrEmpty(entry.flUsrWds) && string.Compare(xattr, "com.apple.FinderInfo", StringComparison.InvariantCulture) == 0)
if(!ArrayHelpers.ArrayIsNullOrEmpty(entry.flUsrWds) &&
string.Compare(xattr, "com.apple.FinderInfo", StringComparison.InvariantCulture) == 0)
{
buf = new byte[16];
Array.Copy(entry.flUsrWds, 0, buf, 0, 16);
@@ -182,5 +175,4 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoSuchExtendedAttribute;
}
}
}
}