Renamed project files and folders

This commit is contained in:
2020-02-26 19:10:46 +00:00
parent e133798583
commit f5b199e483
1417 changed files with 109 additions and 109 deletions

View File

@@ -0,0 +1,60 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Consts.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : U.C.S.D. Pascal filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// U.C.S.D. Pascal filesystem constants.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
namespace DiscImageChef.Filesystems.UCSDPascal
{
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
public partial class PascalPlugin
{
enum PascalFileKind : short
{
/// <summary>Disk volume entry</summary>
Volume = 0,
/// <summary>File containing bad blocks</summary>
Bad,
/// <summary>Code file, machine executable</summary>
Code,
/// <summary>Text file, human readable</summary>
Text,
/// <summary>Information file for debugger</summary>
Info,
/// <summary>Data file</summary>
Data,
/// <summary>Graphics vectors</summary>
Graf,
/// <summary>Graphics screen image</summary>
Foto,
/// <summary>Security, not used</summary>
Secure
}
}
}

View File

@@ -0,0 +1,63 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Dir.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : U.C.S.D. Pascal filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Methods to show the U.C.S.D. Pascal catalog as a directory.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using DiscImageChef.CommonTypes.Structs;
namespace DiscImageChef.Filesystems.UCSDPascal
{
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
public partial class PascalPlugin
{
public Errno ReadDir(string path, out List<string> contents)
{
contents = null;
if(!mounted) return Errno.AccessDenied;
if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
return Errno.NotSupported;
contents = fileEntries.Select(ent => StringHandlers.PascalToString(ent.Filename, Encoding)).ToList();
if(debug)
{
contents.Add("$");
contents.Add("$Boot");
}
contents.Sort();
return Errno.NoError;
}
}
}

View File

@@ -0,0 +1,170 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : File.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : U.C.S.D. Pascal filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Methods to handle files.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.Linq;
using DiscImageChef.CommonTypes.Structs;
namespace DiscImageChef.Filesystems.UCSDPascal
{
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
public partial class PascalPlugin
{
public Errno MapBlock(string path, long fileBlock, out long deviceBlock)
{
deviceBlock = 0;
return !mounted ? Errno.AccessDenied : Errno.NotImplemented;
}
public Errno GetAttributes(string path, out FileAttributes attributes)
{
attributes = new FileAttributes();
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
Errno error = GetFileEntry(path, out _);
if(error != Errno.NoError) return error;
attributes = FileAttributes.File;
return error;
}
public Errno Read(string path, long offset, long size, ref byte[] buf)
{
if(!mounted) return Errno.AccessDenied;
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
byte[] file;
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0))
file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ? catalogBlocks : bootBlocks;
else
{
Errno error = GetFileEntry(path, out PascalFileEntry entry);
if(error != Errno.NoError) return error;
byte[] tmp = device.ReadSectors((ulong)entry.FirstBlock * multiplier,
(uint)(entry.LastBlock - entry.FirstBlock) * multiplier);
file = new byte[(entry.LastBlock - entry.FirstBlock - 1) * device.Info.SectorSize * multiplier +
entry.LastBytes];
Array.Copy(tmp, 0, file, 0, file.Length);
}
if(offset >= file.Length) return Errno.EINVAL;
if(size + offset >= file.Length) size = file.Length - offset;
buf = new byte[size];
Array.Copy(file, offset, buf, 0, size);
return Errno.NoError;
}
public Errno Stat(string path, out FileEntryInfo stat)
{
stat = null;
string[] pathElements = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1) return Errno.NotSupported;
if(debug)
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0)
{
stat = new FileEntryInfo
{
Attributes = FileAttributes.System,
BlockSize = device.Info.SectorSize * multiplier,
Links = 1
};
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
{
stat.Blocks = catalogBlocks.Length / stat.BlockSize + catalogBlocks.Length % stat.BlockSize;
stat.Length = catalogBlocks.Length;
}
else
{
stat.Blocks = bootBlocks.Length / stat.BlockSize + catalogBlocks.Length % stat.BlockSize;
stat.Length = bootBlocks.Length;
}
return Errno.NoError;
}
Errno error = GetFileEntry(path, out PascalFileEntry entry);
if(error != Errno.NoError) return error;
stat = new FileEntryInfo
{
Attributes = FileAttributes.File,
Blocks = entry.LastBlock - entry.FirstBlock,
BlockSize = device.Info.SectorSize * multiplier,
LastWriteTimeUtc = DateHandlers.UcsdPascalToDateTime(entry.ModificationTime),
Length = (entry.LastBlock - entry.FirstBlock) * device.Info.SectorSize * multiplier +
entry.LastBytes,
Links = 1
};
return Errno.NoError;
}
Errno GetFileEntry(string path, out PascalFileEntry entry)
{
entry = new PascalFileEntry();
foreach(PascalFileEntry ent in fileEntries.Where(ent =>
string.Compare(path,
StringHandlers
.PascalToString(ent.Filename,
Encoding),
StringComparison
.InvariantCultureIgnoreCase) == 0))
{
entry = ent;
return Errno.NoError;
}
return Errno.NoSuchFile;
}
}
}

