mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
🎨Converted all plugin types to interfaces.
This commit is contained in:
@@ -35,13 +35,15 @@ using System.Collections.Generic;
|
||||
using Claunia.Encoding;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.DiscImages;
|
||||
using Schemas;
|
||||
using Encoding = System.Text.Encoding;
|
||||
|
||||
namespace DiscImageChef.Filesystems.AppleDOS
|
||||
{
|
||||
public partial class AppleDOS : Filesystem
|
||||
public partial class AppleDOS : IFilesystem
|
||||
{
|
||||
readonly ImagePlugin device;
|
||||
IMediaImage device;
|
||||
Encoding currentEncoding;
|
||||
bool debug;
|
||||
bool mounted;
|
||||
int sectorsPerTrack;
|
||||
@@ -53,30 +55,11 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
|
||||
Vtoc vtoc;
|
||||
|
||||
public AppleDOS()
|
||||
{
|
||||
Name = "Apple DOS File System";
|
||||
PluginUuid = new Guid("8658A1E9-B2E7-4BCC-9638-157A31B0A700\n");
|
||||
CurrentEncoding = new LisaRoman();
|
||||
}
|
||||
|
||||
public AppleDOS(Encoding encoding)
|
||||
{
|
||||
Name = "Apple DOS File System";
|
||||
PluginUuid = new Guid("8658A1E9-B2E7-4BCC-9638-157A31B0A700\n");
|
||||
// TODO: Until Apple ][ encoding is implemented
|
||||
CurrentEncoding = new LisaRoman();
|
||||
}
|
||||
|
||||
public AppleDOS(ImagePlugin imagePlugin, Partition partition, Encoding encoding)
|
||||
{
|
||||
device = imagePlugin;
|
||||
start = partition.Start;
|
||||
Name = "Apple DOS File System";
|
||||
PluginUuid = new Guid("8658A1E9-B2E7-4BCC-9638-157A31B0A700\n");
|
||||
// TODO: Until Apple ][ encoding is implemented
|
||||
CurrentEncoding = new LisaRoman();
|
||||
}
|
||||
FileSystemType xmlFsType;
|
||||
public virtual FileSystemType XmlFsType => xmlFsType;
|
||||
public virtual Encoding Encoding => currentEncoding;
|
||||
public virtual string Name => "Apple DOS File System";
|
||||
public virtual Guid Id => new Guid("8658A1E9-B2E7-4BCC-9638-157A31B0A700\n");
|
||||
|
||||
#region Caches
|
||||
/// <summary>Caches track/sector lists</summary>
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
/// </summary>
|
||||
/// <param name="path">Link path.</param>
|
||||
/// <param name="dest">Link destination.</param>
|
||||
public override Errno ReadLink(string path, ref string dest)
|
||||
public virtual Errno ReadLink(string path, ref string dest)
|
||||
{
|
||||
return !mounted ? Errno.AccessDenied : Errno.NotSupported;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
/// </summary>
|
||||
/// <param name="path">Directory path.</param>
|
||||
/// <param name="contents">Directory contents.</param>
|
||||
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;
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
fileSizeCache = new Dictionary<string, int>();
|
||||
lockedFiles = new List<string>();
|
||||
|
||||
if(lba == 0 || lba > device.ImageInfo.Sectors) return Errno.InvalidArgument;
|
||||
if(lba == 0 || lba > device.Info.Sectors) return Errno.InvalidArgument;
|
||||
|
||||
while(lba != 0)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
// Apple DOS has high byte set over ASCII.
|
||||
for(int i = 0; i < 30; i++) filenameB[i] = (byte)(entry.filename[i] & 0x7F);
|
||||
|
||||
string filename = StringHandlers.SpacePaddedToString(filenameB, CurrentEncoding);
|
||||
string filename = StringHandlers.SpacePaddedToString(filenameB, currentEncoding);
|
||||
|
||||
if(!catalogCache.ContainsKey(filename)) catalogCache.Add(filename, ts);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
|
||||
lba = (ulong)(catSector.trackOfNext * sectorsPerTrack + catSector.sectorOfNext);
|
||||
|
||||
if(lba > device.ImageInfo.Sectors) break;
|
||||
if(lba > device.Info.Sectors) break;
|
||||
}
|
||||
|
||||
if(debug) catalogBlocks = catalogMs.ToArray();
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
{
|
||||
public partial class AppleDOS
|
||||
{
|
||||
public override Errno GetAttributes(string path, ref FileAttributes attributes)
|
||||
public virtual Errno GetAttributes(string path, ref FileAttributes attributes)
|
||||
{
|
||||
if(!mounted) return Errno.AccessDenied;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
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;
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
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;
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
public override Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
|
||||
public virtual Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
|
||||
{
|
||||
// TODO: Not really important.
|
||||
return !mounted ? Errno.AccessDenied : Errno.NotImplemented;
|
||||
|
||||
@@ -33,22 +33,24 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Claunia.Encoding;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.DiscImages;
|
||||
using Schemas;
|
||||
using Encoding = System.Text.Encoding;
|
||||
|
||||
namespace DiscImageChef.Filesystems.AppleDOS
|
||||
{
|
||||
public partial class AppleDOS
|
||||
{
|
||||
public override bool Identify(ImagePlugin imagePlugin, Partition partition)
|
||||
public virtual bool Identify(IMediaImage imagePlugin, Partition partition)
|
||||
{
|
||||
if(imagePlugin.ImageInfo.Sectors != 455 && imagePlugin.ImageInfo.Sectors != 560) return false;
|
||||
if(imagePlugin.Info.Sectors != 455 && imagePlugin.Info.Sectors != 560) return false;
|
||||
|
||||
if(partition.Start > 0 || imagePlugin.ImageInfo.SectorSize != 256) return false;
|
||||
if(partition.Start > 0 || imagePlugin.Info.SectorSize != 256) return false;
|
||||
|
||||
int spt;
|
||||
spt = imagePlugin.ImageInfo.Sectors == 455 ? 13 : 16;
|
||||
spt = imagePlugin.Info.Sectors == 455 ? 13 : 16;
|
||||
|
||||
byte[] vtocB = imagePlugin.ReadSector((ulong)(17 * spt));
|
||||
vtoc = new Vtoc();
|
||||
@@ -61,13 +63,15 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
vtoc.sectorsPerTrack == spt && vtoc.bytesPerSector == 256;
|
||||
}
|
||||
|
||||
public override void GetInformation(ImagePlugin imagePlugin, Partition partition, out string information)
|
||||
public virtual void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
||||
{
|
||||
// TODO: Until Apple ][ encoding is implemented
|
||||
currentEncoding = new LisaRoman();
|
||||
information = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
int spt;
|
||||
spt = imagePlugin.ImageInfo.Sectors == 455 ? 13 : 16;
|
||||
spt = imagePlugin.Info.Sectors == 455 ? 13 : 16;
|
||||
|
||||
byte[] vtocB = imagePlugin.ReadSector((ulong)(17 * spt));
|
||||
vtoc = new Vtoc();
|
||||
@@ -91,11 +95,11 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
|
||||
information = sb.ToString();
|
||||
|
||||
XmlFsType = new FileSystemType
|
||||
xmlFsType = new FileSystemType
|
||||
{
|
||||
Bootable = true,
|
||||
Clusters = (long)imagePlugin.ImageInfo.Sectors,
|
||||
ClusterSize = (int)imagePlugin.ImageInfo.SectorSize,
|
||||
Clusters = (long)imagePlugin.Info.Sectors,
|
||||
ClusterSize = (int)imagePlugin.Info.SectorSize,
|
||||
Type = "Apple DOS"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,8 +32,12 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Claunia.Encoding;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.DiscImages;
|
||||
using Schemas;
|
||||
using Encoding = System.Text.Encoding;
|
||||
|
||||
namespace DiscImageChef.Filesystems.AppleDOS
|
||||
{
|
||||
@@ -42,17 +46,14 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
/// <summary>
|
||||
/// Mounts an Apple DOS filesystem
|
||||
/// </summary>
|
||||
public override Errno Mount()
|
||||
public virtual Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, bool debug)
|
||||
{
|
||||
return Mount(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mounts an Apple DOS filesystem
|
||||
/// </summary>
|
||||
public override Errno Mount(bool debug)
|
||||
{
|
||||
if(device.ImageInfo.Sectors != 455 && device.ImageInfo.Sectors != 560)
|
||||
device = imagePlugin;
|
||||
start = partition.Start;
|
||||
// TODO: Until Apple ][ encoding is implemented
|
||||
currentEncoding = new LisaRoman();
|
||||
|
||||
if(device.Info.Sectors != 455 && device.Info.Sectors != 560)
|
||||
{
|
||||
DicConsole.DebugWriteLine("Apple DOS plugin", "Incorrect device size.");
|
||||
return Errno.InOutError;
|
||||
@@ -64,13 +65,13 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
return Errno.InOutError;
|
||||
}
|
||||
|
||||
if(device.ImageInfo.SectorSize != 256)
|
||||
if(device.Info.SectorSize != 256)
|
||||
{
|
||||
DicConsole.DebugWriteLine("Apple DOS plugin", "Incorrect sector size.");
|
||||
return Errno.InOutError;
|
||||
}
|
||||
|
||||
sectorsPerTrack = device.ImageInfo.Sectors == 455 ? 13 : 16;
|
||||
sectorsPerTrack = device.Info.Sectors == 455 ? 13 : 16;
|
||||
|
||||
// Read the VTOC
|
||||
vtocBlocks = device.ReadSector((ulong)(17 * sectorsPerTrack));
|
||||
@@ -99,17 +100,17 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
}
|
||||
|
||||
// Create XML metadata for mounted filesystem
|
||||
XmlFsType = new FileSystemType
|
||||
xmlFsType = new FileSystemType
|
||||
{
|
||||
Bootable = true,
|
||||
Clusters = (long)device.ImageInfo.Sectors,
|
||||
Clusters = (long)device.Info.Sectors,
|
||||
ClusterSize = vtoc.bytesPerSector,
|
||||
Files = catalogCache.Count,
|
||||
FilesSpecified = true,
|
||||
FreeClustersSpecified = true,
|
||||
Type = "Apple DOS"
|
||||
};
|
||||
XmlFsType.FreeClusters = XmlFsType.Clusters - usedSectors;
|
||||
xmlFsType.FreeClusters = xmlFsType.Clusters - usedSectors;
|
||||
|
||||
this.debug = debug;
|
||||
mounted = true;
|
||||
@@ -119,7 +120,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
/// <summary>
|
||||
/// Umounts this DOS filesystem
|
||||
/// </summary>
|
||||
public override Errno Unmount()
|
||||
public virtual Errno Unmount()
|
||||
{
|
||||
mounted = false;
|
||||
extentCache = null;
|
||||
@@ -134,14 +135,14 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
/// Gets information about the mounted volume.
|
||||
/// </summary>
|
||||
/// <param name="stat">Information about the mounted volume.</param>
|
||||
public override Errno StatFs(ref FileSystemInfo stat)
|
||||
public virtual Errno StatFs(ref FileSystemInfo stat)
|
||||
{
|
||||
stat = new FileSystemInfo
|
||||
{
|
||||
Blocks = (long)device.ImageInfo.Sectors,
|
||||
Blocks = (long)device.Info.Sectors,
|
||||
FilenameLength = 30,
|
||||
Files = (ulong)catalogCache.Count,
|
||||
PluginId = PluginUuid,
|
||||
PluginId = Id,
|
||||
Type = "Apple DOS"
|
||||
};
|
||||
stat.FreeFiles = totalFileEntries - stat.Files;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">Path.</param>
|
||||
/// <param name="xattrs">List of extended attributes, alternate data streams and forks.</param>
|
||||
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;
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="xattr">Extended attribute, alternate data stream or fork name.</param>
|
||||
/// <param name="buf">Buffer.</param>
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user