Cache FAT16.

This commit is contained in:
2019-04-27 02:38:48 +01:00
parent ffa5a4ceb7
commit 5b86a572bd
2 changed files with 13 additions and 12 deletions

View File

@@ -192,17 +192,7 @@ namespace DiscImageChef.Filesystems.FAT
while(nextCluster > 0 && nextCluster <= FAT16_FORMATTED)
{
clusters.Add(nextCluster);
if(currentSector != nextSector)
{
fatData = image.ReadSector(nextSector);
currentSector = nextSector;
}
nextCluster = BitConverter.ToUInt16(fatData, nextEntry * 2);
nextSector = nextCluster / fatEntriesPerSector + fatFirstSector +
(useFirstFat ? 0 : sectorsPerFat);
nextEntry = (int)(nextCluster % fatEntriesPerSector);
nextCluster = fatEntries[nextCluster];
}
else
while(nextCluster > 0 && nextCluster <= FAT12_FORMATTED)

View File

@@ -35,15 +35,16 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.CommonTypes.Structs;
using DiscImageChef.Console;
using DiscImageChef.Helpers;
using Schemas;
using FileSystemInfo = DiscImageChef.CommonTypes.Structs.FileSystemInfo;
using Marshal = DiscImageChef.Helpers.Marshal;
namespace DiscImageChef.Filesystems.FAT
{
@@ -505,6 +506,16 @@ namespace DiscImageChef.Filesystems.FAT
fatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4));
}
}
else if(fat16)
{
DicConsole.DebugWriteLine("FAT plugin", "Reading FAT16");
byte[] fatBytes =
imagePlugin.ReadSectors(fatFirstSector + (useFirstFat ? 0 : sectorsPerFat), sectorsPerFat);
DicConsole.DebugWriteLine("FAT plugin", "Casting FAT");
fatEntries = MemoryMarshal.Cast<byte, ushort>(fatBytes).ToArray();
}
// TODO: Check how this affects international filenames
cultureInfo = new CultureInfo("en-US", false);