🎨Converted all plugin types to interfaces.

This commit is contained in:
2017-12-26 06:05:12 +00:00
parent a002253fa4
commit f66a0bdd42
295 changed files with 9499 additions and 10414 deletions

View File

@@ -35,15 +35,16 @@ using System.Collections.Generic;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.DiscImages;
using Schemas;
namespace DiscImageChef.Filesystems.AppleMFS
{
// Information from Inside Macintosh Volume II
public partial class AppleMFS : Filesystem
public partial class AppleMFS : IFilesystem
{
bool mounted;
bool debug;
ImagePlugin device;
IMediaImage device;
ulong partitionStart;
Dictionary<uint, string> idToFilename;
@@ -61,28 +62,29 @@ namespace DiscImageChef.Filesystems.AppleMFS
byte[] mdbTags;
byte[] directoryTags;
byte[] bitmapTags;
Encoding currentEncoding;
FileSystemType xmlFsType;
public virtual FileSystemType XmlFsType => xmlFsType;
public virtual string Name => "Apple Macintosh File System";
public virtual Guid Id => new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
public virtual Encoding Encoding => currentEncoding;
public AppleMFS()
{
Name = "Apple Macintosh File System";
PluginUuid = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
CurrentEncoding = Encoding.GetEncoding("macintosh");
currentEncoding = Encoding.GetEncoding("macintosh");
}
public AppleMFS(Encoding encoding)
{
Name = "Apple Macintosh File System";
PluginUuid = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
CurrentEncoding = encoding ?? Encoding.GetEncoding("macintosh");
currentEncoding = encoding ?? Encoding.GetEncoding("macintosh");
}
public AppleMFS(ImagePlugin imagePlugin, Partition partition, Encoding encoding)
public AppleMFS(IMediaImage imagePlugin, Partition partition, Encoding encoding)
{
Name = "Apple Macintosh File System";
PluginUuid = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A");
device = imagePlugin;
partitionStart = partition.Start;
CurrentEncoding = encoding ?? Encoding.GetEncoding("macintosh");
currentEncoding = encoding ?? Encoding.GetEncoding("macintosh");
}
}
}

View File

@@ -40,7 +40,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
// Information from Inside Macintosh Volume II
public partial class AppleMFS
{
public override Errno ReadDir(string path, ref List<string> contents)
public virtual Errno ReadDir(string path, ref List<string> contents)
{
if(!mounted) return Errno.AccessDenied;
@@ -92,7 +92,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
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, CurrentEncoding).ToLowerInvariant().Replace('/', ':');
.PascalToString(entry.flNam, currentEncoding).ToLowerInvariant().Replace('/', ':');
if(entry.flFlags.HasFlag(MFS_FileFlags.Used) && !idToFilename.ContainsKey(entry.flFlNum) &&
!idToEntry.ContainsKey(entry.flFlNum) && !filenameToId.ContainsKey(lowerFilename) &&
@@ -100,7 +100,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
idToEntry.Add(entry.flFlNum, entry);
idToFilename.Add(entry.flFlNum,
StringHandlers.PascalToString(entry.flNam, CurrentEncoding).Replace('/', ':'));
StringHandlers.PascalToString(entry.flNam, currentEncoding).Replace('/', ':'));
filenameToId.Add(lowerFilename, entry.flFlNum);
DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flFlags = {0}", entry.flFlags);
@@ -117,7 +117,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
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));
StringHandlers.PascalToString(entry.flNam, currentEncoding));
}
offset += 50 + entry.flNam.Length;

View File

