[Aaru.Images] Reformat and cleanup.

This commit is contained in:
2023-10-03 23:34:59 +01:00
parent 6ffde343ce
commit 2cfad87955
432 changed files with 12011 additions and 8261 deletions

View File

@@ -46,9 +46,11 @@ namespace Aaru.DiscImages;
public sealed partial class Vdi
{
#region IWritableImage Members
/// <inheritdoc />
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
uint sectorSize)
uint sectorSize)
{
if(sectorSize != 512)
{
@@ -89,12 +91,12 @@ public sealed partial class Vdi
return false;
}
uint ibmEntries = (uint)(sectors * sectorSize / DEFAULT_BLOCK_SIZE);
var ibmEntries = (uint)(sectors * sectorSize / DEFAULT_BLOCK_SIZE);
if(sectors * sectorSize % DEFAULT_BLOCK_SIZE > 0)
ibmEntries++;
uint headerSectors = 1 + (ibmEntries * 4 / sectorSize);
uint headerSectors = 1 + ibmEntries * 4 / sectorSize;
if(ibmEntries * 4 % sectorSize != 0)
headerSectors++;
@@ -178,10 +180,10 @@ public sealed partial class Vdi
_vHdr.allocatedBlocks++;
}
ulong imageOff = _vHdr.offsetData + ((ulong)ibmOff * _vHdr.blockSize);
ulong imageOff = _vHdr.offsetData + (ulong)ibmOff * _vHdr.blockSize;
_writingStream.Seek((long)imageOff, SeekOrigin.Begin);
_writingStream.Seek((long)secOff, SeekOrigin.Current);
_writingStream.Seek((long)secOff, SeekOrigin.Current);
_writingStream.Write(data, 0, data.Length);
ErrorMessage = "";
@@ -220,7 +222,7 @@ public sealed partial class Vdi
for(uint i = 0; i < length; i++)
{
byte[] tmp = new byte[_imageInfo.SectorSize];
var tmp = new byte[_imageInfo.SectorSize];
Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize);
if(!WriteSector(tmp, sectorAddress + i))
@@ -285,8 +287,8 @@ public sealed partial class Vdi
}
}
byte[] hdr = new byte[Marshal.SizeOf<Header>()];
nint hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<Header>());
var hdr = new byte[Marshal.SizeOf<Header>()];
nint hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<Header>());
System.Runtime.InteropServices.Marshal.StructureToPtr(_vHdr, hdrPtr, true);
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr);
@@ -345,4 +347,6 @@ public sealed partial class Vdi
/// <inheritdoc />
public bool SetMetadata(Metadata metadata) => false;
#endregion
}