mirror of
https://github.com/aaru-dps/Aaru.git
synced 2026-07-08 18:16:24 +00:00
[SonyPFS] Implement Identify.
This commit is contained in:
@@ -29,7 +29,9 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.AaruMetadata;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Helpers;
|
||||
using Partition = Aaru.CommonTypes.Partition;
|
||||
|
||||
namespace Aaru.Filesystems;
|
||||
@@ -37,7 +39,31 @@ namespace Aaru.Filesystems;
|
||||
public partial class SonyPFS
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool Identify(IMediaImage imagePlugin, Partition partition) => throw new NotImplementedException();
|
||||
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
||||
{
|
||||
uint sectorSize = imagePlugin.Info.SectorSize;
|
||||
|
||||
if(sectorSize < 512) return false;
|
||||
|
||||
// Superblock is at sector 0 relative to partition data start
|
||||
int sbSize = Marshal.SizeOf<SuperBlock>();
|
||||
|
||||
var sectorsToRead = (uint)((sbSize + sectorSize - 1) / sectorSize);
|
||||
|
||||
ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sectorsToRead, out byte[] sector, out _);
|
||||
|
||||
if(errno != ErrorNumber.NoError) return false;
|
||||
|
||||
if(sector.Length < sbSize) return false;
|
||||
|
||||
SuperBlock sb = Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sector);
|
||||
|
||||
if(sb.magic != PFS_SUPER_MAGIC) return false;
|
||||
|
||||
if(sb.version > PFS_FORMAT_VERSION) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information,
|
||||
|
||||
Reference in New Issue
Block a user