mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use new marshaller in Apridisk disk images.
This commit is contained in:
@@ -62,7 +62,7 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] recB = new byte[recordSize];
|
||||
stream.Read(recB, 0, recordSize);
|
||||
|
||||
ApridiskRecord record = Marshal.ByteArrayToStructureLittleEndian<ApridiskRecord>(recB);
|
||||
ApridiskRecord record = Marshal.SpanToStructureLittleEndian<ApridiskRecord>(recB);
|
||||
|
||||
switch(record.type)
|
||||
{
|
||||
@@ -149,7 +149,7 @@ namespace DiscImageChef.DiscImages
|
||||
byte[] recB = new byte[recordSize];
|
||||
stream.Read(recB, 0, recordSize);
|
||||
|
||||
ApridiskRecord record = Marshal.ByteArrayToStructureLittleEndian<ApridiskRecord>(recB);
|
||||
ApridiskRecord record = Marshal.SpanToStructureLittleEndian<ApridiskRecord>(recB);
|
||||
|
||||
switch(record.type)
|
||||
{
|
||||
|
||||
@@ -30,16 +30,16 @@
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Helpers;
|
||||
using Schemas;
|
||||
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
@@ -149,8 +149,7 @@ namespace DiscImageChef.DiscImages
|
||||
writingStream.Seek(0, SeekOrigin.Begin);
|
||||
writingStream.Write(signature, 0, signature.Length);
|
||||
|
||||
byte[] hdr = new byte[Marshal.SizeOf<ApridiskRecord>()];
|
||||
IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<ApridiskRecord>());
|
||||
byte[] hdr = new byte[Marshal.SizeOf<ApridiskRecord>()];
|
||||
|
||||
for(ushort c = 0; c < imageInfo.Cylinders; c++)
|
||||
{
|
||||
@@ -171,8 +170,7 @@ namespace DiscImageChef.DiscImages
|
||||
cylinder = c
|
||||
};
|
||||
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(record, hdrPtr, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
||||
MemoryMarshal.Write(hdr, ref record);
|
||||
|
||||
writingStream.Write(hdr, 0, hdr.Length);
|
||||
writingStream.Write(sectorsData[c][h][s], 0, sectorsData[c][h][s].Length);
|
||||
@@ -194,8 +192,7 @@ namespace DiscImageChef.DiscImages
|
||||
cylinder = 0
|
||||
};
|
||||
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(creatorRecord, hdrPtr, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
||||
MemoryMarshal.Write(hdr, ref creatorRecord);
|
||||
|
||||
writingStream.Write(hdr, 0, hdr.Length);
|
||||
writingStream.Write(creatorBytes, 0, creatorBytes.Length);
|
||||
@@ -216,15 +213,13 @@ namespace DiscImageChef.DiscImages
|
||||
cylinder = 0
|
||||
};
|
||||
|
||||
System.Runtime.InteropServices.Marshal.StructureToPtr(commentRecord, hdrPtr, true);
|
||||
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
||||
MemoryMarshal.Write(hdr, ref commentRecord);
|
||||
|
||||
writingStream.Write(hdr, 0, hdr.Length);
|
||||
writingStream.Write(commentBytes, 0, commentBytes.Length);
|
||||
writingStream.WriteByte(0); // Termination
|
||||
}
|
||||
|
||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr);
|
||||
writingStream.Flush();
|
||||
writingStream.Close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user