View File

@@ -0,0 +1,182 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Info.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : U.C.S.D. Pascal filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Identifies the U.C.S.D. Pascal filesystem and shows information.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.Text;
using Claunia.Encoding;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.Console;
using Schemas;
using Encoding = System.Text.Encoding;
namespace DiscImageChef.Filesystems.UCSDPascal
{
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
public partial class PascalPlugin
{
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
if(partition.Length < 3) return false;
multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
// Blocks 0 and 1 are boot code
byte[] volBlock = imagePlugin.ReadSectors(multiplier * 2 + partition.Start, multiplier);
// On Apple II, it's little endian
// TODO: Fix
/*BigEndianBitConverter.IsLittleEndian =
multiplier == 2 ? !BitConverter.IsLittleEndian : BitConverter.IsLittleEndian;*/
PascalVolumeEntry volEntry = new PascalVolumeEntry
{
FirstBlock = BigEndianBitConverter.ToInt16(volBlock, 0x00),
LastBlock = BigEndianBitConverter.ToInt16(volBlock, 0x02),
EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(volBlock, 0x04),
VolumeName = new byte[8],
Blocks = BigEndianBitConverter.ToInt16(volBlock, 0x0E),
Files = BigEndianBitConverter.ToInt16(volBlock, 0x10),
Dummy = BigEndianBitConverter.ToInt16(volBlock, 0x12),
LastBoot = BigEndianBitConverter.ToInt16(volBlock, 0x14),
Tail = BigEndianBitConverter.ToInt32(volBlock, 0x16)
};
Array.Copy(volBlock, 0x06, volEntry.VolumeName, 0, 8);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.firstBlock = {0}", volEntry.FirstBlock);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.lastBlock = {0}", volEntry.LastBlock);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.entryType = {0}", volEntry.EntryType);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.volumeName = {0}", volEntry.VolumeName);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.blocks = {0}", volEntry.Blocks);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.files = {0}", volEntry.Files);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.dummy = {0}", volEntry.Dummy);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.lastBoot = {0}", volEntry.LastBoot);
DicConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.tail = {0}", volEntry.Tail);
// First block is always 0 (even is it's sector 2)
if(volEntry.FirstBlock != 0) return false;
// Last volume record block must be after first block, and before end of device
if(volEntry.LastBlock <= volEntry.FirstBlock ||
(ulong)volEntry.LastBlock > imagePlugin.Info.Sectors / multiplier - 2) return false;
// Volume record entry type must be volume or secure
if(volEntry.EntryType != PascalFileKind.Volume && volEntry.EntryType != PascalFileKind.Secure) return false;
// Volume name is max 7 characters
if(volEntry.VolumeName[0] > 7) return false;
// Volume blocks is equal to volume sectors
if(volEntry.Blocks < 0 || (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / multiplier) return false;
// There can be not less than zero files
return volEntry.Files >= 0;
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
Encoding encoding)
{
Encoding = encoding ?? new Apple2();
StringBuilder sbInformation = new StringBuilder();
information = "";
multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
if(imagePlugin.Info.Sectors < 3) return;
// Blocks 0 and 1 are boot code
byte[] volBlock = imagePlugin.ReadSectors(multiplier * 2 + partition.Start, multiplier);
// On Apple //, it's little endian
// TODO: Fix
//BigEndianBitConverter.IsLittleEndian =
// multiplier == 2 ? !BitConverter.IsLittleEndian : BitConverter.IsLittleEndian;
PascalVolumeEntry volEntry = new PascalVolumeEntry
{
FirstBlock = BigEndianBitConverter.ToInt16(volBlock, 0x00),
LastBlock = BigEndianBitConverter.ToInt16(volBlock, 0x02),
EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(volBlock, 0x04),
VolumeName = new byte[8],
Blocks = BigEndianBitConverter.ToInt16(volBlock, 0x0E),
Files = BigEndianBitConverter.ToInt16(volBlock, 0x10),
Dummy = BigEndianBitConverter.ToInt16(volBlock, 0x12),
LastBoot = BigEndianBitConverter.ToInt16(volBlock, 0x14),
Tail = BigEndianBitConverter.ToInt32(volBlock, 0x16)
};
Array.Copy(volBlock, 0x06, volEntry.VolumeName, 0, 8);
// First block is always 0 (even is it's sector 2)
if(volEntry.FirstBlock != 0) return;
// Last volume record block must be after first block, and before end of device
if(volEntry.LastBlock <= volEntry.FirstBlock ||
(ulong)volEntry.LastBlock > imagePlugin.Info.Sectors / multiplier - 2) return;
// Volume record entry type must be volume or secure
if(volEntry.EntryType != PascalFileKind.Volume && volEntry.EntryType != PascalFileKind.Secure) return;
// Volume name is max 7 characters
if(volEntry.VolumeName[0] > 7) return;
// Volume blocks is equal to volume sectors
if(volEntry.Blocks < 0 || (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / multiplier) return;
// There can be not less than zero files
if(volEntry.Files < 0) return;
sbInformation.AppendFormat("Volume record spans from block {0} to block {1}", volEntry.FirstBlock,
volEntry.LastBlock).AppendLine();
sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(volEntry.VolumeName, Encoding))
.AppendLine();
sbInformation.AppendFormat("Volume has {0} blocks", volEntry.Blocks).AppendLine();
sbInformation.AppendFormat("Volume has {0} files", volEntry.Files).AppendLine();
sbInformation
.AppendFormat("Volume last booted at {0}", DateHandlers.UcsdPascalToDateTime(volEntry.LastBoot))
.AppendLine();
information = sbInformation.ToString();
XmlFsType = new FileSystemType
{
Bootable =
!ArrayHelpers.ArrayIsNullOrEmpty(imagePlugin.ReadSectors(partition.Start, multiplier * 2)),
Clusters = (ulong)volEntry.Blocks,
ClusterSize = imagePlugin.Info.SectorSize,
Files = (ulong)volEntry.Files,
FilesSpecified = true,
Type = "UCSD Pascal",
VolumeName = StringHandlers.PascalToString(volEntry.VolumeName, Encoding)
};
}
}
}

