mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move to file scoped namespaces.
This commit is contained in:
@@ -37,74 +37,73 @@ using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.Filesystems
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements the CP/M filesystem</summary>
|
||||
public sealed partial class CPM : IReadOnlyFilesystem
|
||||
{
|
||||
/// <summary>True if <see cref="Identify" /> thinks this is a CP/M filesystem</summary>
|
||||
bool _cpmFound;
|
||||
|
||||
/// <summary>Cached <see cref="FileSystemInfo" /></summary>
|
||||
FileSystemInfo _cpmStat;
|
||||
|
||||
/// <summary>Cached file passwords, decoded</summary>
|
||||
Dictionary<string, byte[]> _decodedPasswordCache;
|
||||
|
||||
/// <summary>Stores all known CP/M disk definitions</summary>
|
||||
CpmDefinitions _definitions;
|
||||
IMediaImage _device;
|
||||
/// <summary>Cached directory listing</summary>
|
||||
List<string> _dirList;
|
||||
/// <summary>CP/M disc parameter block (on-memory)</summary>
|
||||
DiscParameterBlock _dpb;
|
||||
/// <summary>Cached file data</summary>
|
||||
Dictionary<string, byte[]> _fileCache;
|
||||
/// <summary>The volume label, if the CP/M filesystem contains one</summary>
|
||||
string _label;
|
||||
/// <summary>Timestamp in volume label for creation</summary>
|
||||
byte[] _labelCreationDate;
|
||||
/// <summary>Timestamp in volume label for update</summary>
|
||||
byte[] _labelUpdateDate;
|
||||
bool _mounted;
|
||||
/// <summary>Cached file passwords</summary>
|
||||
Dictionary<string, byte[]> _passwordCache;
|
||||
/// <summary>Sector deinterleaving mask</summary>
|
||||
int[] _sectorMask;
|
||||
/// <summary>True if there are CP/M 3 timestamps</summary>
|
||||
bool _standardTimestamps;
|
||||
/// <summary>Cached file <see cref="FileEntryInfo" /></summary>
|
||||
Dictionary<string, FileEntryInfo> _statCache;
|
||||
/// <summary>True if there are timestamps in Z80DOS or DOS+ format</summary>
|
||||
bool _thirdPartyTimestamps;
|
||||
/// <summary>If <see cref="Identify" /> thinks this is a CP/M filesystem, this is the definition for it</summary>
|
||||
CpmDefinition _workingDefinition;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements the CP/M filesystem</summary>
|
||||
public sealed partial class CPM : IReadOnlyFilesystem
|
||||
public FileSystemType XmlFsType { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public Encoding Encoding { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public string Name => "CP/M File System";
|
||||
/// <inheritdoc />
|
||||
public Guid Id => new("AA2B8585-41DF-4E3B-8A35-D1A935E2F8A1");
|
||||
/// <inheritdoc />
|
||||
public string Author => "Natalia Portillo";
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||
new (string name, Type type, string description)[]
|
||||
{};
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<string, string> Namespaces => null;
|
||||
|
||||
static Dictionary<string, string> GetDefaultOptions() => new()
|
||||
{
|
||||
/// <summary>True if <see cref="Identify" /> thinks this is a CP/M filesystem</summary>
|
||||
bool _cpmFound;
|
||||
|
||||
/// <summary>Cached <see cref="FileSystemInfo" /></summary>
|
||||
FileSystemInfo _cpmStat;
|
||||
|
||||
/// <summary>Cached file passwords, decoded</summary>
|
||||
Dictionary<string, byte[]> _decodedPasswordCache;
|
||||
|
||||
/// <summary>Stores all known CP/M disk definitions</summary>
|
||||
CpmDefinitions _definitions;
|
||||
IMediaImage _device;
|
||||
/// <summary>Cached directory listing</summary>
|
||||
List<string> _dirList;
|
||||
/// <summary>CP/M disc parameter block (on-memory)</summary>
|
||||
DiscParameterBlock _dpb;
|
||||
/// <summary>Cached file data</summary>
|
||||
Dictionary<string, byte[]> _fileCache;
|
||||
/// <summary>The volume label, if the CP/M filesystem contains one</summary>
|
||||
string _label;
|
||||
/// <summary>Timestamp in volume label for creation</summary>
|
||||
byte[] _labelCreationDate;
|
||||
/// <summary>Timestamp in volume label for update</summary>
|
||||
byte[] _labelUpdateDate;
|
||||
bool _mounted;
|
||||
/// <summary>Cached file passwords</summary>
|
||||
Dictionary<string, byte[]> _passwordCache;
|
||||
/// <summary>Sector deinterleaving mask</summary>
|
||||
int[] _sectorMask;
|
||||
/// <summary>True if there are CP/M 3 timestamps</summary>
|
||||
bool _standardTimestamps;
|
||||
/// <summary>Cached file <see cref="FileEntryInfo" /></summary>
|
||||
Dictionary<string, FileEntryInfo> _statCache;
|
||||
/// <summary>True if there are timestamps in Z80DOS or DOS+ format</summary>
|
||||
bool _thirdPartyTimestamps;
|
||||
/// <summary>If <see cref="Identify" /> thinks this is a CP/M filesystem, this is the definition for it</summary>
|
||||
CpmDefinition _workingDefinition;
|
||||
|
||||
/// <inheritdoc />
|
||||
public FileSystemType XmlFsType { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public Encoding Encoding { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public string Name => "CP/M File System";
|
||||
/// <inheritdoc />
|
||||
public Guid Id => new("AA2B8585-41DF-4E3B-8A35-D1A935E2F8A1");
|
||||
/// <inheritdoc />
|
||||
public string Author => "Natalia Portillo";
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||
new (string name, Type type, string description)[]
|
||||
{};
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<string, string> Namespaces => null;
|
||||
|
||||
static Dictionary<string, string> GetDefaultOptions() => new()
|
||||
{
|
||||
{
|
||||
"debug", false.ToString()
|
||||
}
|
||||
};
|
||||
}
|
||||
"debug", false.ToString()
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -32,33 +32,32 @@
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace Aaru.Filesystems
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
public sealed partial class CPM
|
||||
{
|
||||
public sealed partial class CPM
|
||||
/// <summary>Enumerates the format identification byte used by CP/M-86</summary>
|
||||
enum FormatByte : byte
|
||||
{
|
||||
/// <summary>Enumerates the format identification byte used by CP/M-86</summary>
|
||||
enum FormatByte : byte
|
||||
{
|
||||
/// <summary>5.25" double-density single-side 8 sectors/track</summary>
|
||||
k160 = 0,
|
||||
/// <summary>5.25" double-density double-side 8 sectors/track</summary>
|
||||
k320 = 1,
|
||||
/// <summary>5.25" double-density double-side 9 sectors/track</summary>
|
||||
k360 = 0x10,
|
||||
/// <summary>5.25" double-density double-side 9 sectors/track</summary>
|
||||
k360Alt = 0x40,
|
||||
/// <summary>3.5" double-density double-side 9 sectors/track</summary>
|
||||
k720 = 0x11,
|
||||
/// <summary>3.5" double-density double-side 9 sectors/track using FEAT144</summary>
|
||||
f720 = 0x48,
|
||||
/// <summary>5.25" high-density double-side 15 sectors/track using FEAT144</summary>
|
||||
f1200 = 0x0C,
|
||||
/// <summary>3.5" high-density double-side 18 sectors/track using FEAT144</summary>
|
||||
f1440 = 0x90,
|
||||
/// <summary>5.25" double-density double-side 9 sectors/track</summary>
|
||||
k360Alt2 = 0x26,
|
||||
/// <summary>3.5" double-density double-side 9 sectors/track</summary>
|
||||
k720Alt = 0x94
|
||||
}
|
||||
/// <summary>5.25" double-density single-side 8 sectors/track</summary>
|
||||
k160 = 0,
|
||||
/// <summary>5.25" double-density double-side 8 sectors/track</summary>
|
||||
k320 = 1,
|
||||
/// <summary>5.25" double-density double-side 9 sectors/track</summary>
|
||||
k360 = 0x10,
|
||||
/// <summary>5.25" double-density double-side 9 sectors/track</summary>
|
||||
k360Alt = 0x40,
|
||||
/// <summary>3.5" double-density double-side 9 sectors/track</summary>
|
||||
k720 = 0x11,
|
||||
/// <summary>3.5" double-density double-side 9 sectors/track using FEAT144</summary>
|
||||
f720 = 0x48,
|
||||
/// <summary>5.25" high-density double-side 15 sectors/track using FEAT144</summary>
|
||||
f1200 = 0x0C,
|
||||
/// <summary>3.5" high-density double-side 18 sectors/track using FEAT144</summary>
|
||||
f1440 = 0x90,
|
||||
/// <summary>5.25" double-density double-side 9 sectors/track</summary>
|
||||
k360Alt2 = 0x26,
|
||||
/// <summary>3.5" double-density double-side 9 sectors/track</summary>
|
||||
k720Alt = 0x94
|
||||
}
|
||||
}
|
||||
@@ -38,136 +38,135 @@ using System.Reflection;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Aaru.Filesystems
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
public sealed partial class CPM
|
||||
{
|
||||
public sealed partial class CPM
|
||||
/// <summary>Loads all the known CP/M disk definitions from an XML stored as an embedded resource.</summary>
|
||||
/// <returns>The definitions.</returns>
|
||||
bool LoadDefinitions()
|
||||
{
|
||||
/// <summary>Loads all the known CP/M disk definitions from an XML stored as an embedded resource.</summary>
|
||||
/// <returns>The definitions.</returns>
|
||||
bool LoadDefinitions()
|
||||
try
|
||||
{
|
||||
try
|
||||
var defsReader =
|
||||
XmlReader.Create(Assembly.GetExecutingAssembly().
|
||||
GetManifestResourceStream("Aaru.Filesystems.CPM.cpmdefs.xml") ??
|
||||
new MemoryStream());
|
||||
|
||||
var defsSerializer = new XmlSerializer(typeof(CpmDefinitions));
|
||||
_definitions = (CpmDefinitions)defsSerializer.Deserialize(defsReader);
|
||||
|
||||
// Patch definitions
|
||||
foreach(CpmDefinition def in _definitions.definitions)
|
||||
{
|
||||
var defsReader =
|
||||
XmlReader.Create(Assembly.GetExecutingAssembly().
|
||||
GetManifestResourceStream("Aaru.Filesystems.CPM.cpmdefs.xml") ??
|
||||
new MemoryStream());
|
||||
|
||||
var defsSerializer = new XmlSerializer(typeof(CpmDefinitions));
|
||||
_definitions = (CpmDefinitions)defsSerializer.Deserialize(defsReader);
|
||||
|
||||
// Patch definitions
|
||||
foreach(CpmDefinition def in _definitions.definitions)
|
||||
if(def.side1 == null)
|
||||
{
|
||||
if(def.side1 == null)
|
||||
def.side1 = new Side
|
||||
{
|
||||
def.side1 = new Side
|
||||
{
|
||||
sideId = 0,
|
||||
sectorIds = new int[def.sectorsPerTrack]
|
||||
};
|
||||
sideId = 0,
|
||||
sectorIds = new int[def.sectorsPerTrack]
|
||||
};
|
||||
|
||||
for(int i = 0; i < def.sectorsPerTrack; i++)
|
||||
def.side1.sectorIds[i] = i + 1;
|
||||
}
|
||||
|
||||
if(def.sides != 2 ||
|
||||
def.side2 != null)
|
||||
continue;
|
||||
|
||||
{
|
||||
def.side2 = new Side
|
||||
{
|
||||
sideId = 1,
|
||||
sectorIds = new int[def.sectorsPerTrack]
|
||||
};
|
||||
|
||||
for(int i = 0; i < def.sectorsPerTrack; i++)
|
||||
def.side2.sectorIds[i] = i + 1;
|
||||
}
|
||||
for(int i = 0; i < def.sectorsPerTrack; i++)
|
||||
def.side1.sectorIds[i] = i + 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
if(def.sides != 2 ||
|
||||
def.side2 != null)
|
||||
continue;
|
||||
|
||||
{
|
||||
def.side2 = new Side
|
||||
{
|
||||
sideId = 1,
|
||||
sectorIds = new int[def.sectorsPerTrack]
|
||||
};
|
||||
|
||||
for(int i = 0; i < def.sectorsPerTrack; i++)
|
||||
def.side2.sectorIds[i] = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>CP/M disk definitions</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public sealed class CpmDefinitions
|
||||
{
|
||||
/// <summary>Timestamp of creation of the CP/M disk definitions list</summary>
|
||||
public DateTime creation;
|
||||
/// <summary>List of all CP/M disk definitions</summary>
|
||||
public List<CpmDefinition> definitions;
|
||||
}
|
||||
/// <summary>CP/M disk definitions</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public sealed class CpmDefinitions
|
||||
{
|
||||
/// <summary>Timestamp of creation of the CP/M disk definitions list</summary>
|
||||
public DateTime creation;
|
||||
/// <summary>List of all CP/M disk definitions</summary>
|
||||
public List<CpmDefinition> definitions;
|
||||
}
|
||||
|
||||
/// <summary>CP/M disk definition</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public sealed class CpmDefinition
|
||||
{
|
||||
/// <summary>Maps the first 16 allocation blocks for reservation, high byte</summary>
|
||||
public int al0;
|
||||
/// <summary>Maps the first 16 allocation blocks for reservation, low byte</summary>
|
||||
public int al1;
|
||||
/// <summary>Controller bitrate</summary>
|
||||
public string bitrate;
|
||||
/// <summary>Block mask for <see cref="bsh" /></summary>
|
||||
public int blm;
|
||||
/// <summary>Left shifts needed to translate allocation block number to lba</summary>
|
||||
public int bsh;
|
||||
/// <summary>Physical bytes per sector</summary>
|
||||
public int bytesPerSector;
|
||||
/// <summary>Comment and description</summary>
|
||||
public string comment;
|
||||
/// <summary>If true, all bytes written on disk are negated</summary>
|
||||
public bool complement;
|
||||
/// <summary>Total cylinders</summary>
|
||||
public int cylinders;
|
||||
/// <summary>Total number of available directory entries</summary>
|
||||
public int drm;
|
||||
/// <summary>Total number of 128 byte records on disk</summary>
|
||||
public int dsm;
|
||||
/// <summary>Encoding, "FM", "MFM", "GCR"</summary>
|
||||
public string encoding;
|
||||
/// <summary>Absolutely unknown?</summary>
|
||||
public bool evenOdd;
|
||||
/// <summary>Extent mask</summary>
|
||||
public int exm;
|
||||
/// <summary>Disk definition label</summary>
|
||||
public string label;
|
||||
/// <summary>Tracks at the beginning of disk reserved for BIOS/BDOS</summary>
|
||||
public int ofs;
|
||||
/// <summary>
|
||||
/// Cylinder/side ordering. SIDES = change side after each track, CYLINDERS = change side after whole side, EAGLE
|
||||
/// and COLUMBIA unknown
|
||||
/// </summary>
|
||||
public string order;
|
||||
/// <summary>Physical sectors per side</summary>
|
||||
public int sectorsPerTrack;
|
||||
/// <summary>Description of controller's side 0 (usually, upper side)</summary>
|
||||
public Side side1;
|
||||
/// <summary>Description of controller's side 1 (usually, lower side)</summary>
|
||||
public Side side2;
|
||||
/// <summary>Total sides</summary>
|
||||
public int sides;
|
||||
/// <summary>Physical sector interleaving</summary>
|
||||
public int skew;
|
||||
/// <summary>Sectors at the beginning of disk reserved for BIOS/BDOS</summary>
|
||||
public int sofs;
|
||||
}
|
||||
/// <summary>CP/M disk definition</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public sealed class CpmDefinition
|
||||
{
|
||||
/// <summary>Maps the first 16 allocation blocks for reservation, high byte</summary>
|
||||
public int al0;
|
||||
/// <summary>Maps the first 16 allocation blocks for reservation, low byte</summary>
|
||||
public int al1;
|
||||
/// <summary>Controller bitrate</summary>
|
||||
public string bitrate;
|
||||
/// <summary>Block mask for <see cref="bsh" /></summary>
|
||||
public int blm;
|
||||
/// <summary>Left shifts needed to translate allocation block number to lba</summary>
|
||||
public int bsh;
|
||||
/// <summary>Physical bytes per sector</summary>
|
||||
public int bytesPerSector;
|
||||
/// <summary>Comment and description</summary>
|
||||
public string comment;
|
||||
/// <summary>If true, all bytes written on disk are negated</summary>
|
||||
public bool complement;
|
||||
/// <summary>Total cylinders</summary>
|
||||
public int cylinders;
|
||||
/// <summary>Total number of available directory entries</summary>
|
||||
public int drm;
|
||||
/// <summary>Total number of 128 byte records on disk</summary>
|
||||
public int dsm;
|
||||
/// <summary>Encoding, "FM", "MFM", "GCR"</summary>
|
||||
public string encoding;
|
||||
/// <summary>Absolutely unknown?</summary>
|
||||
public bool evenOdd;
|
||||
/// <summary>Extent mask</summary>
|
||||
public int exm;
|
||||
/// <summary>Disk definition label</summary>
|
||||
public string label;
|
||||
/// <summary>Tracks at the beginning of disk reserved for BIOS/BDOS</summary>
|
||||
public int ofs;
|
||||
/// <summary>
|
||||
/// Cylinder/side ordering. SIDES = change side after each track, CYLINDERS = change side after whole side, EAGLE
|
||||
/// and COLUMBIA unknown
|
||||
/// </summary>
|
||||
public string order;
|
||||
/// <summary>Physical sectors per side</summary>
|
||||
public int sectorsPerTrack;
|
||||
/// <summary>Description of controller's side 0 (usually, upper side)</summary>
|
||||
public Side side1;
|
||||
/// <summary>Description of controller's side 1 (usually, lower side)</summary>
|
||||
public Side side2;
|
||||
/// <summary>Total sides</summary>
|
||||
public int sides;
|
||||
/// <summary>Physical sector interleaving</summary>
|
||||
public int skew;
|
||||
/// <summary>Sectors at the beginning of disk reserved for BIOS/BDOS</summary>
|
||||
public int sofs;
|
||||
}
|
||||
|
||||
/// <summary>Side descriptions</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public sealed class Side
|
||||
{
|
||||
/// <summary>Software interleaving mask, [1,3,0,2] means CP/M LBA 0 is physical sector 1, LBA 1 = 3, so on</summary>
|
||||
public int[] sectorIds;
|
||||
/// <summary>Side ID as found in each sector address mark</summary>
|
||||
public int sideId;
|
||||
}
|
||||
/// <summary>Side descriptions</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public sealed class Side
|
||||
{
|
||||
/// <summary>Software interleaving mask, [1,3,0,2] means CP/M LBA 0 is physical sector 1, LBA 1 = 3, so on</summary>
|
||||
public int[] sectorIds;
|
||||
/// <summary>Side ID as found in each sector address mark</summary>
|
||||
public int sideId;
|
||||
}
|
||||
@@ -37,93 +37,92 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.Filesystems
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
public sealed partial class CPM
|
||||
{
|
||||
public sealed partial class CPM
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadDir(string path, out List<string> contents)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadDir(string path, out List<string> contents)
|
||||
contents = null;
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
if(!string.IsNullOrEmpty(path) &&
|
||||
string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
contents = new List<string>(_dirList);
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks that the given directory blocks follow the CP/M filesystem directory specification Corrupted
|
||||
/// directories will fail. FAT directories will false positive if all files start with 0x05, and do not use full
|
||||
/// extensions, for example: "σAFILE.GZ" (using code page 437)
|
||||
/// </summary>
|
||||
/// <returns>False if the directory does not follow the directory specification</returns>
|
||||
/// <param name="directory">Directory blocks.</param>
|
||||
bool CheckDir(byte[] directory)
|
||||
{
|
||||
try
|
||||
{
|
||||
contents = null;
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
if(!string.IsNullOrEmpty(path) &&
|
||||
string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
contents = new List<string>(_dirList);
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks that the given directory blocks follow the CP/M filesystem directory specification Corrupted
|
||||
/// directories will fail. FAT directories will false positive if all files start with 0x05, and do not use full
|
||||
/// extensions, for example: "σAFILE.GZ" (using code page 437)
|
||||
/// </summary>
|
||||
/// <returns>False if the directory does not follow the directory specification</returns>
|
||||
/// <param name="directory">Directory blocks.</param>
|
||||
bool CheckDir(byte[] directory)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(directory == null)
|
||||
return false;
|
||||
|
||||
int fileCount = 0;
|
||||
|
||||
for(int off = 0; off < directory.Length; off += 32)
|
||||
{
|
||||
DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(directory, off, 32);
|
||||
|
||||
if((entry.statusUser & 0x7F) < 0x20)
|
||||
{
|
||||
for(int f = 0; f < 8; f++)
|
||||
if(entry.filename[f] < 0x20 &&
|
||||
entry.filename[f] != 0x00)
|
||||
return false;
|
||||
|
||||
for(int e = 0; e < 3; e++)
|
||||
if(entry.extension[e] < 0x20 &&
|
||||
entry.extension[e] != 0x00)
|
||||
return false;
|
||||
|
||||
if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(entry.filename))
|
||||
fileCount++;
|
||||
}
|
||||
else if(entry.statusUser == 0x20)
|
||||
{
|
||||
for(int f = 0; f < 8; f++)
|
||||
if(entry.filename[f] < 0x20 &&
|
||||
entry.filename[f] != 0x00)
|
||||
return false;
|
||||
|
||||
for(int e = 0; e < 3; e++)
|
||||
if(entry.extension[e] < 0x20 &&
|
||||
entry.extension[e] != 0x00)
|
||||
return false;
|
||||
|
||||
_label = Encoding.ASCII.GetString(directory, off + 1, 11).Trim();
|
||||
_labelCreationDate = new byte[4];
|
||||
_labelUpdateDate = new byte[4];
|
||||
Array.Copy(directory, off + 24, _labelCreationDate, 0, 4);
|
||||
Array.Copy(directory, off + 28, _labelUpdateDate, 0, 4);
|
||||
}
|
||||
else if(entry.statusUser == 0x21)
|
||||
if(directory[off + 1] == 0x00)
|
||||
_thirdPartyTimestamps = true;
|
||||
else
|
||||
_standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00;
|
||||
}
|
||||
|
||||
return fileCount > 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if(directory == null)
|
||||
return false;
|
||||
|
||||
int fileCount = 0;
|
||||
|
||||
for(int off = 0; off < directory.Length; off += 32)
|
||||
{
|
||||
DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian<DirectoryEntry>(directory, off, 32);
|
||||
|
||||
if((entry.statusUser & 0x7F) < 0x20)
|
||||
{
|
||||
for(int f = 0; f < 8; f++)
|
||||
if(entry.filename[f] < 0x20 &&
|
||||
entry.filename[f] != 0x00)
|
||||
return false;
|
||||
|
||||
for(int e = 0; e < 3; e++)
|
||||
if(entry.extension[e] < 0x20 &&
|
||||
entry.extension[e] != 0x00)
|
||||
return false;
|
||||
|
||||
if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(entry.filename))
|
||||
fileCount++;
|
||||
}
|
||||
else if(entry.statusUser == 0x20)
|
||||
{
|
||||
for(int f = 0; f < 8; f++)
|
||||
if(entry.filename[f] < 0x20 &&
|
||||
entry.filename[f] != 0x00)
|
||||
return false;
|
||||
|
||||
for(int e = 0; e < 3; e++)
|
||||
if(entry.extension[e] < 0x20 &&
|
||||
entry.extension[e] != 0x00)
|
||||
return false;
|
||||
|
||||
_label = Encoding.ASCII.GetString(directory, off + 1, 11).Trim();
|
||||
_labelCreationDate = new byte[4];
|
||||
_labelUpdateDate = new byte[4];
|
||||
Array.Copy(directory, off + 24, _labelCreationDate, 0, 4);
|
||||
Array.Copy(directory, off + 28, _labelUpdateDate, 0, 4);
|
||||
}
|
||||
else if(entry.statusUser == 0x21)
|
||||
if(directory[off + 1] == 0x00)
|
||||
_thirdPartyTimestamps = true;
|
||||
else
|
||||
_standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00;
|
||||
}
|
||||
|
||||
return fileCount > 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,133 +35,132 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.Filesystems
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
public sealed partial class CPM
|
||||
{
|
||||
public sealed partial class CPM
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber GetAttributes(string path, out FileAttributes attributes)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber GetAttributes(string path, out FileAttributes attributes)
|
||||
attributes = new FileAttributes();
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
if(string.IsNullOrEmpty(pathElements[0]) ||
|
||||
string.Compare(pathElements[0], "/", StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
attributes = new FileAttributes();
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
if(string.IsNullOrEmpty(pathElements[0]) ||
|
||||
string.Compare(pathElements[0], "/", StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
attributes = new FileAttributes();
|
||||
attributes = FileAttributes.Directory;
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
if(!_statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out FileEntryInfo fInfo))
|
||||
return ErrorNumber.NoSuchFile;
|
||||
|
||||
attributes = fInfo.Attributes;
|
||||
attributes = FileAttributes.Directory;
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
// TODO: Implementing this would require storing the interleaving
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock)
|
||||
if(!_statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out FileEntryInfo fInfo))
|
||||
return ErrorNumber.NoSuchFile;
|
||||
|
||||
attributes = fInfo.Attributes;
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
// TODO: Implementing this would require storing the interleaving
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock)
|
||||
{
|
||||
deviceBlock = 0;
|
||||
|
||||
return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotImplemented;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber Read(string path, long offset, long size, ref byte[] buf)
|
||||
{
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
if(size == 0)
|
||||
{
|
||||
deviceBlock = 0;
|
||||
|
||||
return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotImplemented;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber Read(string path, long offset, long size, ref byte[] buf)
|
||||
{
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
if(size == 0)
|
||||
{
|
||||
buf = Array.Empty<byte>();
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
if(offset < 0)
|
||||
return ErrorNumber.InvalidArgument;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
if(!_fileCache.TryGetValue(pathElements[0].ToUpperInvariant(), out byte[] file))
|
||||
return ErrorNumber.NoSuchFile;
|
||||
|
||||
if(offset >= file.Length)
|
||||
return ErrorNumber.EINVAL;
|
||||
|
||||
if(size + offset >= file.Length)
|
||||
size = file.Length - offset;
|
||||
|
||||
buf = new byte[size];
|
||||
Array.Copy(file, offset, buf, 0, size);
|
||||
buf = Array.Empty<byte>();
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadLink(string path, out string dest)
|
||||
if(offset < 0)
|
||||
return ErrorNumber.InvalidArgument;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
dest = null;
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotSupported;
|
||||
}
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber Stat(string path, out FileEntryInfo stat)
|
||||
if(!_fileCache.TryGetValue(pathElements[0].ToUpperInvariant(), out byte[] file))
|
||||
return ErrorNumber.NoSuchFile;
|
||||
|
||||
if(offset >= file.Length)
|
||||
return ErrorNumber.EINVAL;
|
||||
|
||||
if(size + offset >= file.Length)
|
||||
size = file.Length - offset;
|
||||
|
||||
buf = new byte[size];
|
||||
Array.Copy(file, offset, buf, 0, size);
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadLink(string path, out string dest)
|
||||
{
|
||||
dest = null;
|
||||
|
||||
return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotSupported;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber Stat(string path, out FileEntryInfo stat)
|
||||
{
|
||||
stat = null;
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
stat = null;
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(!string.IsNullOrEmpty(path) &&
|
||||
string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
|
||||
return _statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat) ? ErrorNumber.NoError
|
||||
: ErrorNumber.NoSuchFile;
|
||||
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
stat = new FileEntryInfo
|
||||
{
|
||||
Attributes = FileAttributes.Directory,
|
||||
BlockSize = XmlFsType.ClusterSize
|
||||
};
|
||||
|
||||
if(!string.IsNullOrEmpty(path) &&
|
||||
string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
|
||||
return _statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat) ? ErrorNumber.NoError
|
||||
: ErrorNumber.NoSuchFile;
|
||||
if(_labelCreationDate != null)
|
||||
stat.CreationTime = DateHandlers.CpmToDateTime(_labelCreationDate);
|
||||
|
||||
stat = new FileEntryInfo
|
||||
{
|
||||
Attributes = FileAttributes.Directory,
|
||||
BlockSize = XmlFsType.ClusterSize
|
||||
};
|
||||
if(_labelUpdateDate != null)
|
||||
stat.StatusChangeTime = DateHandlers.CpmToDateTime(_labelUpdateDate);
|
||||
|
||||
if(_labelCreationDate != null)
|
||||
stat.CreationTime = DateHandlers.CpmToDateTime(_labelCreationDate);
|
||||
|
||||
if(_labelUpdateDate != null)
|
||||
stat.StatusChangeTime = DateHandlers.CpmToDateTime(_labelUpdateDate);
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,336 +35,335 @@ using System.Runtime.InteropServices;
|
||||
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
|
||||
namespace Aaru.Filesystems
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
public sealed partial class CPM
|
||||
{
|
||||
public sealed partial class CPM
|
||||
/// <summary>Most of the times this structure is hard wired or generated by CP/M, not stored on disk</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
class DiscParameterBlock
|
||||
{
|
||||
/// <summary>Most of the times this structure is hard wired or generated by CP/M, not stored on disk</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
class DiscParameterBlock
|
||||
{
|
||||
/// <summary>First byte of allocation bitmap</summary>
|
||||
public byte al0;
|
||||
/// <summary>Second byte of allocation bitmap</summary>
|
||||
public byte al1;
|
||||
/// <summary>Block mask</summary>
|
||||
public byte blm;
|
||||
/// <summary>Block shift</summary>
|
||||
public byte bsh;
|
||||
/// <summary>Checksum vector size</summary>
|
||||
public ushort cks;
|
||||
/// <summary>Directory entries - 1</summary>
|
||||
public ushort drm;
|
||||
/// <summary>Blocks on disk - 1</summary>
|
||||
public ushort dsm;
|
||||
/// <summary>Extent mask</summary>
|
||||
public byte exm;
|
||||
/// <summary>Reserved tracks</summary>
|
||||
public ushort off;
|
||||
/// <summary>Physical sector mask</summary>
|
||||
public byte phm;
|
||||
/// <summary>Physical sector shift</summary>
|
||||
public byte psh;
|
||||
/// <summary>Sectors per track</summary>
|
||||
public ushort spt;
|
||||
}
|
||||
/// <summary>First byte of allocation bitmap</summary>
|
||||
public byte al0;
|
||||
/// <summary>Second byte of allocation bitmap</summary>
|
||||
public byte al1;
|
||||
/// <summary>Block mask</summary>
|
||||
public byte blm;
|
||||
/// <summary>Block shift</summary>
|
||||
public byte bsh;
|
||||
/// <summary>Checksum vector size</summary>
|
||||
public ushort cks;
|
||||
/// <summary>Directory entries - 1</summary>
|
||||
public ushort drm;
|
||||
/// <summary>Blocks on disk - 1</summary>
|
||||
public ushort dsm;
|
||||
/// <summary>Extent mask</summary>
|
||||
public byte exm;
|
||||
/// <summary>Reserved tracks</summary>
|
||||
public ushort off;
|
||||
/// <summary>Physical sector mask</summary>
|
||||
public byte phm;
|
||||
/// <summary>Physical sector shift</summary>
|
||||
public byte psh;
|
||||
/// <summary>Sectors per track</summary>
|
||||
public ushort spt;
|
||||
}
|
||||
|
||||
/// <summary>Amstrad superblock, for PCW</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct AmstradSuperBlock
|
||||
{
|
||||
/// <summary>Format ID. 0 single-side, 3 double-side. 1 and 2 are for CPC but they don't use the superblock</summary>
|
||||
public readonly byte format;
|
||||
/// <summary>Gives information about side ordering</summary>
|
||||
public readonly byte sidedness;
|
||||
/// <summary>Tracks per side, aka, cylinders</summary>
|
||||
public readonly byte tps;
|
||||
/// <summary>Sectors per track</summary>
|
||||
public readonly byte spt;
|
||||
/// <summary>Physical sector shift</summary>
|
||||
public readonly byte psh;
|
||||
/// <summary>Reserved tracks</summary>
|
||||
public readonly byte off;
|
||||
/// <summary>Block size shift</summary>
|
||||
public readonly byte bsh;
|
||||
/// <summary>How many blocks does the directory take</summary>
|
||||
public readonly byte dirBlocks;
|
||||
/// <summary>GAP#3 length (intersector)</summary>
|
||||
public readonly byte gapLen;
|
||||
/// <summary>GAP#4 length (end-of-track)</summary>
|
||||
public readonly byte formatGap;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero1;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero2;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero3;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero4;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero5;
|
||||
/// <summary>Indicates machine the boot code following the superblock is designed to boot</summary>
|
||||
public readonly byte fiddle;
|
||||
}
|
||||
/// <summary>Amstrad superblock, for PCW</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct AmstradSuperBlock
|
||||
{
|
||||
/// <summary>Format ID. 0 single-side, 3 double-side. 1 and 2 are for CPC but they don't use the superblock</summary>
|
||||
public readonly byte format;
|
||||
/// <summary>Gives information about side ordering</summary>
|
||||
public readonly byte sidedness;
|
||||
/// <summary>Tracks per side, aka, cylinders</summary>
|
||||
public readonly byte tps;
|
||||
/// <summary>Sectors per track</summary>
|
||||
public readonly byte spt;
|
||||
/// <summary>Physical sector shift</summary>
|
||||
public readonly byte psh;
|
||||
/// <summary>Reserved tracks</summary>
|
||||
public readonly byte off;
|
||||
/// <summary>Block size shift</summary>
|
||||
public readonly byte bsh;
|
||||
/// <summary>How many blocks does the directory take</summary>
|
||||
public readonly byte dirBlocks;
|
||||
/// <summary>GAP#3 length (intersector)</summary>
|
||||
public readonly byte gapLen;
|
||||
/// <summary>GAP#4 length (end-of-track)</summary>
|
||||
public readonly byte formatGap;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero1;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero2;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero3;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero4;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly byte zero5;
|
||||
/// <summary>Indicates machine the boot code following the superblock is designed to boot</summary>
|
||||
public readonly byte fiddle;
|
||||
}
|
||||
|
||||
/// <summary>Superblock found on CP/M-86 hard disk volumes</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct HardDiskSuperBlock
|
||||
{
|
||||
/// <summary>Value so the sum of all the superblock's sector bytes taken as 16-bit values gives 0</summary>
|
||||
public readonly ushort checksum;
|
||||
/// <summary>Copyright string</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x1F)]
|
||||
public readonly byte[] copyright;
|
||||
/// <summary>First cylinder of disk where this volume resides</summary>
|
||||
public readonly ushort firstCylinder;
|
||||
/// <summary>How many cylinders does this volume span</summary>
|
||||
public readonly ushort cylinders;
|
||||
/// <summary>Heads on hard disk</summary>
|
||||
public readonly byte heads;
|
||||
/// <summary>Sectors per track</summary>
|
||||
public readonly byte sectorsPerTrack;
|
||||
/// <summary>Flags, only use by CCP/M where bit 0 equals verify on write</summary>
|
||||
public readonly byte flags;
|
||||
/// <summary>Sector size / 128</summary>
|
||||
public readonly byte recordsPerSector;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.spt" />
|
||||
/// </summary>
|
||||
public readonly ushort spt;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.bsh" />
|
||||
/// </summary>
|
||||
public readonly byte bsh;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.blm" />
|
||||
/// </summary>
|
||||
public readonly byte blm;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.exm" />
|
||||
/// </summary>
|
||||
public readonly byte exm;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.dsm" />
|
||||
/// </summary>
|
||||
public readonly ushort dsm;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.drm" />
|
||||
/// </summary>
|
||||
public readonly ushort drm;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.al0" />
|
||||
/// </summary>
|
||||
public readonly ushort al0;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.al1" />
|
||||
/// </summary>
|
||||
public readonly ushort al1;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.cks" />
|
||||
/// </summary>
|
||||
public readonly ushort cks;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.off" />
|
||||
/// </summary>
|
||||
public readonly ushort off;
|
||||
/// <summary>Must be zero</summary>
|
||||
public readonly ushort zero1;
|
||||
/// <summary>Must be zero</summary>
|
||||
public readonly ushort zero2;
|
||||
/// <summary>Must be zero</summary>
|
||||
public readonly ushort zero3;
|
||||
/// <summary>Must be zero</summary>
|
||||
public readonly ushort zero4;
|
||||
/// <summary>How many 128 bytes are in a block</summary>
|
||||
public readonly ushort recordsPerBlock;
|
||||
/// <summary>Maximum number of bad blocks in the bad block list</summary>
|
||||
public readonly ushort badBlockWordsMax;
|
||||
/// <summary>Used number of bad blocks in the bad block list</summary>
|
||||
public readonly ushort badBlockWords;
|
||||
/// <summary>First block after the blocks reserved for bad block substitution</summary>
|
||||
public readonly ushort firstSub;
|
||||
}
|
||||
/// <summary>Superblock found on CP/M-86 hard disk volumes</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct HardDiskSuperBlock
|
||||
{
|
||||
/// <summary>Value so the sum of all the superblock's sector bytes taken as 16-bit values gives 0</summary>
|
||||
public readonly ushort checksum;
|
||||
/// <summary>Copyright string</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x1F)]
|
||||
public readonly byte[] copyright;
|
||||
/// <summary>First cylinder of disk where this volume resides</summary>
|
||||
public readonly ushort firstCylinder;
|
||||
/// <summary>How many cylinders does this volume span</summary>
|
||||
public readonly ushort cylinders;
|
||||
/// <summary>Heads on hard disk</summary>
|
||||
public readonly byte heads;
|
||||
/// <summary>Sectors per track</summary>
|
||||
public readonly byte sectorsPerTrack;
|
||||
/// <summary>Flags, only use by CCP/M where bit 0 equals verify on write</summary>
|
||||
public readonly byte flags;
|
||||
/// <summary>Sector size / 128</summary>
|
||||
public readonly byte recordsPerSector;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.spt" />
|
||||
/// </summary>
|
||||
public readonly ushort spt;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.bsh" />
|
||||
/// </summary>
|
||||
public readonly byte bsh;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.blm" />
|
||||
/// </summary>
|
||||
public readonly byte blm;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.exm" />
|
||||
/// </summary>
|
||||
public readonly byte exm;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.dsm" />
|
||||
/// </summary>
|
||||
public readonly ushort dsm;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.drm" />
|
||||
/// </summary>
|
||||
public readonly ushort drm;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.al0" />
|
||||
/// </summary>
|
||||
public readonly ushort al0;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.al1" />
|
||||
/// </summary>
|
||||
public readonly ushort al1;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.cks" />
|
||||
/// </summary>
|
||||
public readonly ushort cks;
|
||||
/// <summary>
|
||||
/// <see cref="DiscParameterBlock.off" />
|
||||
/// </summary>
|
||||
public readonly ushort off;
|
||||
/// <summary>Must be zero</summary>
|
||||
public readonly ushort zero1;
|
||||
/// <summary>Must be zero</summary>
|
||||
public readonly ushort zero2;
|
||||
/// <summary>Must be zero</summary>
|
||||
public readonly ushort zero3;
|
||||
/// <summary>Must be zero</summary>
|
||||
public readonly ushort zero4;
|
||||
/// <summary>How many 128 bytes are in a block</summary>
|
||||
public readonly ushort recordsPerBlock;
|
||||
/// <summary>Maximum number of bad blocks in the bad block list</summary>
|
||||
public readonly ushort badBlockWordsMax;
|
||||
/// <summary>Used number of bad blocks in the bad block list</summary>
|
||||
public readonly ushort badBlockWords;
|
||||
/// <summary>First block after the blocks reserved for bad block substitution</summary>
|
||||
public readonly ushort firstSub;
|
||||
}
|
||||
|
||||
/// <summary>Volume label entry</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct LabelEntry
|
||||
{
|
||||
/// <summary>Must be 0x20</summary>
|
||||
public readonly byte signature;
|
||||
/// <summary>Label in ASCII</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
|
||||
public readonly byte[] label;
|
||||
/// <summary>
|
||||
/// Label flags. Bit 0 = label exists, bit 4 = creation timestamp, bit 5 = modification timestamp, bit 6 = access
|
||||
/// timestamp, bit 7 = password enabled
|
||||
/// </summary>
|
||||
public readonly byte flags;
|
||||
/// <summary>Password decoder byte</summary>
|
||||
public readonly byte passwordDecoder;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly ushort reserved;
|
||||
/// <summary>Password XOR'ed with <see cref="passwordDecoder" /></summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] password;
|
||||
/// <summary>Label creation time</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] ctime;
|
||||
/// <summary>Label modification time</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] mtime;
|
||||
}
|
||||
/// <summary>Volume label entry</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct LabelEntry
|
||||
{
|
||||
/// <summary>Must be 0x20</summary>
|
||||
public readonly byte signature;
|
||||
/// <summary>Label in ASCII</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
|
||||
public readonly byte[] label;
|
||||
/// <summary>
|
||||
/// Label flags. Bit 0 = label exists, bit 4 = creation timestamp, bit 5 = modification timestamp, bit 6 = access
|
||||
/// timestamp, bit 7 = password enabled
|
||||
/// </summary>
|
||||
public readonly byte flags;
|
||||
/// <summary>Password decoder byte</summary>
|
||||
public readonly byte passwordDecoder;
|
||||
/// <summary>Must be 0</summary>
|
||||
public readonly ushort reserved;
|
||||
/// <summary>Password XOR'ed with <see cref="passwordDecoder" /></summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] password;
|
||||
/// <summary>Label creation time</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] ctime;
|
||||
/// <summary>Label modification time</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] mtime;
|
||||
}
|
||||
|
||||
/// <summary>CP/M 3 timestamp entry</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct DateEntry
|
||||
{
|
||||
/// <summary>Must be 0x21</summary>
|
||||
public readonly byte signature;
|
||||
/// <summary>File 1 create/access timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date1;
|
||||
/// <summary>File 1 modification timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date2;
|
||||
/// <summary>File 1 password mode</summary>
|
||||
public readonly byte mode1;
|
||||
public readonly byte zero1;
|
||||
/// <summary>File 2 create/access timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date3;
|
||||
/// <summary>File 2 modification timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date4;
|
||||
/// <summary>File 2 password mode</summary>
|
||||
public readonly byte mode2;
|
||||
public readonly byte zero2;
|
||||
/// <summary>File 3 create/access timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date5;
|
||||
/// <summary>File 3 modification timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date6;
|
||||
/// <summary>File 3 password mode</summary>
|
||||
public readonly byte mode3;
|
||||
public readonly ushort zero3;
|
||||
}
|
||||
/// <summary>CP/M 3 timestamp entry</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct DateEntry
|
||||
{
|
||||
/// <summary>Must be 0x21</summary>
|
||||
public readonly byte signature;
|
||||
/// <summary>File 1 create/access timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date1;
|
||||
/// <summary>File 1 modification timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date2;
|
||||
/// <summary>File 1 password mode</summary>
|
||||
public readonly byte mode1;
|
||||
public readonly byte zero1;
|
||||
/// <summary>File 2 create/access timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date3;
|
||||
/// <summary>File 2 modification timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date4;
|
||||
/// <summary>File 2 password mode</summary>
|
||||
public readonly byte mode2;
|
||||
public readonly byte zero2;
|
||||
/// <summary>File 3 create/access timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date5;
|
||||
/// <summary>File 3 modification timestamp</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] date6;
|
||||
/// <summary>File 3 password mode</summary>
|
||||
public readonly byte mode3;
|
||||
public readonly ushort zero3;
|
||||
}
|
||||
|
||||
/// <summary>Password entry</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct PasswordEntry
|
||||
{
|
||||
/// <summary>16 + user number</summary>
|
||||
public readonly byte userNumber;
|
||||
/// <summary>Filename</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] filename;
|
||||
/// <summary>Extension</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public readonly byte[] extension;
|
||||
/// <summary>Password mode. Bit 7 = required for read, bit 6 = required for write, bit 5 = required for delete</summary>
|
||||
public readonly byte mode;
|
||||
/// <summary>Password decoder byte</summary>
|
||||
public readonly byte passwordDecoder;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly byte[] reserved;
|
||||
/// <summary>Password XOR'ed with <see cref="passwordDecoder" /></summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] password;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] reserved2;
|
||||
}
|
||||
/// <summary>Password entry</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct PasswordEntry
|
||||
{
|
||||
/// <summary>16 + user number</summary>
|
||||
public readonly byte userNumber;
|
||||
/// <summary>Filename</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] filename;
|
||||
/// <summary>Extension</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public readonly byte[] extension;
|
||||
/// <summary>Password mode. Bit 7 = required for read, bit 6 = required for write, bit 5 = required for delete</summary>
|
||||
public readonly byte mode;
|
||||
/// <summary>Password decoder byte</summary>
|
||||
public readonly byte passwordDecoder;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly byte[] reserved;
|
||||
/// <summary>Password XOR'ed with <see cref="passwordDecoder" /></summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] password;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] reserved2;
|
||||
}
|
||||
|
||||
/// <summary>Timestamp for Z80DOS or DOS+</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct TrdPartyDateEntry
|
||||
{
|
||||
/// <summary>Must be 0x21</summary>
|
||||
public readonly byte signature;
|
||||
public readonly byte zero;
|
||||
/// <summary>Creation year for file 1</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly byte[] create1;
|
||||
/// <summary>Modification time for file 1</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] modify1;
|
||||
/// <summary>Access time for file 1</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] access1;
|
||||
/// <summary>Creation year for file 2</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly byte[] create2;
|
||||
/// <summary>Modification time for file 2</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] modify2;
|
||||
/// <summary>Access time for file 2</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] access2;
|
||||
/// <summary>Creation year for file 3</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly byte[] create3;
|
||||
/// <summary>Modification time for file 3</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] modify3;
|
||||
/// <summary>Access time for file 3</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] access3;
|
||||
}
|
||||
/// <summary>Timestamp for Z80DOS or DOS+</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct TrdPartyDateEntry
|
||||
{
|
||||
/// <summary>Must be 0x21</summary>
|
||||
public readonly byte signature;
|
||||
public readonly byte zero;
|
||||
/// <summary>Creation year for file 1</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly byte[] create1;
|
||||
/// <summary>Modification time for file 1</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] modify1;
|
||||
/// <summary>Access time for file 1</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] access1;
|
||||
/// <summary>Creation year for file 2</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly byte[] create2;
|
||||
/// <summary>Modification time for file 2</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] modify2;
|
||||
/// <summary>Access time for file 2</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] access2;
|
||||
/// <summary>Creation year for file 3</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly byte[] create3;
|
||||
/// <summary>Modification time for file 3</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] modify3;
|
||||
/// <summary>Access time for file 3</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] access3;
|
||||
}
|
||||
|
||||
/// <summary>Directory entry for <256 allocation blocks</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct DirectoryEntry
|
||||
{
|
||||
/// <summary>User number. Bit 7 set in CP/M 1 means hidden</summary>
|
||||
public readonly byte statusUser;
|
||||
/// <summary>Filename and bit 7 as flags</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] filename;
|
||||
/// <summary>Extension and bit 7 as flags</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public readonly byte[] extension;
|
||||
/// <summary>Low byte of extent number</summary>
|
||||
public readonly byte extentCounter;
|
||||
/// <summary>
|
||||
/// Last record bytes. In some implementations it means how many bytes are used in the last record, in others how
|
||||
/// many bytes are free. It always refer to 128 byte records even if blocks are way bigger, so it's mostly useless.
|
||||
/// </summary>
|
||||
public readonly byte lastRecordBytes;
|
||||
/// <summary>High byte of extent number</summary>
|
||||
public readonly byte extentCounterHigh;
|
||||
/// <summary>How many records are used in this entry. 0x80 if all are used.</summary>
|
||||
public readonly byte records;
|
||||
/// <summary>Allocation blocks</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public readonly byte[] allocations;
|
||||
}
|
||||
/// <summary>Directory entry for <256 allocation blocks</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct DirectoryEntry
|
||||
{
|
||||
/// <summary>User number. Bit 7 set in CP/M 1 means hidden</summary>
|
||||
public readonly byte statusUser;
|
||||
/// <summary>Filename and bit 7 as flags</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] filename;
|
||||
/// <summary>Extension and bit 7 as flags</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public readonly byte[] extension;
|
||||
/// <summary>Low byte of extent number</summary>
|
||||
public readonly byte extentCounter;
|
||||
/// <summary>
|
||||
/// Last record bytes. In some implementations it means how many bytes are used in the last record, in others how
|
||||
/// many bytes are free. It always refer to 128 byte records even if blocks are way bigger, so it's mostly useless.
|
||||
/// </summary>
|
||||
public readonly byte lastRecordBytes;
|
||||
/// <summary>High byte of extent number</summary>
|
||||
public readonly byte extentCounterHigh;
|
||||
/// <summary>How many records are used in this entry. 0x80 if all are used.</summary>
|
||||
public readonly byte records;
|
||||
/// <summary>Allocation blocks</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public readonly byte[] allocations;
|
||||
}
|
||||
|
||||
/// <summary>Directory entry for >256 allocation blocks</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct DirectoryEntry16
|
||||
{
|
||||
/// <summary>User number. Bit 7 set in CP/M 1 means hidden</summary>
|
||||
public readonly byte statusUser;
|
||||
/// <summary>Filename and bit 7 as flags</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] filename;
|
||||
/// <summary>Extension and bit 7 as flags</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public readonly byte[] extension;
|
||||
/// <summary>Low byte of extent number</summary>
|
||||
public readonly byte extentCounter;
|
||||
/// <summary>
|
||||
/// Last record bytes. In some implementations it means how many bytes are used in the last record, in others how
|
||||
/// many bytes are free. It always refer to 128 byte records even if blocks are way bigger, so it's mostly useless.
|
||||
/// </summary>
|
||||
public readonly byte lastRecordBytes;
|
||||
/// <summary>High byte of extent number</summary>
|
||||
public readonly byte extentCounterHigh;
|
||||
/// <summary>How many records are used in this entry. 0x80 if all are used.</summary>
|
||||
public readonly byte records;
|
||||
/// <summary>Allocation blocks</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly ushort[] allocations;
|
||||
}
|
||||
/// <summary>Directory entry for >256 allocation blocks</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct DirectoryEntry16
|
||||
{
|
||||
/// <summary>User number. Bit 7 set in CP/M 1 means hidden</summary>
|
||||
public readonly byte statusUser;
|
||||
/// <summary>Filename and bit 7 as flags</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly byte[] filename;
|
||||
/// <summary>Extension and bit 7 as flags</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public readonly byte[] extension;
|
||||
/// <summary>Low byte of extent number</summary>
|
||||
public readonly byte extentCounter;
|
||||
/// <summary>
|
||||
/// Last record bytes. In some implementations it means how many bytes are used in the last record, in others how
|
||||
/// many bytes are free. It always refer to 128 byte records even if blocks are way bigger, so it's mostly useless.
|
||||
/// </summary>
|
||||
public readonly byte lastRecordBytes;
|
||||
/// <summary>High byte of extent number</summary>
|
||||
public readonly byte extentCounterHigh;
|
||||
/// <summary>How many records are used in this entry. 0x80 if all are used.</summary>
|
||||
public readonly byte records;
|
||||
/// <summary>Allocation blocks</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public readonly ushort[] allocations;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,66 +34,65 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
|
||||
namespace Aaru.Filesystems
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
public sealed partial class CPM
|
||||
{
|
||||
public sealed partial class CPM
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf)
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant()))
|
||||
return ErrorNumber.NoSuchFile;
|
||||
|
||||
if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant()))
|
||||
return ErrorNumber.NoSuchFile;
|
||||
if(string.Compare(xattr, "com.caldera.cpm.password", StringComparison.InvariantCulture) == 0)
|
||||
if(!_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf))
|
||||
return ErrorNumber.NoError;
|
||||
|
||||
if(string.Compare(xattr, "com.caldera.cpm.password", StringComparison.InvariantCulture) == 0)
|
||||
if(!_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf))
|
||||
return ErrorNumber.NoError;
|
||||
if(string.Compare(xattr, "com.caldera.cpm.password.text", StringComparison.InvariantCulture) != 0)
|
||||
return ErrorNumber.NoSuchExtendedAttribute;
|
||||
|
||||
if(string.Compare(xattr, "com.caldera.cpm.password.text", StringComparison.InvariantCulture) != 0)
|
||||
return ErrorNumber.NoSuchExtendedAttribute;
|
||||
return !_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf) ? ErrorNumber.NoError
|
||||
: ErrorNumber.NoSuchExtendedAttribute;
|
||||
}
|
||||
|
||||
return !_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf) ? ErrorNumber.NoError
|
||||
: ErrorNumber.NoSuchExtendedAttribute;
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ListXAttr(string path, out List<string> xattrs)
|
||||
{
|
||||
xattrs = null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ListXAttr(string path, out List<string> xattrs)
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
xattrs = null;
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if(!_mounted)
|
||||
return ErrorNumber.AccessDenied;
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
|
||||
string[] pathElements = path.Split(new[]
|
||||
{
|
||||
'/'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant()))
|
||||
return ErrorNumber.NoSuchFile;
|
||||
|
||||
if(pathElements.Length != 1)
|
||||
return ErrorNumber.NotSupported;
|
||||
xattrs = new List<string>();
|
||||
|
||||
if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant()))
|
||||
return ErrorNumber.NoSuchFile;
|
||||
if(_passwordCache.ContainsKey(pathElements[0].ToUpperInvariant()))
|
||||
xattrs.Add("com.caldera.cpm.password");
|
||||
|
||||
xattrs = new List<string>();
|
||||
if(_decodedPasswordCache.ContainsKey(pathElements[0].ToUpperInvariant()))
|
||||
xattrs.Add("com.caldera.cpm.password.text");
|
||||
|
||||
if(_passwordCache.ContainsKey(pathElements[0].ToUpperInvariant()))
|
||||
xattrs.Add("com.caldera.cpm.password");
|
||||
|
||||
if(_decodedPasswordCache.ContainsKey(pathElements[0].ToUpperInvariant()))
|
||||
xattrs.Add("com.caldera.cpm.password.text");
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user