Use UTF-8 string literals whenever possible.

This commit is contained in:
2023-09-29 18:27:27 +01:00
parent c673fb6e95
commit 750ae890e7
31 changed files with 105 additions and 266 deletions

View File

@@ -45,40 +45,13 @@ namespace Aaru.Core.Devices.Dumping;
public partial class Dump
{
static readonly byte[] _sfcExtension =
{
0x53, 0x46, 0x43
};
static readonly byte[] _genesisExtension =
{
0x42, 0x49, 0x4E
};
static readonly byte[] _smsExtension =
{
0x53, 0x4D, 0x53
};
static readonly byte[] _z64Extension =
{
0x5A, 0x36, 0x34
};
static readonly byte[] _gbExtension =
{
0x47, 0x42, 0x20
};
static readonly byte[] _gbcExtension =
{
0x47, 0x42, 0x43
};
static readonly byte[] _gbaExtension =
{
0x47, 0x42, 0x41
};
static readonly byte[] _sfcExtension = "SFC"u8.ToArray();
static readonly byte[] _genesisExtension = "BIN"u8.ToArray();
static readonly byte[] _smsExtension = "SMS"u8.ToArray();
static readonly byte[] _z64Extension = "Z64"u8.ToArray();
static readonly byte[] _gbExtension = "GB "u8.ToArray();
static readonly byte[] _gbcExtension = "GBC"u8.ToArray();
static readonly byte[] _gbaExtension = "GBA"u8.ToArray();
/// <summary>Dumps a game cartridge using a Retrode adapter</summary>
void Retrode()

View File

@@ -42,14 +42,8 @@ namespace Aaru.Core.Devices.Dumping;
public partial class Dump
{
static readonly byte[] _fatSignature =
{
0x46, 0x41, 0x54, 0x31, 0x36, 0x20, 0x20, 0x20
};
static readonly byte[] _isoExtension =
{
0x49, 0x53, 0x4F
};
static readonly byte[] _fatSignature = "FAT16 "u8.ToArray();
static readonly byte[] _isoExtension = "ISO"u8.ToArray();
/// <summary>Dumps a CFW PlayStation Portable UMD</summary>
void PlayStationPortable()

View File

@@ -91,31 +91,11 @@ public static class MMC
};
/// <summary>Present on first two seconds of second track, says "COPYRIGHT BANDAI"</summary>
static readonly byte[] _playdiaCopyright =
{
0x43, 0x4F, 0x50, 0x59, 0x52, 0x49, 0x47, 0x48, 0x54, 0x20, 0x42, 0x41, 0x4E, 0x44, 0x41, 0x49
};
static readonly byte[] _pcEngineSignature =
{
0x50, 0x43, 0x20, 0x45, 0x6E, 0x67, 0x69, 0x6E, 0x65, 0x20, 0x43, 0x44, 0x2D, 0x52, 0x4F, 0x4D, 0x20, 0x53,
0x59, 0x53, 0x54, 0x45, 0x4D
};
static readonly byte[] _pcFxSignature =
{
0x50, 0x43, 0x2D, 0x46, 0x58, 0x3A, 0x48, 0x75, 0x5F, 0x43, 0x44, 0x2D, 0x52, 0x4F, 0x4D
};
static readonly byte[] _playdiaCopyright = "COPYRIGHT BANDAI"u8.ToArray();
static readonly byte[] _pcEngineSignature = "PC Engine CD-ROM SYSTEM"u8.ToArray();
static readonly byte[] _pcFxSignature = "PC-FX:Hu_CD-ROM"u8.ToArray();
static readonly byte[] _atariSignature =
{
0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41,
0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52,
0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41,
0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x52, 0x41, 0x20, 0x49, 0x50, 0x41,
0x52, 0x50, 0x56, 0x4F, 0x44, 0x45, 0x44, 0x20, 0x54, 0x41, 0x20, 0x41, 0x45, 0x48, 0x44, 0x41, 0x52, 0x45,
0x41, 0x20, 0x52, 0x54
};
"TAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTAIRTARA IPARPVODED TA AEHDAREA RT"u8.ToArray();
/// <summary>This is some kind of header. Every 10 bytes there's an audio byte.</summary>
static readonly byte[] _videoNowColorFrameMarker =

View File

@@ -39,8 +39,5 @@ namespace Aaru.Filesystems;
public sealed partial class AODOS
{
const string FS_TYPE = "aodos";
readonly byte[] _identifier =
{
0x20, 0x41, 0x4F, 0x2D, 0x44, 0x4F, 0x53, 0x20
};
readonly byte[] _identifier = " AO-DOS "u8.ToArray();
}

View File

@@ -37,8 +37,5 @@ namespace Aaru.Filesystems;
public sealed partial class ECMA67
{
const string FS_TYPE = "ecma67";
readonly byte[] _magic =
{
0x56, 0x4F, 0x4C
};
readonly byte[] _magic = "VOL"u8.ToArray();
}

View File

@@ -34,14 +34,8 @@ public sealed partial class HPOFS
{
0x48, 0x50, 0x4F, 0x46, 0x53, 0x00, 0x00, 0x00
};
readonly byte[] _medinfoSignature =
{
0x4D, 0x45, 0x44, 0x49, 0x4E, 0x46, 0x4F, 0x20
};
readonly byte[] _volinfoSignature =
{
0x56, 0x4F, 0x4C, 0x49, 0x4E, 0x46, 0x4F, 0x20
};
readonly byte[] _medinfoSignature = "MEDINFO "u8.ToArray();
readonly byte[] _volinfoSignature = "VOLINFO "u8.ToArray();
// Do not translate
const string FS_TYPE = "hpofs";

View File

@@ -40,11 +40,6 @@ namespace Aaru.Filesystems;
public sealed partial class exFAT
{
readonly Guid _oemFlashParameterGuid = new("0A0C7E46-3399-4021-90C8-FA6D389C4BA2");
readonly byte[] _signature =
{
0x45, 0x58, 0x46, 0x41, 0x54, 0x20, 0x20, 0x20
};
readonly byte[] _signature = "EXFAT "u8.ToArray();
const string FS_TYPE = "exfat";
}

View File

@@ -50,31 +50,12 @@ public sealed class AppleDouble : IFilter
const uint MAGIC = 0x00051607;
const uint VERSION = 0x00010000;
const uint VERSION2 = 0x00020000;
readonly byte[] _dosHome =
{
0x4D, 0x53, 0x2D, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _macintoshHome =
{
0x4D, 0x61, 0x63, 0x69, 0x6E, 0x74, 0x6F, 0x73, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _osxHome =
{
0x4D, 0x61, 0x63, 0x20, 0x4F, 0x53, 0x20, 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _proDosHome =
{
0x50, 0x72, 0x6F, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _unixHome =
{
0x55, 0x6E, 0x69, 0x78, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _vmsHome =
{
0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _dosHome = "MS-DOS "u8.ToArray();
readonly byte[] _macintoshHome = "Macintosh "u8.ToArray();
readonly byte[] _osxHome = "Mac OS X "u8.ToArray();
readonly byte[] _proDosHome = "ProDOS "u8.ToArray();
readonly byte[] _unixHome = "Unix "u8.ToArray();
readonly byte[] _vmsHome = "VAX VMS "u8.ToArray();
Entry _dataFork;
Header _header;
string _headerPath;

View File

@@ -50,31 +50,12 @@ public sealed class AppleSingle : IFilter
const uint MAGIC = 0x00051600;
const uint VERSION = 0x00010000;
const uint VERSION2 = 0x00020000;
readonly byte[] _dosHome =
{
0x4D, 0x53, 0x2D, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _macintoshHome =
{
0x4D, 0x61, 0x63, 0x69, 0x6E, 0x74, 0x6F, 0x73, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _osxHome =
{
0x4D, 0x61, 0x63, 0x20, 0x4F, 0x53, 0x20, 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _proDosHome =
{
0x50, 0x72, 0x6F, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _unixHome =
{
0x55, 0x6E, 0x69, 0x78, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _vmsHome =
{
0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
readonly byte[] _dosHome = "MS-DOS "u8.ToArray();
readonly byte[] _macintoshHome = "Macintosh "u8.ToArray();
readonly byte[] _osxHome = "Mac OS X "u8.ToArray();
readonly byte[] _proDosHome = "ProDOS "u8.ToArray();
readonly byte[] _unixHome = "Unix "u8.ToArray();
readonly byte[] _vmsHome = "VAX VMS "u8.ToArray();
byte[] _bytes;
Entry _dataFork;
Header _header;

View File

@@ -35,8 +35,5 @@ namespace Aaru.DiscImages;
public sealed partial class Alcohol120
{
const byte MAXIMUM_SUPPORTED_VERSION = 1;
readonly byte[] _alcoholSignature =
{
0x4d, 0x45, 0x44, 0x49, 0x41, 0x20, 0x44, 0x45, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x4f, 0x52
};
readonly byte[] _alcoholSignature = "MEDIA DESCRIPTOR"u8.ToArray();
}

View File

@@ -53,27 +53,17 @@ public sealed partial class AppleNib
{
0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15
};
readonly byte[] _driString =
{
0x43, 0x4F, 0x50, 0x59, 0x52, 0x49, 0x47, 0x48, 0x54, 0x20, 0x28, 0x43, 0x29, 0x20, 0x31, 0x39, 0x37, 0x39,
0x2C, 0x20, 0x44, 0x49, 0x47, 0x49, 0x54, 0x41, 0x4C, 0x20, 0x52, 0x45, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48
};
readonly byte[] _driString = "COPYRIGHT (C) 1979, DIGITAL RESEARCH"u8.ToArray();
readonly byte[] _pascalSign =
{
0x08, 0xA5, 0x0F, 0x29
};
readonly byte[] _pascalString =
{
0x53, 0x59, 0x53, 0x54, 0x45, 0x2E, 0x41, 0x50, 0x50, 0x4C, 0x45
};
readonly byte[] _pascalString = "SYSTE.APPLE"u8.ToArray();
readonly byte[] _pascal2Sign =
{
0xFF, 0xA2, 0x00, 0x8E
};
readonly byte[] _prodosString =
{
0x50, 0x52, 0x4F, 0x44, 0x4F, 0x53
};
readonly byte[] _prodosString = "PRODOS"u8.ToArray();
readonly ulong[] _proDosSkewing =
{
0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15

View File

@@ -35,8 +35,5 @@ namespace Aaru.DiscImages;
public sealed partial class BlindWrite4
{
/// <summary>"BLINDWRITE TOC FILE"</summary>
readonly byte[] _bw4Signature =
{
0x42, 0x4C, 0x49, 0x4E, 0x44, 0x57, 0x52, 0x49, 0x54, 0x45, 0x20, 0x54, 0x4F, 0x43, 0x20, 0x46, 0x49, 0x4C, 0x45
};
readonly byte[] _bw4Signature = "BLINDWRITE TOC FILE"u8.ToArray();
}

View File

@@ -35,13 +35,7 @@ namespace Aaru.DiscImages;
public sealed partial class BlindWrite5
{
/// <summary>"BWT5 STREAM FOOT"</summary>
readonly byte[] _bw5Footer =
{
0x42, 0x57, 0x54, 0x35, 0x20, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4D, 0x20, 0x46, 0x4F, 0x4F, 0x54
};
readonly byte[] _bw5Footer = "BWT5 STREAM FOOT"u8.ToArray();
/// <summary>"BWT5 STREAM SIGN"</summary>
readonly byte[] _bw5Signature =
{
0x42, 0x57, 0x54, 0x35, 0x20, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4D, 0x20, 0x53, 0x49, 0x47, 0x4E
};
readonly byte[] _bw5Signature = "BWT5 STREAM SIGN"u8.ToArray();
}

View File

@@ -48,10 +48,7 @@ namespace Aaru.DiscImages;
public sealed partial class Chd : IOpticalMediaImage, IVerifiableImage
{
/// <summary>"MComprHD"</summary>
readonly byte[] _chdTag =
{
0x4D, 0x43, 0x6F, 0x6D, 0x70, 0x72, 0x48, 0x44
};
readonly byte[] _chdTag = "MComprHD"u8.ToArray();
SectorBuilder _sectorBuilder;
uint _bytesPerHunk;
byte[] _cis;

View File

@@ -177,7 +177,7 @@ public sealed partial class CopyTape
return false;
}
byte[] footer = Encoding.ASCII.GetBytes("CPTP:EOT\n");
byte[] footer = "CPTP:EOT\n"u8.ToArray();
_dataStream.Write(footer, 0, footer.Length);
_dataStream.Flush();
@@ -231,7 +231,7 @@ public sealed partial class CopyTape
return false;
}
byte[] marker = Encoding.ASCII.GetBytes("CPTP:MRK\n");
byte[] marker = "CPTP:MRK\n"u8.ToArray();
_dataStream.Write(marker, 0, marker.Length);

View File

@@ -36,8 +36,5 @@ public sealed partial class Dim
{
/// <summary>Start of data sectors in disk image, should be 0x100</summary>
const uint DATA_OFFSET = 0x100;
readonly byte[] _headerId =
{
0x44, 0x49, 0x46, 0x43, 0x20, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x20, 0x20
};
readonly byte[] _headerId = "DIFC HEADER "u8.ToArray();
}

View File

@@ -34,7 +34,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
@@ -109,7 +108,7 @@ public sealed partial class DriDiskCopy
}
};
Array.Copy(Encoding.ASCII.GetBytes("DiskImage 2.01 (C) 1990,1991 Digital Research Inc"), 0, _footer.signature,
Array.Copy("DiskImage 2.01 (C) 1990,1991 Digital Research Inc"u8.ToArray(), 0, _footer.signature,
0, 49);
_footer.bpbcopy = _footer.bpb;

View File

@@ -44,12 +44,6 @@ public sealed partial class Parallels
const uint MAX_CACHE_SIZE = 16777216;
const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512;
const uint DEFAULT_CLUSTER_SIZE = 1048576;
readonly byte[] _extMagic =
{
0x57, 0x69, 0x74, 0x68, 0x6F, 0x75, 0x46, 0x72, 0x65, 0x53, 0x70, 0x61, 0x63, 0x45, 0x78, 0x74
};
readonly byte[] _magic =
{
0x57, 0x69, 0x74, 0x68, 0x6F, 0x75, 0x74, 0x46, 0x72, 0x65, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65
};
readonly byte[] _extMagic = "WithouFreSpacExt"u8.ToArray();
readonly byte[] _magic = "WithoutFreeSpace"u8.ToArray();
}

View File

@@ -37,12 +37,6 @@ public sealed partial class PartClone
const int CRC_SIZE = 4;
const uint MAX_CACHE_SIZE = 16777216;
const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512;
readonly byte[] _biTmAgIc =
{
0x42, 0x69, 0x54, 0x6D, 0x41, 0x67, 0x49, 0x63
};
readonly byte[] _partCloneMagic =
{
0x70, 0x61, 0x72, 0x74, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x2D, 0x69, 0x6D, 0x61, 0x67, 0x65
};
readonly byte[] _biTmAgIc = "BiTmAgIc"u8.ToArray();
readonly byte[] _partCloneMagic = "partclone-image"u8.ToArray();
}

View File

@@ -37,15 +37,9 @@ public sealed partial class SuperCardPro
/// <summary>SuperCardPro footer signature: "FPCS"</summary>
const uint FOOTER_SIGNATURE = 0x53435046;
/// <summary>SuperCardPro header signature: "SCP"</summary>
readonly byte[] _scpSignature =
{
0x53, 0x43, 0x50
};
readonly byte[] _scpSignature = "SCP"u8.ToArray();
/// <summary>SuperCardPro track header signature: "TRK"</summary>
readonly byte[] _trkSignature =
{
0x54, 0x52, 0x4B
};
readonly byte[] _trkSignature = "TRK"u8.ToArray();
/// <summary>SuperCardPro device default capture resolution: 25 nanoseconds.</summary>
const ushort DEFAULT_RESOLUTION = 25000;

View File

@@ -34,8 +34,5 @@ namespace Aaru.DiscImages;
public sealed partial class UkvFdi
{
readonly byte[] _signature =
{
0x46, 0x44, 0x49
};
readonly byte[] _signature = "FDI"u8.ToArray();
}

View File

@@ -39,7 +39,6 @@ public sealed partial class VMware
{
const uint VMWARE_EXTENT_MAGIC = 0x564D444B;
const uint VMWARE_COW_MAGIC = 0x44574F43;
const string VM_TYPE_CUSTOM = "custom";
const string VM_TYPE_MONO_SPARSE = "monolithicSparse";
const string VM_TYPE_MONO_FLAT = "monolithicFlat";
@@ -58,9 +57,7 @@ public sealed partial class VMware
const string VMFS_TYPE_RAW = "vmfsRaw";
const string VMFS_TYPE = "vmfs";
const string VM_TYPE_STREAM = "streamOptimized";
const string DDF_MAGIC = "# Disk DescriptorFile";
const string REGEX_VERSION = @"^\s*version\s*=\s*(?<version>\d+)$";
const string REGEX_CID = @"^\s*CID\s*=\s*(?<cid>[0123456789abcdef]{8})$";
const string REGEX_CID_PARENT = @"^\s*parentCID\s*=\s*(?<cid>[0123456789abcdef]{8})$";
@@ -73,22 +70,15 @@ public sealed partial class VMware
const string REGEX_DDB_HEADS = @"^\s*ddb\.geometry\.heads\s*=\s*\""(?<heads>\d+)\""$";
const string REGEX_DDB_CYLINDERS = @"^\s*ddb\.geometry\.cylinders\s*=\s*\""(?<cylinders>\d+)\""$";
const string PARENT_REGEX = @"^\s*parentFileNameHint\s*=\s*\""(?<filename>.+)\""$";
const uint FLAGS_VALID_NEW_LINE = 0x01;
const uint FLAGS_USE_REDUNDANT_TABLE = 0x02;
const uint FLAGS_ZERO_GRAIN_GTE = 0x04;
const uint FLAGS_COMPRESSION = 0x10000;
const uint FLAGS_MARKERS = 0x20000;
const ushort COMPRESSION_NONE = 0;
const ushort COMPRESSION_DEFLATE = 1;
const uint MAX_CACHE_SIZE = 16777216;
const uint SECTOR_SIZE = 512;
const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / SECTOR_SIZE;
readonly byte[] _ddfMagicBytes =
{
0x23, 0x20, 0x44, 0x69, 0x73, 0x6B, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6F, 0x72, 0x46,
0x69, 0x6C, 0x65
};
readonly byte[] _ddfMagicBytes = "# Disk DescriptorFile"u8.ToArray();
}

View File

@@ -44,6 +44,7 @@ public class Adler32
};
static readonly byte[] _expectedRandom =
{
// ReSharper disable once UseUtf8StringLiteral
0x37, 0x28, 0xd1, 0x86
};

View File

@@ -43,6 +43,7 @@ public class Crc16Ccitt
};
static readonly byte[] _expectedRandom =
{
// ReSharper disable once UseUtf8StringLiteral
0x36, 0x40
};
static readonly byte[] _expectedRandom15 =

View File

@@ -44,6 +44,7 @@ public class Crc16Ibm
};
static readonly byte[] _expectedRandom =
{
// ReSharper disable once UseUtf8StringLiteral
0x2d, 0x6d
};
static readonly byte[] _expectedRandom15 =

View File

@@ -44,6 +44,7 @@ public class Crc32
};
static readonly byte[] _expectedRandom =
{
// ReSharper disable once UseUtf8StringLiteral
0x2b, 0x6e, 0x68, 0x54
};
static readonly byte[] _expectedRandom15 =

View File

@@ -4,6 +4,8 @@ using Aaru.Helpers;
using FluentAssertions.Execution;
using NUnit.Framework;
// ReSharper disable UseUtf8StringLiteral
namespace Aaru.Tests.Devices.MultiMediaCard;
[TestFixture]

View File

@@ -42,6 +42,7 @@ public class CSD
readonly byte[] speeds =
{
// ReSharper disable once UseUtf8StringLiteral
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50
};