mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Refactor and reformat code
git-svn-id: svn://claunia.com/FileSystemIDandChk@29 17725271-3d32-4980-a8cb-9ff532f270ba
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using FileSystemIDandChk;
|
||||
|
||||
|
||||
namespace FileSystemIDandChk.Plugins
|
||||
{
|
||||
class OperaFS : Plugin
|
||||
{
|
||||
public OperaFS(PluginBase Core)
|
||||
class OperaFS : Plugin
|
||||
{
|
||||
public OperaFS(PluginBase Core)
|
||||
{
|
||||
base.Name = "Opera Filesystem Plugin";
|
||||
base.PluginUUID = new Guid("0ec84ec7-eae6-4196-83fe-943b3fe46dbd");
|
||||
Name = "Opera Filesystem Plugin";
|
||||
PluginUUID = new Guid("0ec84ec7-eae6-4196-83fe-943b3fe46dbd");
|
||||
}
|
||||
|
||||
|
||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset)
|
||||
{
|
||||
{
|
||||
byte[] sb_sector = imagePlugin.ReadSector(0 + partitionOffset);
|
||||
|
||||
byte record_type;
|
||||
@@ -26,22 +24,20 @@ namespace FileSystemIDandChk.Plugins
|
||||
Array.Copy(sb_sector, 0x001, sync_bytes, 0, 5);
|
||||
record_version = sb_sector[0x006];
|
||||
|
||||
if (record_type != 1 || record_version != 1)
|
||||
return false;
|
||||
if(Encoding.ASCII.GetString(sync_bytes) != "ZZZZZ")
|
||||
if (record_type != 1 || record_version != 1)
|
||||
return false;
|
||||
return Encoding.ASCII.GetString(sync_bytes) == "ZZZZZ";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void GetInformation (ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
|
||||
{
|
||||
information = "";
|
||||
}
|
||||
|
||||
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionOffset, out string information)
|
||||
{
|
||||
information = "";
|
||||
StringBuilder SuperBlockMetadata = new StringBuilder();
|
||||
|
||||
byte[] sb_sector = imagePlugin.ReadSector(0 + partitionOffset);
|
||||
|
||||
OperaSuperBlock sb = new OperaSuperBlock();
|
||||
OperaSuperBlock sb = new OperaSuperBlock();
|
||||
byte[] cString = new byte[32];
|
||||
sb.sync_bytes = new byte[5];
|
||||
|
||||
@@ -50,9 +46,9 @@ namespace FileSystemIDandChk.Plugins
|
||||
sb.record_version = sb_sector[0x006];
|
||||
sb.volume_flags = sb_sector[0x007];
|
||||
Array.Copy(sb_sector, 0x008, cString, 0, 32);
|
||||
sb.volume_comment = StringHandlers.CToString(cString);
|
||||
sb.volume_comment = StringHandlers.CToString(cString);
|
||||
Array.Copy(sb_sector, 0x028, cString, 0, 32);
|
||||
sb.volume_label = StringHandlers.CToString(cString);
|
||||
sb.volume_label = StringHandlers.CToString(cString);
|
||||
sb.volume_id = BigEndianBitConverter.ToInt32(sb_sector, 0x048);
|
||||
sb.block_size = BigEndianBitConverter.ToInt32(sb_sector, 0x04C);
|
||||
sb.block_count = BigEndianBitConverter.ToInt32(sb_sector, 0x050);
|
||||
@@ -61,22 +57,22 @@ namespace FileSystemIDandChk.Plugins
|
||||
sb.rootdir_bsize = BigEndianBitConverter.ToInt32(sb_sector, 0x05C);
|
||||
sb.last_root_copy = BigEndianBitConverter.ToInt32(sb_sector, 0x060);
|
||||
|
||||
if (sb.record_type != 1 || sb.record_version != 1)
|
||||
if (sb.record_type != 1 || sb.record_version != 1)
|
||||
return;
|
||||
if(Encoding.ASCII.GetString(sb.sync_bytes) != "ZZZZZ")
|
||||
if (Encoding.ASCII.GetString(sb.sync_bytes) != "ZZZZZ")
|
||||
return;
|
||||
|
||||
if (sb.volume_comment.Length == 0)
|
||||
sb.volume_comment = "Not set.";
|
||||
if (sb.volume_comment.Length == 0)
|
||||
sb.volume_comment = "Not set.";
|
||||
|
||||
if (sb.volume_label.Length == 0)
|
||||
sb.volume_label = "Not set.";
|
||||
if (sb.volume_label.Length == 0)
|
||||
sb.volume_label = "Not set.";
|
||||
|
||||
SuperBlockMetadata.AppendFormat("Opera filesystem disc.").AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume label: {0}", sb.volume_label).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume comment: {0}", sb.volume_comment).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume identifier: 0x{0:X8}", sb.volume_id).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Block size: {0} bytes", sb.block_size).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume label: {0}", sb.volume_label).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume comment: {0}", sb.volume_comment).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Volume identifier: 0x{0:X8}", sb.volume_id).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Block size: {0} bytes", sb.block_size).AppendLine();
|
||||
if (imagePlugin.GetSectorSize() == 2336 || imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448)
|
||||
{
|
||||
if (sb.block_size != 2048)
|
||||
@@ -84,32 +80,45 @@ namespace FileSystemIDandChk.Plugins
|
||||
}
|
||||
else if (imagePlugin.GetSectorSize() != sb.block_size)
|
||||
SuperBlockMetadata.AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/block", sb.block_size, imagePlugin.GetSectorSize());
|
||||
SuperBlockMetadata.AppendFormat("Volume size: {0} blocks, {1} bytes", sb.block_count, sb.block_size*sb.block_count).AppendLine();
|
||||
if((ulong)sb.block_count > imagePlugin.GetSectors())
|
||||
SuperBlockMetadata.AppendFormat("Volume size: {0} blocks, {1} bytes", sb.block_count, sb.block_size * sb.block_count).AppendLine();
|
||||
if ((ulong)sb.block_count > imagePlugin.GetSectors())
|
||||
SuperBlockMetadata.AppendFormat("WARNING: Filesystem indicates {0} blocks while device indicates {1} blocks", sb.block_count, imagePlugin.GetSectors());
|
||||
SuperBlockMetadata.AppendFormat("Root directory identifier: 0x{0:X8}", sb.root_dirid).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory block size: {0} bytes", sb.rootdir_bsize).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory size: {0} blocks, {1} bytes", sb.rootdir_blocks, sb.rootdir_bsize*sb.rootdir_blocks).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Last root directory copy: {0}", sb.last_root_copy).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory identifier: 0x{0:X8}", sb.root_dirid).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory block size: {0} bytes", sb.rootdir_bsize).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Root directory size: {0} blocks, {1} bytes", sb.rootdir_blocks, sb.rootdir_bsize * sb.rootdir_blocks).AppendLine();
|
||||
SuperBlockMetadata.AppendFormat("Last root directory copy: {0}", sb.last_root_copy).AppendLine();
|
||||
|
||||
information = SuperBlockMetadata.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private struct OperaSuperBlock
|
||||
{
|
||||
public byte record_type; // 0x000, Record type, must be 1
|
||||
public byte[] sync_bytes; // 0x001, 5 bytes, "ZZZZZ" = new byte[5];
|
||||
public byte record_version; // 0x006, Record version, must be 1
|
||||
public byte volume_flags; // 0x007, Volume flags
|
||||
public string volume_comment; // 0x008, 32 bytes, volume comment
|
||||
public string volume_label; // 0x028, 32 bytes, volume label
|
||||
public Int32 volume_id; // 0x048, Volume ID
|
||||
public Int32 block_size; // 0x04C, Block size in bytes
|
||||
public Int32 block_count; // 0x050, Blocks in volume
|
||||
public Int32 root_dirid; // 0x054, Root directory ID
|
||||
public Int32 rootdir_blocks; // 0x058, Root directory blocks
|
||||
public Int32 rootdir_bsize; // 0x05C, Root directory block size
|
||||
public Int32 last_root_copy; // 0x060, Last root directory copy
|
||||
}
|
||||
}
|
||||
struct OperaSuperBlock
|
||||
{
|
||||
public byte record_type;
|
||||
// 0x000, Record type, must be 1
|
||||
public byte[] sync_bytes;
|
||||
// 0x001, 5 bytes, "ZZZZZ" = new byte[5];
|
||||
public byte record_version;
|
||||
// 0x006, Record version, must be 1
|
||||
public byte volume_flags;
|
||||
// 0x007, Volume flags
|
||||
public string volume_comment;
|
||||
// 0x008, 32 bytes, volume comment
|
||||
public string volume_label;
|
||||
// 0x028, 32 bytes, volume label
|
||||
public Int32 volume_id;
|
||||
// 0x048, Volume ID
|
||||
public Int32 block_size;
|
||||
// 0x04C, Block size in bytes
|
||||
public Int32 block_count;
|
||||
// 0x050, Blocks in volume
|
||||
public Int32 root_dirid;
|
||||
// 0x054, Root directory ID
|
||||
public Int32 rootdir_blocks;
|
||||
// 0x058, Root directory blocks
|
||||
public Int32 rootdir_bsize;
|
||||
// 0x05C, Root directory block size
|
||||
public Int32 last_root_copy;
|
||||
// 0x060, Last root directory copy
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user