View File

@@ -0,0 +1,76 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Structs.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : U.C.S.D. Pascal filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// U.C.S.D. Pascal filesystem structures.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
namespace DiscImageChef.Filesystems.UCSDPascal
{
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
public partial class PascalPlugin
{
struct PascalVolumeEntry
{
/// <summary>0x00, first block of volume entry</summary>
public short FirstBlock;
/// <summary>0x02, last block of volume entry</summary>
public short LastBlock;
/// <summary>0x04, entry type</summary>
public PascalFileKind EntryType;
/// <summary>0x06, volume name</summary>
public byte[] VolumeName;
/// <summary>0x0E, block in volume</summary>
public short Blocks;
/// <summary>0x10, files in volume</summary>
public short Files;
/// <summary>0x12, dummy</summary>
public short Dummy;
/// <summary>0x14, last booted</summary>
public short LastBoot;
/// <summary>0x16, tail to make record same size as <see cref="PascalFileEntry" /></summary>
public int Tail;
}
struct PascalFileEntry
{
/// <summary>0x00, first block of file</summary>
public short FirstBlock;
/// <summary>0x02, last block of file</summary>
public short LastBlock;
/// <summary>0x04, entry type</summary>
public PascalFileKind EntryType;
/// <summary>0x06, file name</summary>
public byte[] Filename;
/// <summary>0x16, bytes used in last block</summary>
public short LastBytes;
/// <summary>0x18, modification time</summary>
public short ModificationTime;
}
}
}

View File

