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];
|
byte[] recB = new byte[recordSize];
|
||||||
stream.Read(recB, 0, recordSize);
|
stream.Read(recB, 0, recordSize);
|
||||||
|
|
||||||
ApridiskRecord record = Marshal.ByteArrayToStructureLittleEndian<ApridiskRecord>(recB);
|
ApridiskRecord record = Marshal.SpanToStructureLittleEndian<ApridiskRecord>(recB);
|
||||||
|
|
||||||
switch(record.type)
|
switch(record.type)
|
||||||
{
|
{
|
||||||
@@ -149,7 +149,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
byte[] recB = new byte[recordSize];
|
byte[] recB = new byte[recordSize];
|
||||||
stream.Read(recB, 0, recordSize);
|
stream.Read(recB, 0, recordSize);
|
||||||
|
|
||||||
ApridiskRecord record = Marshal.ByteArrayToStructureLittleEndian<ApridiskRecord>(recB);
|
ApridiskRecord record = Marshal.SpanToStructureLittleEndian<ApridiskRecord>(recB);
|
||||||
|
|
||||||
switch(record.type)
|
switch(record.type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,16 +30,16 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.CommonTypes.Structs;
|
using DiscImageChef.CommonTypes.Structs;
|
||||||
using DiscImageChef.Helpers;
|
|
||||||
using Schemas;
|
using Schemas;
|
||||||
|
using Marshal = DiscImageChef.Helpers.Marshal;
|
||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
@@ -149,8 +149,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
writingStream.Seek(0, SeekOrigin.Begin);
|
writingStream.Seek(0, SeekOrigin.Begin);
|
||||||
writingStream.Write(signature, 0, signature.Length);
|
writingStream.Write(signature, 0, signature.Length);
|
||||||
|
|
||||||
byte[] hdr = new byte[Marshal.SizeOf<ApridiskRecord>()];
|
byte[] hdr = new byte[Marshal.SizeOf<ApridiskRecord>()];
|
||||||
IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<ApridiskRecord>());
|
|
||||||
|
|
||||||
for(ushort c = 0; c < imageInfo.Cylinders; c++)
|
for(ushort c = 0; c < imageInfo.Cylinders; c++)
|
||||||
{
|
{
|
||||||
@@ -171,8 +170,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
cylinder = c
|
cylinder = c
|
||||||
};
|
};
|
||||||
|
|
||||||
System.Runtime.InteropServices.Marshal.StructureToPtr(record, hdrPtr, true);
|
MemoryMarshal.Write(hdr, ref record);
|
||||||
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
|
||||||
|
|
||||||
writingStream.Write(hdr, 0, hdr.Length);
|
writingStream.Write(hdr, 0, hdr.Length);
|
||||||
writingStream.Write(sectorsData[c][h][s], 0, sectorsData[c][h][s].Length);
|
writingStream.Write(sectorsData[c][h][s], 0, sectorsData[c][h][s].Length);
|
||||||
@@ -194,8 +192,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
cylinder = 0
|
cylinder = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
System.Runtime.InteropServices.Marshal.StructureToPtr(creatorRecord, hdrPtr, true);
|
MemoryMarshal.Write(hdr, ref creatorRecord);
|
||||||
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
|
||||||
|
|
||||||
writingStream.Write(hdr, 0, hdr.Length);
|
writingStream.Write(hdr, 0, hdr.Length);
|
||||||
writingStream.Write(creatorBytes, 0, creatorBytes.Length);
|
writingStream.Write(creatorBytes, 0, creatorBytes.Length);
|
||||||
@@ -216,15 +213,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
cylinder = 0
|
cylinder = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
System.Runtime.InteropServices.Marshal.StructureToPtr(commentRecord, hdrPtr, true);
|
MemoryMarshal.Write(hdr, ref commentRecord);
|
||||||
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
|
||||||
|
|
||||||
writingStream.Write(hdr, 0, hdr.Length);
|
writingStream.Write(hdr, 0, hdr.Length);
|
||||||
writingStream.Write(commentBytes, 0, commentBytes.Length);
|
writingStream.Write(commentBytes, 0, commentBytes.Length);
|
||||||
writingStream.WriteByte(0); // Termination
|
writingStream.WriteByte(0); // Termination
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr);
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user