@@ -40,7 +40,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
// Information from Inside Macintosh Volume II
public partial class AppleMFS
{
public override Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
public virtual Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
{
deviceBlock = new long();
@@ -75,7 +75,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.InOutError;
}
public override Errno GetAttributes(string path, ref FileAttributes attributes)
public virtual Errno GetAttributes(string path, ref FileAttributes attributes)
{
if(!mounted) return Errno.AccessDenied;
@@ -108,7 +108,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
public override Errno Read(string path, long offset, long size, ref byte[] buf)
public virtual Errno Read(string path, long offset, long size, ref byte[] buf)
{
if(!mounted) return Errno.AccessDenied;
@@ -142,7 +142,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
public override Errno Stat(string path, ref FileEntryInfo stat)
public virtual Errno Stat(string path, ref FileEntryInfo stat)
{
if(!mounted) return Errno.AccessDenied;
@@ -157,7 +157,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
{
stat = new FileEntryInfo
{
BlockSize = device.ImageInfo.SectorSize,
BlockSize = device.Info.SectorSize,
DeviceNo = 0,
GID = 0,
Inode = 0,
@@ -219,7 +219,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
public override Errno ReadLink(string path, ref string dest)
public virtual Errno ReadLink(string path, ref string dest)
{
return Errno.NotImplemented;
}

View File

@@ -41,7 +41,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
// Information from Inside Macintosh Volume II
public partial class AppleMFS
{
public override bool Identify(ImagePlugin imagePlugin, Partition partition)
public virtual bool Identify(IMediaImage imagePlugin, Partition partition)
{
ushort drSigWord;
@@ -56,7 +56,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return drSigWord == MFS_MAGIC;
}
public override void GetInformation(ImagePlugin imagePlugin, Partition partition, out string information)
public virtual void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
{
information = "";
@@ -90,7 +90,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
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);
MDB.drVN = StringHandlers.PascalToString(variableSize, currentEncoding);
BB.signature = BigEndianBitConverter.ToUInt16(bbSector, 0x000);
@@ -103,19 +103,19 @@ namespace DiscImageChef.Filesystems.AppleMFS
BB.sec_sv_pages = BigEndianBitConverter.ToInt16(bbSector, 0x008);
Array.Copy(mdbSector, 0x00A, pString, 0, 16);
BB.system_name = StringHandlers.PascalToString(pString, CurrentEncoding);
BB.system_name = StringHandlers.PascalToString(pString, currentEncoding);
Array.Copy(mdbSector, 0x01A, pString, 0, 16);
BB.finder_name = StringHandlers.PascalToString(pString, CurrentEncoding);
BB.finder_name = StringHandlers.PascalToString(pString, currentEncoding);
Array.Copy(mdbSector, 0x02A, pString, 0, 16);
BB.debug_name = StringHandlers.PascalToString(pString, CurrentEncoding);
BB.debug_name = StringHandlers.PascalToString(pString, currentEncoding);
Array.Copy(mdbSector, 0x03A, pString, 0, 16);
BB.disasm_name = StringHandlers.PascalToString(pString, CurrentEncoding);
BB.disasm_name = StringHandlers.PascalToString(pString, currentEncoding);
Array.Copy(mdbSector, 0x04A, pString, 0, 16);
BB.stupscr_name = StringHandlers.PascalToString(pString, CurrentEncoding);
BB.stupscr_name = StringHandlers.PascalToString(pString, currentEncoding);
Array.Copy(mdbSector, 0x05A, pString, 0, 16);
BB.bootup_name = StringHandlers.PascalToString(pString, CurrentEncoding);
BB.bootup_name = StringHandlers.PascalToString(pString, currentEncoding);
Array.Copy(mdbSector, 0x06A, pString, 0, 16);
BB.clipbrd_name = StringHandlers.PascalToString(pString, CurrentEncoding);
BB.clipbrd_name = StringHandlers.PascalToString(pString, currentEncoding);
BB.max_files = BigEndianBitConverter.ToUInt16(bbSector, 0x07A);
BB.queue_size = BigEndianBitConverter.ToUInt16(bbSector, 0x07C);
@@ -173,26 +173,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;
}
}
}

View File

@@ -31,6 +31,8 @@
// ****************************************************************************/
using System;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.DiscImages;
using Schemas;
@@ -39,8 +41,11 @@ namespace DiscImageChef.Filesystems.AppleMFS
// Information from Inside Macintosh Volume II
public partial class AppleMFS
{
public override Errno Mount(bool debug)
public virtual Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, bool debug)
{
device = imagePlugin;
partitionStart = partition.Start;
currentEncoding = encoding ?? Encoding.GetEncoding("macintosh");
this.debug = debug;
volMDB = new MFS_MasterDirectoryBlock();
@@ -67,14 +72,14 @@ namespace DiscImageChef.Filesystems.AppleMFS
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, CurrentEncoding);
volMDB.drVN = StringHandlers.PascalToString(variableSize, currentEncoding);
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.ImageInfo.SectorSize +
bytesInWholeMdb % (int)device.ImageInfo.SectorSize;
int sectorsInWholeMdb = bytesInWholeMdb / (int)device.Info.SectorSize +
bytesInWholeMdb % (int)device.Info.SectorSize;
byte[] wholeMdb = device.ReadSectors(partitionStart + 2, (uint)sectorsInWholeMdb);
blockMapBytes = new byte[bytesInBlockMap];
Array.Copy(wholeMdb, BYTES_BEFORE_BLOCK_MAP, blockMapBytes, 0, blockMapBytes.Length);
@@ -105,7 +110,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
offset += 12;
}
if(device.ImageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
{
mdbTags = device.ReadSectorTag(2 + partitionStart, SectorTagType.AppleSectorTag);
bootTags = device.ReadSectorTag(0 + partitionStart, SectorTagType.AppleSectorTag);
@@ -115,7 +120,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
SectorTagType.AppleSectorTag);
}
sectorsPerBlock = (int)(volMDB.drAlBlkSiz / device.ImageInfo.SectorSize);
sectorsPerBlock = (int)(volMDB.drAlBlkSiz / device.Info.SectorSize);
if(!FillDirectory()) return Errno.InvalidArgument;
@@ -125,36 +130,31 @@ 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;
}
public override Errno Mount()
{
return Mount(false);
}
public override Errno Unmount()
public virtual Errno Unmount()
{
mounted = false;
idToFilename = null;
@@ -165,7 +165,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
public override Errno StatFs(ref FileSystemInfo stat)
public virtual Errno StatFs(ref FileSystemInfo stat)
{
stat = new FileSystemInfo
{
@@ -173,7 +173,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
FilenameLength = 255,
Files = volMDB.drNmFls,
FreeBlocks = volMDB.drFreeBks,
PluginId = PluginUuid,
PluginId = Id,
Type = "Apple MFS"
};
stat.FreeFiles = uint.MaxValue - stat.Files;

View File

@@ -40,7 +40,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
// Information from Inside Macintosh Volume II
public partial class AppleMFS
{
public override Errno ListXAttr(string path, ref List<string> xattrs)
public virtual Errno ListXAttr(string path, ref List<string> xattrs)
{
if(!mounted) return Errno.AccessDenied;
@@ -55,7 +55,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
{
if(device.ImageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
xattrs.Add("com.apple.macintosh.tags");
return Errno.NoError;
@@ -68,13 +68,13 @@ namespace DiscImageChef.Filesystems.AppleMFS
if(entry.flRLgLen > 0)
{
xattrs.Add("com.apple.ResourceFork");
if(debug && device.ImageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
if(debug && device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
xattrs.Add("com.apple.ResourceFork.tags");
}
if(!ArrayHelpers.ArrayIsNullOrEmpty(entry.flUsrWds)) xattrs.Add("com.apple.FinderInfo");
if(debug && device.ImageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) && entry.flLgLen > 0)
if(debug && device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) && entry.flLgLen > 0)
xattrs.Add("com.apple.macintosh.tags");
xattrs.Sort();
@@ -82,7 +82,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
public override Errno GetXattr(string path, string xattr, ref byte[] buf)
public virtual Errno GetXattr(string path, string xattr, ref byte[] buf)
{
if(!mounted) return Errno.AccessDenied;
@@ -94,7 +94,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0)
if(device.ImageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) &&
if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) &&
string.Compare(xattr, "com.apple.macintosh.tags", StringComparison.InvariantCulture) == 0)
{
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
@@ -155,7 +155,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
return Errno.NoError;
}
if(!debug || !device.ImageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) ||
if(!debug || !device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) ||
string.Compare(xattr, "com.apple.macintosh.tags", StringComparison.InvariantCulture) != 0)
return Errno.NoSuchExtendedAttribute;