mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Refactor] General reformat and clean-up.
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
<PackageReference Include="Humanizer"/>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection"/>
|
||||
<PackageReference Include="SharpCompress"/>
|
||||
<PackageReference Include="Spectre.Console" />
|
||||
<PackageReference Include="Spectre.Console"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aaru.Generators\Aaru.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
|
||||
|
||||
@@ -11,10 +11,9 @@ public sealed partial class Amg
|
||||
#region IArchive Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Identify(IFilter filter)
|
||||
{
|
||||
return false;
|
||||
/*
|
||||
public bool Identify(IFilter filter) => false;
|
||||
|
||||
/*
|
||||
if(filter.DataForkLength < Marshal.SizeOf<ArcHeader>()) return false;
|
||||
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
@@ -29,8 +28,6 @@ public sealed partial class Amg
|
||||
// Not a valid magic
|
||||
return header.magic == ARC_MAGIC;
|
||||
*/
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void GetInformation(IFilter filter, Encoding encoding, out string information)
|
||||
{
|
||||
@@ -42,7 +39,7 @@ public sealed partial class Amg
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<ArcHeader>()];
|
||||
var hdr = new byte[Marshal.SizeOf<ArcHeader>()];
|
||||
|
||||
stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -61,7 +58,7 @@ public sealed partial class Amg
|
||||
|
||||
if(header.commentLength > 0)
|
||||
{
|
||||
byte[] buffer = new byte[header.commentLength];
|
||||
var buffer = new byte[header.commentLength];
|
||||
stream.ReadExactly(buffer, 0, buffer.Length);
|
||||
sb.AppendLine(Localization.Archive_comment);
|
||||
sb.AppendLine(Markup.Escape(StringHandlers.CToString(buffer, encoding)));
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed partial class Amg
|
||||
_stream = filter.GetDataForkStream();
|
||||
_stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<ArcHeader>()];
|
||||
var hdr = new byte[Marshal.SizeOf<ArcHeader>()];
|
||||
|
||||
_stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -39,7 +39,7 @@ public sealed partial class Amg
|
||||
|
||||
while(_stream.Position + fileHeaderLen < _stream.Length)
|
||||
{
|
||||
byte[] fileHdr = new byte[fileHeaderLen];
|
||||
var fileHdr = new byte[fileHeaderLen];
|
||||
|
||||
_stream.ReadExactly(fileHdr, 0, fileHdr.Length);
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed partial class Amg
|
||||
|
||||
if(fh.pathLength > 0)
|
||||
{
|
||||
byte[] buffer = new byte[fh.pathLength];
|
||||
var buffer = new byte[fh.pathLength];
|
||||
_stream.ReadExactly(buffer, 0, buffer.Length);
|
||||
string path = StringHandlers.CToString(buffer, encoding);
|
||||
path = path.Replace('\\', Path.DirectorySeparatorChar);
|
||||
@@ -74,7 +74,7 @@ public sealed partial class Amg
|
||||
|
||||
if(fh.commentLength > 0)
|
||||
{
|
||||
byte[] buffer = new byte[fh.commentLength];
|
||||
var buffer = new byte[fh.commentLength];
|
||||
_stream.ReadExactly(buffer, 0, buffer.Length);
|
||||
entry.Comment = StringHandlers.CToString(buffer, encoding);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public sealed partial class Arc
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
|
||||
stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -53,7 +53,7 @@ public sealed partial class Arc
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
|
||||
stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public sealed partial class Arc
|
||||
_stream = filter.GetDataForkStream();
|
||||
_stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdr = new byte[Marshal.SizeOf<Header>()];
|
||||
|
||||
_stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -55,7 +55,7 @@ public sealed partial class Arc
|
||||
ArchiveSupportedFeature.SupportsFilenames |
|
||||
ArchiveSupportedFeature.HasEntryTimestamp;
|
||||
|
||||
string path = "";
|
||||
var path = "";
|
||||
string longname = null;
|
||||
string comment = null;
|
||||
string attributes = null;
|
||||
@@ -104,7 +104,7 @@ public sealed partial class Arc
|
||||
if(header.method == Method.FileInformation)
|
||||
{
|
||||
int recordsSize = header.compressed;
|
||||
int recordsRead = 0;
|
||||
var recordsRead = 0;
|
||||
|
||||
while(recordsRead < recordsSize)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ public sealed partial class Ha
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<HaHeader>()];
|
||||
var hdr = new byte[Marshal.SizeOf<HaHeader>()];
|
||||
|
||||
stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -37,7 +37,7 @@ public sealed partial class Ha
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<HaHeader>()];
|
||||
var hdr = new byte[Marshal.SizeOf<HaHeader>()];
|
||||
|
||||
stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
@@ -21,7 +20,7 @@ public sealed partial class Ha
|
||||
_stream = filter.GetDataForkStream();
|
||||
_stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<HaHeader>()];
|
||||
var hdr = new byte[Marshal.SizeOf<HaHeader>()];
|
||||
|
||||
_stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -32,11 +31,11 @@ public sealed partial class Ha
|
||||
|
||||
_entries = [];
|
||||
|
||||
int fhLen = Marshal.SizeOf<FHeader>();
|
||||
byte[] fhBuf = new byte[fhLen];
|
||||
byte[] pathBuf = new byte[16384];
|
||||
byte[] nameBuf = new byte[256];
|
||||
int i; // Guard
|
||||
int fhLen = Marshal.SizeOf<FHeader>();
|
||||
var fhBuf = new byte[fhLen];
|
||||
var pathBuf = new byte[16384];
|
||||
var nameBuf = new byte[256];
|
||||
int i; // Guard
|
||||
|
||||
while(_stream.Position + fhLen < _stream.Length)
|
||||
{
|
||||
@@ -88,7 +87,7 @@ public sealed partial class Ha
|
||||
|
||||
int mdiLen = _stream.ReadByte();
|
||||
|
||||
byte[] mdi = new byte[mdiLen];
|
||||
var mdi = new byte[mdiLen];
|
||||
_stream.ReadExactly(mdi, 0, mdiLen);
|
||||
|
||||
string path = StringHandlers.CToString(pathBuf, encoding);
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed partial class Stfs
|
||||
_stream = filter.GetDataForkStream();
|
||||
_stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<RemotePackage>()];
|
||||
var hdr = new byte[Marshal.SizeOf<RemotePackage>()];
|
||||
|
||||
_stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -46,13 +46,13 @@ public sealed partial class Stfs
|
||||
|
||||
int fileTablePosition = BlockToPosition(fileTableBlockNumber, (int)header.Metadata.HeaderSize);
|
||||
|
||||
byte[] buffer = new byte[4096 * vd.FileTableBlockCount];
|
||||
var buffer = new byte[4096 * vd.FileTableBlockCount];
|
||||
_stream.Position = fileTablePosition;
|
||||
_stream.ReadExactly(buffer, 0, buffer.Length);
|
||||
|
||||
List<FileTableEntry> entries = [];
|
||||
int entrySize = Marshal.SizeOf<FileTableEntry>();
|
||||
int in_pos = 0;
|
||||
var in_pos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -67,11 +67,11 @@ public sealed partial class Stfs
|
||||
|
||||
_entries = new FileEntry[entries.Count];
|
||||
|
||||
for(int i = 0; i < entries.Count; i++)
|
||||
for(var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
// While entries[i].PathIndicator > 0 recursively inversely prepend entries[PathIndicator].Filename to entries[i].Filename
|
||||
int pathIndicator = entries[i].PathIndicator;
|
||||
string path = "";
|
||||
int pathIndicator = entries[i].PathIndicator;
|
||||
var path = "";
|
||||
|
||||
while(pathIndicator > 0)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ public sealed partial class Stfs
|
||||
/// <inheritdoc />
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
int totalRead = 0;
|
||||
var totalRead = 0;
|
||||
|
||||
// Validate parameters
|
||||
ArgumentNullException.ThrowIfNull(buffer);
|
||||
@@ -73,7 +73,7 @@ public sealed partial class Stfs
|
||||
_isConsole);
|
||||
|
||||
// Calculate position within block
|
||||
int blockOffset = (int)(_position % 0x1000);
|
||||
var blockOffset = (int)(_position % 0x1000);
|
||||
|
||||
// Calculate absolute position in the stream
|
||||
long absolutePosition = BlockToPosition(currentBlock, _headerSize) + blockOffset;
|
||||
@@ -138,7 +138,7 @@ public sealed partial class Stfs
|
||||
_baseStream.Position = absolutePosition + leftInBlock;
|
||||
|
||||
// Read remaining bytes
|
||||
int toRead = (int)Math.Min(count, _length - _position);
|
||||
var toRead = (int)Math.Min(count, _length - _position);
|
||||
_baseStream.ReadExactly(buffer, offset, toRead);
|
||||
_position += toRead;
|
||||
totalRead += toRead;
|
||||
|
||||
@@ -48,7 +48,7 @@ public sealed partial class Zoo
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<ZooHeader>()];
|
||||
var hdr = new byte[Marshal.SizeOf<ZooHeader>()];
|
||||
|
||||
stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -67,7 +67,7 @@ public sealed partial class Zoo
|
||||
Stream stream = filter.GetDataForkStream();
|
||||
stream.Position = 0;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<ZooHeader>()];
|
||||
var hdr = new byte[Marshal.SizeOf<ZooHeader>()];
|
||||
|
||||
stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -105,7 +105,7 @@ public sealed partial class Zoo
|
||||
|
||||
if(header.acmt_len > 0)
|
||||
{
|
||||
byte[] buffer = new byte[header.acmt_len];
|
||||
var buffer = new byte[header.acmt_len];
|
||||
stream.Position = header.acmt_pos;
|
||||
encoding ??= Encoding.UTF8;
|
||||
stream.ReadExactly(buffer, 0, buffer.Length);
|
||||
|
||||
@@ -56,7 +56,7 @@ public sealed partial class Zoo
|
||||
ArchiveSupportedFeature.SupportsFilenames |
|
||||
ArchiveSupportedFeature.SupportsSubdirectories;
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<ZooHeader>()];
|
||||
var hdr = new byte[Marshal.SizeOf<ZooHeader>()];
|
||||
|
||||
_stream.ReadExactly(hdr, 0, hdr.Length);
|
||||
|
||||
@@ -86,7 +86,7 @@ public sealed partial class Zoo
|
||||
|
||||
do
|
||||
{
|
||||
byte[] buf = new byte[Marshal.SizeOf<Direntry>()];
|
||||
var buf = new byte[Marshal.SizeOf<Direntry>()];
|
||||
|
||||
if(_stream.Position + buf.Length >= _stream.Length) break;
|
||||
|
||||
@@ -94,7 +94,7 @@ public sealed partial class Zoo
|
||||
|
||||
entry = Marshal.ByteArrayToStructureLittleEndian<Direntry>(buf);
|
||||
|
||||
int pos = 56; // dir_crc
|
||||
var pos = 56; // dir_crc
|
||||
|
||||
if(entry.namlen > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user