mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Final cleanup of DiscImageChef.Filesystems.
This commit is contained in:
@@ -41,39 +41,18 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
{
|
||||
public partial class AppleDOS : Filesystem
|
||||
{
|
||||
bool mounted;
|
||||
bool debug;
|
||||
readonly ImagePlugin device;
|
||||
|
||||
#region Caches
|
||||
/// <summary>Caches track/sector lists</summary>
|
||||
Dictionary<string, byte[]> extentCache;
|
||||
/// <summary>Caches files</summary>
|
||||
Dictionary<string, byte[]> fileCache;
|
||||
/// <summary>Caches catalog</summary>
|
||||
Dictionary<string, ushort> catalogCache;
|
||||
/// <summary>Caches file size</summary>
|
||||
Dictionary<string, int> fileSizeCache;
|
||||
/// <summary>Caches VTOC</summary>
|
||||
byte[] vtocBlocks;
|
||||
/// <summary>Caches catalog</summary>
|
||||
byte[] catalogBlocks;
|
||||
/// <summary>Caches boot code</summary>
|
||||
byte[] bootBlocks;
|
||||
/// <summary>Caches file type</summary>
|
||||
Dictionary<string, byte> fileTypeCache;
|
||||
/// <summary>Caches locked files</summary>
|
||||
List<string> lockedFiles;
|
||||
#endregion Caches
|
||||
|
||||
Vtoc vtoc;
|
||||
ulong start;
|
||||
bool debug;
|
||||
bool mounted;
|
||||
int sectorsPerTrack;
|
||||
ulong start;
|
||||
ulong totalFileEntries;
|
||||
bool track1UsedByFiles;
|
||||
bool track2UsedByFiles;
|
||||
int usedSectors;
|
||||
|
||||
Vtoc vtoc;
|
||||
|
||||
public AppleDOS()
|
||||
{
|
||||
Name = "Apple DOS File System";
|
||||
@@ -98,5 +77,26 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
// TODO: Until Apple ][ encoding is implemented
|
||||
CurrentEncoding = new LisaRoman();
|
||||
}
|
||||
|
||||
#region Caches
|
||||
/// <summary>Caches track/sector lists</summary>
|
||||
Dictionary<string, byte[]> extentCache;
|
||||
/// <summary>Caches files</summary>
|
||||
Dictionary<string, byte[]> fileCache;
|
||||
/// <summary>Caches catalog</summary>
|
||||
Dictionary<string, ushort> catalogCache;
|
||||
/// <summary>Caches file size</summary>
|
||||
Dictionary<string, int> fileSizeCache;
|
||||
/// <summary>Caches VTOC</summary>
|
||||
byte[] vtocBlocks;
|
||||
/// <summary>Caches catalog</summary>
|
||||
byte[] catalogBlocks;
|
||||
/// <summary>Caches boot code</summary>
|
||||
byte[] bootBlocks;
|
||||
/// <summary>Caches file type</summary>
|
||||
Dictionary<string, byte> fileTypeCache;
|
||||
/// <summary>Caches locked files</summary>
|
||||
List<string> lockedFiles;
|
||||
#endregion Caches
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
public partial class AppleDOS
|
||||
{
|
||||
/// <summary>
|
||||
/// Solves a symbolic link.
|
||||
/// Solves a symbolic link.
|
||||
/// </summary>
|
||||
/// <param name="path">Link path.</param>
|
||||
/// <param name="dest">Link destination.</param>
|
||||
@@ -51,7 +51,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists contents from a directory.
|
||||
/// Lists contents from a directory.
|
||||
/// </summary>
|
||||
/// <param name="path">Directory path.</param>
|
||||
/// <param name="contents">Directory contents.</param>
|
||||
@@ -100,7 +100,8 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
CatalogSector catSector = (CatalogSector)Marshal.PtrToStructure(catPtr, typeof(CatalogSector));
|
||||
Marshal.FreeHGlobal(catPtr);
|
||||
|
||||
foreach(FileEntry entry in catSector.entries.Where(entry => entry.extentTrack > 0)) {
|
||||
foreach(FileEntry entry in catSector.entries.Where(entry => entry.extentTrack > 0))
|
||||
{
|
||||
track1UsedByFiles |= entry.extentTrack == 1;
|
||||
track2UsedByFiles |= entry.extentTrack == 2;
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
|
||||
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) attributes |= FileAttributes.System;
|
||||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
|
||||
attributes |= FileAttributes.System;
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
@@ -77,14 +78,9 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
|
||||
{
|
||||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
|
||||
file = catalogBlocks;
|
||||
else if(string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)
|
||||
file = vtocBlocks;
|
||||
else
|
||||
file = bootBlocks;
|
||||
}
|
||||
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) file = catalogBlocks;
|
||||
else if(string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0) file = vtocBlocks;
|
||||
else file = bootBlocks;
|
||||
else
|
||||
{
|
||||
if(!fileCache.TryGetValue(filename, out file))
|
||||
@@ -224,7 +220,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
extentCache = new Dictionary<string, byte[]>();
|
||||
|
||||
foreach(Errno error in catalogCache.Keys.Select(CacheFile).Where(error => error != Errno.NoError))
|
||||
{ return error; }
|
||||
return error;
|
||||
|
||||
uint tracksOnBoot = 1;
|
||||
if(!track1UsedByFiles) tracksOnBoot++;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
public partial class AppleDOS
|
||||
{
|
||||
/// <summary>
|
||||
/// Mounts an Apple DOS filesystem
|
||||
/// Mounts an Apple DOS filesystem
|
||||
/// </summary>
|
||||
public override Errno Mount()
|
||||
{
|
||||
@@ -48,7 +48,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mounts an Apple DOS filesystem
|
||||
/// Mounts an Apple DOS filesystem
|
||||
/// </summary>
|
||||
public override Errno Mount(bool debug)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Umounts this DOS filesystem
|
||||
/// Umounts this DOS filesystem
|
||||
/// </summary>
|
||||
public override Errno Unmount()
|
||||
{
|
||||
@@ -131,7 +131,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the mounted volume.
|
||||
/// Gets information about the mounted volume.
|
||||
/// </summary>
|
||||
/// <param name="stat">Information about the mounted volume.</param>
|
||||
public override Errno StatFs(ref FileSystemInfo stat)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
public partial class AppleDOS
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists all extended attributes, alternate data streams and forks of the given file.
|
||||
/// Lists all extended attributes, alternate data streams and forks of the given file.
|
||||
/// </summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">Path.</param>
|
||||
@@ -71,7 +71,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an extended attribute, alternate data stream or fork from the given file.
|
||||
/// Reads an extended attribute, alternate data stream or fork from the given file.
|
||||
/// </summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">File path.</param>
|
||||
@@ -89,7 +89,8 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
|
||||
if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
|
||||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) return Errno.NoSuchExtendedAttribute;
|
||||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
|
||||
return Errno.NoSuchExtendedAttribute;
|
||||
|
||||
if(!catalogCache.ContainsKey(filename)) return Errno.NoSuchFile;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user