mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: All refactor in DiscImageChef.Filesystems.
This commit is contained in:
@@ -65,26 +65,24 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
public AppleMFS()
|
||||
{
|
||||
Name = "Apple Macintosh File System";
|
||||
PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
|
||||
PluginUuid = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
|
||||
CurrentEncoding = Encoding.GetEncoding("macintosh");
|
||||
}
|
||||
|
||||
public AppleMFS(Encoding encoding)
|
||||
{
|
||||
Name = "Apple Macintosh File System";
|
||||
PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
|
||||
if(encoding == null) CurrentEncoding = Encoding.GetEncoding("macintosh");
|
||||
else CurrentEncoding = encoding;
|
||||
PluginUuid = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
|
||||
CurrentEncoding = encoding ?? Encoding.GetEncoding("macintosh");
|
||||
}
|
||||
|
||||
public AppleMFS(ImagePlugin imagePlugin, Partition partition, Encoding encoding)
|
||||
{
|
||||
Name = "Apple Macintosh File System";
|
||||
PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
|
||||
PluginUuid = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
|
||||
device = imagePlugin;
|
||||
partitionStart = partition.Start;
|
||||
if(encoding == null) CurrentEncoding = Encoding.GetEncoding("macintosh");
|
||||
else CurrentEncoding = encoding;
|
||||
CurrentEncoding = encoding ?? Encoding.GetEncoding("macintosh");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
public bool FillDirectory()
|
||||
bool FillDirectory()
|
||||
{
|
||||
idToFilename = new Dictionary<uint, string>();
|
||||
idToEntry = new Dictionary<uint, MFS_FileEntry>();
|
||||
@@ -70,11 +70,12 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
int offset = 0;
|
||||
while(offset + 51 < directoryBlocks.Length)
|
||||
{
|
||||
MFS_FileEntry entry = new MFS_FileEntry();
|
||||
string lowerFilename;
|
||||
entry.flUsrWds = new byte[16];
|
||||
MFS_FileEntry entry = new MFS_FileEntry
|
||||
{
|
||||
flUsrWds = new byte[16],
|
||||
flFlags = (MFS_FileFlags)directoryBlocks[offset + 0]
|
||||
};
|
||||
|
||||
entry.flFlags = (MFS_FileFlags)directoryBlocks[offset + 0];
|
||||
if(!entry.flFlags.HasFlag(MFS_FileFlags.Used)) break;
|
||||
|
||||
entry.flTyp = directoryBlocks[offset + 1];
|
||||
@@ -90,8 +91,8 @@ 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('/', ':');
|
||||
string 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) &&
|
||||
|
||||
@@ -49,12 +49,9 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(pathElements.Length != 1) return Errno.NotSupported;
|
||||
|
||||
uint fileID;
|
||||
MFS_FileEntry entry;
|
||||
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint 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 MFS_FileEntry entry)) return Errno.NoSuchFile;
|
||||
|
||||
if(fileBlock > entry.flPyLen / volMDB.drAlBlkSiz) return Errno.InvalidArgument;
|
||||
|
||||
@@ -85,12 +82,9 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(pathElements.Length != 1) return Errno.NotSupported;
|
||||
|
||||
uint fileID;
|
||||
MFS_FileEntry entry;
|
||||
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint 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 MFS_FileEntry entry)) return Errno.NoSuchFile;
|
||||
|
||||
attributes = new FileAttributes();
|
||||
MFS_FinderFlags fdFlags = (MFS_FinderFlags)BigEndianBitConverter.ToUInt16(entry.flUsrWds, 0x08);
|
||||
@@ -161,16 +155,17 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
|
||||
{
|
||||
stat = new FileEntryInfo();
|
||||
stat.Attributes = new FileAttributes();
|
||||
stat.Attributes = FileAttributes.System;
|
||||
stat.BlockSize = device.GetSectorSize();
|
||||
stat.DeviceNo = 0;
|
||||
stat.GID = 0;
|
||||
stat.Inode = 0;
|
||||
stat.Links = 1;
|
||||
stat.Mode = 0x124;
|
||||
stat.UID = 0;
|
||||
stat = new FileEntryInfo
|
||||
{
|
||||
BlockSize = device.GetSectorSize(),
|
||||
DeviceNo = 0,
|
||||
GID = 0,
|
||||
Inode = 0,
|
||||
Links = 1,
|
||||
Mode = 0x124,
|
||||
UID = 0,
|
||||
Attributes = FileAttributes.System
|
||||
};
|
||||
|
||||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
|
||||
{
|
||||
@@ -198,30 +193,29 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
uint fileID;
|
||||
MFS_FileEntry entry;
|
||||
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint 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 MFS_FileEntry entry)) return Errno.NoSuchFile;
|
||||
|
||||
FileAttributes attr = new FileAttributes();
|
||||
Errno error = GetAttributes(path, ref attr);
|
||||
if(error != Errno.NoError) return error;
|
||||
|
||||
stat = new FileEntryInfo();
|
||||
stat.Attributes = attr;
|
||||
stat.Blocks = entry.flLgLen / volMDB.drAlBlkSiz;
|
||||
stat.BlockSize = volMDB.drAlBlkSiz;
|
||||
stat.CreationTime = DateHandlers.MacToDateTime(entry.flCrDat);
|
||||
stat.DeviceNo = 0;
|
||||
stat.GID = 0;
|
||||
stat.Inode = entry.flFlNum;
|
||||
stat.LastWriteTime = DateHandlers.MacToDateTime(entry.flMdDat);
|
||||
stat.Length = entry.flPyLen;
|
||||
stat.Links = 1;
|
||||
stat.Mode = 0x124;
|
||||
stat.UID = 0;
|
||||
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,
|
||||
LastWriteTime = DateHandlers.MacToDateTime(entry.flMdDat),
|
||||
Length = entry.flPyLen,
|
||||
Links = 1,
|
||||
Mode = 0x124,
|
||||
UID = 0
|
||||
};
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
@@ -240,12 +234,9 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(pathElements.Length != 1) return Errno.NotSupported;
|
||||
|
||||
uint fileID;
|
||||
MFS_FileEntry entry;
|
||||
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint 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 MFS_FileEntry entry)) return Errno.NoSuchFile;
|
||||
|
||||
uint nextBlock;
|
||||
|
||||
@@ -271,10 +262,10 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
}
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
byte[] sectors;
|
||||
|
||||
do
|
||||
{
|
||||
byte[] sectors;
|
||||
if(tags)
|
||||
sectors =
|
||||
device.ReadSectorsTag((ulong)((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + partitionStart,
|
||||
|
||||
@@ -47,11 +47,11 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
|
||||
if(2 + partition.Start >= partition.End) return false;
|
||||
|
||||
byte[] mdb_sector = imagePlugin.ReadSector(2 + partition.Start);
|
||||
byte[] mdbSector = imagePlugin.ReadSector(2 + partition.Start);
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
drSigWord = BigEndianBitConverter.ToUInt16(mdb_sector, 0x000);
|
||||
drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000);
|
||||
|
||||
return drSigWord == MFS_MAGIC;
|
||||
}
|
||||
@@ -67,63 +67,62 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
MFS_BootBlock BB = new MFS_BootBlock();
|
||||
|
||||
byte[] pString = new byte[16];
|
||||
byte[] variable_size;
|
||||
|
||||
byte[] mdb_sector = imagePlugin.ReadSector(2 + partition.Start);
|
||||
byte[] bb_sector = imagePlugin.ReadSector(0 + partition.Start);
|
||||
byte[] mdbSector = imagePlugin.ReadSector(2 + partition.Start);
|
||||
byte[] bbSector = imagePlugin.ReadSector(0 + partition.Start);
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
MDB.drSigWord = BigEndianBitConverter.ToUInt16(mdb_sector, 0x000);
|
||||
MDB.drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000);
|
||||
if(MDB.drSigWord != MFS_MAGIC) return;
|
||||
|
||||
MDB.drCrDate = BigEndianBitConverter.ToUInt32(mdb_sector, 0x002);
|
||||
MDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdb_sector, 0x006);
|
||||
MDB.drAtrb = BigEndianBitConverter.ToUInt16(mdb_sector, 0x00A);
|
||||
MDB.drNmFls = BigEndianBitConverter.ToUInt16(mdb_sector, 0x00C);
|
||||
MDB.drDirSt = BigEndianBitConverter.ToUInt16(mdb_sector, 0x00E);
|
||||
MDB.drBlLen = BigEndianBitConverter.ToUInt16(mdb_sector, 0x010);
|
||||
MDB.drNmAlBlks = BigEndianBitConverter.ToUInt16(mdb_sector, 0x012);
|
||||
MDB.drAlBlkSiz = BigEndianBitConverter.ToUInt32(mdb_sector, 0x014);
|
||||
MDB.drClpSiz = BigEndianBitConverter.ToUInt32(mdb_sector, 0x018);
|
||||
MDB.drAlBlSt = BigEndianBitConverter.ToUInt16(mdb_sector, 0x01C);
|
||||
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);
|
||||
MDB.drVN = StringHandlers.PascalToString(variable_size, CurrentEncoding);
|
||||
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];
|
||||
byte[] variableSize = new byte[MDB.drVNSiz + 1];
|
||||
Array.Copy(mdbSector, 0x024, variableSize, 0, MDB.drVNSiz + 1);
|
||||
MDB.drVN = StringHandlers.PascalToString(variableSize, CurrentEncoding);
|
||||
|
||||
BB.signature = BigEndianBitConverter.ToUInt16(bb_sector, 0x000);
|
||||
BB.signature = BigEndianBitConverter.ToUInt16(bbSector, 0x000);
|
||||
|
||||
if(BB.signature == MFSBB_MAGIC)
|
||||
{
|
||||
BB.branch = BigEndianBitConverter.ToUInt32(bb_sector, 0x002);
|
||||
BB.boot_flags = bb_sector[0x006];
|
||||
BB.boot_version = bb_sector[0x007];
|
||||
BB.branch = BigEndianBitConverter.ToUInt32(bbSector, 0x002);
|
||||
BB.boot_flags = bbSector[0x006];
|
||||
BB.boot_version = bbSector[0x007];
|
||||
|
||||
BB.sec_sv_pages = BigEndianBitConverter.ToInt16(bb_sector, 0x008);
|
||||
BB.sec_sv_pages = BigEndianBitConverter.ToInt16(bbSector, 0x008);
|
||||
|
||||
Array.Copy(mdb_sector, 0x00A, pString, 0, 16);
|
||||
Array.Copy(mdbSector, 0x00A, pString, 0, 16);
|
||||
BB.system_name = StringHandlers.PascalToString(pString, CurrentEncoding);
|
||||
Array.Copy(mdb_sector, 0x01A, pString, 0, 16);
|
||||
Array.Copy(mdbSector, 0x01A, pString, 0, 16);
|
||||
BB.finder_name = StringHandlers.PascalToString(pString, CurrentEncoding);
|
||||
Array.Copy(mdb_sector, 0x02A, pString, 0, 16);
|
||||
Array.Copy(mdbSector, 0x02A, pString, 0, 16);
|
||||
BB.debug_name = StringHandlers.PascalToString(pString, CurrentEncoding);
|
||||
Array.Copy(mdb_sector, 0x03A, pString, 0, 16);
|
||||
Array.Copy(mdbSector, 0x03A, pString, 0, 16);
|
||||
BB.disasm_name = StringHandlers.PascalToString(pString, CurrentEncoding);
|
||||
Array.Copy(mdb_sector, 0x04A, pString, 0, 16);
|
||||
Array.Copy(mdbSector, 0x04A, pString, 0, 16);
|
||||
BB.stupscr_name = StringHandlers.PascalToString(pString, CurrentEncoding);
|
||||
Array.Copy(mdb_sector, 0x05A, pString, 0, 16);
|
||||
Array.Copy(mdbSector, 0x05A, pString, 0, 16);
|
||||
BB.bootup_name = StringHandlers.PascalToString(pString, CurrentEncoding);
|
||||
Array.Copy(mdb_sector, 0x06A, pString, 0, 16);
|
||||
Array.Copy(mdbSector, 0x06A, pString, 0, 16);
|
||||
BB.clipbrd_name = StringHandlers.PascalToString(pString, CurrentEncoding);
|
||||
|
||||
BB.max_files = BigEndianBitConverter.ToUInt16(bb_sector, 0x07A);
|
||||
BB.queue_size = BigEndianBitConverter.ToUInt16(bb_sector, 0x07C);
|
||||
BB.heap_128k = BigEndianBitConverter.ToUInt32(bb_sector, 0x07E);
|
||||
BB.heap_256k = BigEndianBitConverter.ToUInt32(bb_sector, 0x082);
|
||||
BB.heap_512k = BigEndianBitConverter.ToUInt32(bb_sector, 0x086);
|
||||
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);
|
||||
}
|
||||
else BB.signature = 0x0000;
|
||||
|
||||
@@ -175,26 +174,26 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
|
||||
information = sb.ToString();
|
||||
|
||||
xmlFSType = new FileSystemType();
|
||||
XmlFsType = new FileSystemType();
|
||||
if(MDB.drLsBkUp > 0)
|
||||
{
|
||||
xmlFSType.BackupDate = DateHandlers.MacToDateTime(MDB.drLsBkUp);
|
||||
xmlFSType.BackupDateSpecified = true;
|
||||
XmlFsType.BackupDate = DateHandlers.MacToDateTime(MDB.drLsBkUp);
|
||||
XmlFsType.BackupDateSpecified = true;
|
||||
}
|
||||
xmlFSType.Bootable = BB.signature == MFSBB_MAGIC;
|
||||
xmlFSType.Clusters = MDB.drNmAlBlks;
|
||||
xmlFSType.ClusterSize = (int)MDB.drAlBlkSiz;
|
||||
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.CreationDateSpecified = true;
|
||||
XmlFsType.CreationDate = DateHandlers.MacToDateTime(MDB.drCrDate);
|
||||
XmlFsType.CreationDateSpecified = true;
|
||||
}
|
||||
xmlFSType.Files = MDB.drNmFls;
|
||||
xmlFSType.FilesSpecified = true;
|
||||
xmlFSType.FreeClusters = MDB.drFreeBks;
|
||||
xmlFSType.FreeClustersSpecified = true;
|
||||
xmlFSType.Type = "MFS";
|
||||
xmlFSType.VolumeName = MDB.drVN;
|
||||
XmlFsType.Files = MDB.drNmFls;
|
||||
XmlFsType.FilesSpecified = true;
|
||||
XmlFsType.FreeClusters = MDB.drFreeBks;
|
||||
XmlFsType.FreeClustersSpecified = true;
|
||||
XmlFsType.Type = "MFS";
|
||||
XmlFsType.VolumeName = MDB.drVN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,14 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#pragma warning disable 169
|
||||
|
||||
namespace DiscImageChef.Filesystems.AppleMFS
|
||||
{
|
||||
// Information from Inside Macintosh Volume II
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
public partial class AppleMFS
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -44,8 +44,6 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
this.debug = debug;
|
||||
volMDB = new MFS_MasterDirectoryBlock();
|
||||
|
||||
byte[] variable_size;
|
||||
|
||||
mdbBlocks = device.ReadSector(2 + partitionStart);
|
||||
bootBlocks = device.ReadSector(0 + partitionStart);
|
||||
|
||||
@@ -67,19 +65,19 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
volMDB.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x01E);
|
||||
volMDB.drFreeBks = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x022);
|
||||
volMDB.drVNSiz = mdbBlocks[0x024];
|
||||
variable_size = new byte[volMDB.drVNSiz + 1];
|
||||
Array.Copy(mdbBlocks, 0x024, variable_size, 0, volMDB.drVNSiz + 1);
|
||||
volMDB.drVN = StringHandlers.PascalToString(variable_size, CurrentEncoding);
|
||||
byte[] variableSize = new byte[volMDB.drVNSiz + 1];
|
||||
Array.Copy(mdbBlocks, 0x024, variableSize, 0, volMDB.drVNSiz + 1);
|
||||
volMDB.drVN = StringHandlers.PascalToString(variableSize, CurrentEncoding);
|
||||
|
||||
directoryBlocks = device.ReadSectors(volMDB.drDirSt + partitionStart, volMDB.drBlLen);
|
||||
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;
|
||||
byte[] wholeMDB = device.ReadSectors(partitionStart + 2, (uint)sectorsInWholeMDB);
|
||||
const int BYTES_BEFORE_BLOCK_MAP = 64;
|
||||
int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP;
|
||||
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);
|
||||
Array.Copy(wholeMdb, BYTES_BEFORE_BLOCK_MAP, blockMapBytes, 0, blockMapBytes.Length);
|
||||
|
||||
int offset = 0;
|
||||
blockMap = new uint[volMDB.drNmAlBlks + 2 + 1];
|
||||
@@ -113,7 +111,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
bootTags = device.ReadSectorTag(0 + partitionStart, SectorTagType.AppleSectorTag);
|
||||
directoryTags = device.ReadSectorsTag(volMDB.drDirSt + partitionStart, volMDB.drBlLen,
|
||||
SectorTagType.AppleSectorTag);
|
||||
bitmapTags = device.ReadSectorsTag(partitionStart + 2, (uint)sectorsInWholeMDB,
|
||||
bitmapTags = device.ReadSectorsTag(partitionStart + 2, (uint)sectorsInWholeMdb,
|
||||
SectorTagType.AppleSectorTag);
|
||||
}
|
||||
|
||||
@@ -127,26 +125,26 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
|
||||
if(bbSig != MFSBB_MAGIC) bootBlocks = null;
|
||||
|
||||
xmlFSType = new FileSystemType();
|
||||
XmlFsType = new FileSystemType();
|
||||
if(volMDB.drLsBkUp > 0)
|
||||
{
|
||||
xmlFSType.BackupDate = DateHandlers.MacToDateTime(volMDB.drLsBkUp);
|
||||
xmlFSType.BackupDateSpecified = true;
|
||||
XmlFsType.BackupDate = DateHandlers.MacToDateTime(volMDB.drLsBkUp);
|
||||
XmlFsType.BackupDateSpecified = true;
|
||||
}
|
||||
xmlFSType.Bootable = bbSig == MFSBB_MAGIC;
|
||||
xmlFSType.Clusters = volMDB.drNmAlBlks;
|
||||
xmlFSType.ClusterSize = (int)volMDB.drAlBlkSiz;
|
||||
XmlFsType.Bootable = bbSig == MFSBB_MAGIC;
|
||||
XmlFsType.Clusters = volMDB.drNmAlBlks;
|
||||
XmlFsType.ClusterSize = (int)volMDB.drAlBlkSiz;
|
||||
if(volMDB.drCrDate > 0)
|
||||
{
|
||||
xmlFSType.CreationDate = DateHandlers.MacToDateTime(volMDB.drCrDate);
|
||||
xmlFSType.CreationDateSpecified = true;
|
||||
XmlFsType.CreationDate = DateHandlers.MacToDateTime(volMDB.drCrDate);
|
||||
XmlFsType.CreationDateSpecified = true;
|
||||
}
|
||||
xmlFSType.Files = volMDB.drNmFls;
|
||||
xmlFSType.FilesSpecified = true;
|
||||
xmlFSType.FreeClusters = volMDB.drFreeBks;
|
||||
xmlFSType.FreeClustersSpecified = true;
|
||||
xmlFSType.Type = "MFS";
|
||||
xmlFSType.VolumeName = volMDB.drVN;
|
||||
XmlFsType.Files = volMDB.drNmFls;
|
||||
XmlFsType.FilesSpecified = true;
|
||||
XmlFsType.FreeClusters = volMDB.drFreeBks;
|
||||
XmlFsType.FreeClustersSpecified = true;
|
||||
XmlFsType.Type = "MFS";
|
||||
XmlFsType.VolumeName = volMDB.drVN;
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
@@ -169,14 +167,16 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
|
||||
public override Errno StatFs(ref FileSystemInfo stat)
|
||||
{
|
||||
stat = new FileSystemInfo();
|
||||
stat.Blocks = volMDB.drNmAlBlks;
|
||||
stat.FilenameLength = 255;
|
||||
stat.Files = volMDB.drNmFls;
|
||||
stat.FreeBlocks = volMDB.drFreeBks;
|
||||
stat = new FileSystemInfo
|
||||
{
|
||||
Blocks = volMDB.drNmAlBlks,
|
||||
FilenameLength = 255,
|
||||
Files = volMDB.drNmFls,
|
||||
FreeBlocks = volMDB.drFreeBks,
|
||||
PluginId = PluginUuid,
|
||||
Type = "Apple MFS"
|
||||
};
|
||||
stat.FreeFiles = uint.MaxValue - stat.Files;
|
||||
stat.PluginId = PluginUUID;
|
||||
stat.Type = "Apple MFS";
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
@@ -61,12 +61,9 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
uint fileID;
|
||||
MFS_FileEntry entry;
|
||||
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint 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 MFS_FileEntry entry)) return Errno.NoSuchFile;
|
||||
|
||||
if(entry.flRLgLen > 0)
|
||||
{
|
||||
@@ -130,13 +127,11 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
}
|
||||
else return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
uint fileID;
|
||||
MFS_FileEntry entry;
|
||||
Errno error;
|
||||
|
||||
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out fileID)) return Errno.NoSuchFile;
|
||||
if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return Errno.NoSuchFile;
|
||||
|
||||
if(!idToEntry.TryGetValue(fileID, out entry)) return Errno.NoSuchFile;
|
||||
if(!idToEntry.TryGetValue(fileId, out MFS_FileEntry entry)) return Errno.NoSuchFile;
|
||||
|
||||
if(entry.flRLgLen > 0 &&
|
||||
string.Compare(xattr, "com.apple.ResourceFork", StringComparison.InvariantCulture) == 0)
|
||||
|
||||
Reference in New Issue
Block a user