mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[IArchive] Use IFilter for Identify() and Open().
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.IO;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Helpers;
|
||||
|
||||
namespace Aaru.Archives;
|
||||
@@ -39,30 +40,18 @@ public partial class Symbian
|
||||
{
|
||||
#region IArchive Members
|
||||
|
||||
public bool Identify(byte[] buffer)
|
||||
{
|
||||
if(buffer.Length < Marshal.SizeOf<SymbianHeader>())
|
||||
return false;
|
||||
|
||||
SymbianHeader header = Marshal.ByteArrayToStructureLittleEndian<SymbianHeader>(buffer);
|
||||
|
||||
if(header.uid1 == SYMBIAN9_MAGIC)
|
||||
return true;
|
||||
|
||||
if(header.uid3 != SYMBIAN_MAGIC)
|
||||
return false;
|
||||
|
||||
return header.uid2 is EPOC_MAGIC or EPOC6_MAGIC;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Identify(Stream stream)
|
||||
public bool Identify(IFilter filter)
|
||||
{
|
||||
if(stream.Length < Marshal.SizeOf<SymbianHeader>())
|
||||
if(filter.DataForkLength < Marshal.SizeOf<SymbianHeader>())
|
||||
return false;
|
||||
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
|
||||
var hdr = new byte[Marshal.SizeOf<SymbianHeader>()];
|
||||
|
||||
stream.EnsureRead(hdr, 0, hdr.Length);
|
||||
|
||||
SymbianHeader header = Marshal.ByteArrayToStructureLittleEndian<SymbianHeader>(hdr);
|
||||
|
||||
if(header.uid1 == SYMBIAN9_MAGIC)
|
||||
|
||||
Reference in New Issue
Block a user