@@ -0,0 +1,157 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Super.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : U.C.S.D. Pascal filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Handles mounting and umounting the U.C.S.D. Pascal filesystem.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using Claunia.Encoding;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.CommonTypes.Structs;
using Schemas;
using Encoding = System.Text.Encoding;
namespace DiscImageChef.Filesystems.UCSDPascal
{
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
public partial class PascalPlugin
{
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
Dictionary<string, string> options, string @namespace)
{
device = imagePlugin;
Encoding = encoding ?? new Apple2();
if(options == null) options = GetDefaultOptions();
if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out debug);
if(device.Info.Sectors < 3) return Errno.InvalidArgument;
multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1);
// Blocks 0 and 1 are boot code
catalogBlocks = device.ReadSectors(multiplier * 2, multiplier);
// On Apple //, it's little endian
// TODO: Fix
//BigEndianBitConverter.IsLittleEndian =
// multiplier == 2 ? !BitConverter.IsLittleEndian : BitConverter.IsLittleEndian;
mountedVolEntry.FirstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, 0x00);
mountedVolEntry.LastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, 0x02);
mountedVolEntry.EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(catalogBlocks, 0x04);
mountedVolEntry.VolumeName = new byte[8];
Array.Copy(catalogBlocks, 0x06, mountedVolEntry.VolumeName, 0, 8);
mountedVolEntry.Blocks = BigEndianBitConverter.ToInt16(catalogBlocks, 0x0E);
mountedVolEntry.Files = BigEndianBitConverter.ToInt16(catalogBlocks, 0x10);
mountedVolEntry.Dummy = BigEndianBitConverter.ToInt16(catalogBlocks, 0x12);
mountedVolEntry.LastBoot = BigEndianBitConverter.ToInt16(catalogBlocks, 0x14);
mountedVolEntry.Tail = BigEndianBitConverter.ToInt32(catalogBlocks, 0x16);
if(mountedVolEntry.FirstBlock != 0 ||
mountedVolEntry.LastBlock <= mountedVolEntry.FirstBlock ||
(ulong)mountedVolEntry.LastBlock > device.Info.Sectors / multiplier - 2 ||
mountedVolEntry.EntryType != PascalFileKind.Volume &&
mountedVolEntry.EntryType != PascalFileKind.Secure || mountedVolEntry.VolumeName[0] > 7 ||
mountedVolEntry.Blocks < 0 ||
(ulong)mountedVolEntry.Blocks != device.Info.Sectors / multiplier ||
mountedVolEntry.Files < 0)
return Errno.InvalidArgument;
catalogBlocks = device.ReadSectors(multiplier * 2,
(uint)(mountedVolEntry.LastBlock - mountedVolEntry.FirstBlock - 2) *
multiplier);
int offset = 26;
fileEntries = new List<PascalFileEntry>();
while(offset + 26 < catalogBlocks.Length)
{
PascalFileEntry entry = new PascalFileEntry
{
Filename = new byte[16],
FirstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x00),
LastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x02),
EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x04),
LastBytes = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x16),
ModificationTime = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x18)
};
Array.Copy(catalogBlocks, offset + 0x06, entry.Filename, 0, 16);
if(entry.Filename[0] <= 15 && entry.Filename[0] > 0) fileEntries.Add(entry);
offset += 26;
}
bootBlocks = device.ReadSectors(0, 2 * multiplier);
XmlFsType = new FileSystemType
{
Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(bootBlocks),
Clusters = (ulong)mountedVolEntry.Blocks,
ClusterSize = device.Info.SectorSize,
Files = (ulong)mountedVolEntry.Files,
FilesSpecified = true,
Type = "UCSD Pascal",
VolumeName = StringHandlers.PascalToString(mountedVolEntry.VolumeName, Encoding)
};
mounted = true;
return Errno.NoError;
}
public Errno Unmount()
{
mounted = false;
fileEntries = null;
return Errno.NoError;
}
public Errno StatFs(out FileSystemInfo stat)
{
stat = new FileSystemInfo
{
Blocks = (ulong)mountedVolEntry.Blocks,
FilenameLength = 16,
Files = (ulong)mountedVolEntry.Files,
FreeBlocks = 0,
PluginId = Id,
Type = "UCSD Pascal"
};
stat.FreeBlocks =
(ulong)(mountedVolEntry.Blocks - (mountedVolEntry.LastBlock - mountedVolEntry.FirstBlock));
foreach(PascalFileEntry entry in fileEntries)
stat.FreeBlocks -= (ulong)(entry.LastBlock - entry.FirstBlock);
return Errno.NotImplemented;
}
}
}

View File

@@ -0,0 +1,85 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : UCSDPascal.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : U.C.S.D. Pascal filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Constructors and common variables for the U.C.S.D. Pascal filesystem plugin.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.CommonTypes.Structs;
using Schemas;
namespace DiscImageChef.Filesystems.UCSDPascal
{
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
public partial class PascalPlugin : IReadOnlyFilesystem
{
byte[] bootBlocks;
byte[] catalogBlocks;
bool debug;
IMediaImage device;
List<PascalFileEntry> fileEntries;
bool mounted;
PascalVolumeEntry mountedVolEntry;
/// <summary>Apple II disks use 256 bytes / sector, but filesystem assumes it's 512 bytes / sector</summary>
uint multiplier;
public FileSystemType XmlFsType { get; private set; }
public string Name => "U.C.S.D. Pascal filesystem";
public Guid Id => new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53");
public Encoding Encoding { get; private set; }
public string Author => "Natalia Portillo";
public Errno ListXAttr(string path, out List<string> xattrs)
{
xattrs = null;
return Errno.NotSupported;
}
public Errno GetXattr(string path, string xattr, ref byte[] buf) => Errno.NotSupported;
public Errno ReadLink(string path, out string dest)
{
dest = null;
return Errno.NotSupported;
}
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
new (string name, Type type, string description)[] { };
public Dictionary<string, string> Namespaces => null;
static Dictionary<string, string> GetDefaultOptions() =>
new Dictionary<string, string> {{"debug", false.ToString()}};
}
}