From 98f52803c9053a585ae32f66cf9d6dba97a00306 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 24 Nov 2025 03:23:37 +0000 Subject: [PATCH] [Refactor] Replace byte array initializations with string literals for improved readability --- Aaru.Core/Media/Detection/MMC.cs | 12 +++--------- Aaru.Filesystems/HPOFS/Consts.cs | 2 +- Aaru.Filesystems/QNX4/Consts.cs | 4 +--- Aaru.Filesystems/ReFS/Consts.cs | 2 +- Aaru.Filesystems/Reiser/Consts.cs | 6 +++--- Aaru.Filesystems/Reiser4/Consts.cs | 4 +--- Aaru.Filesystems/UDF/Consts.cs | 5 +---- Aaru.Images/DiskDupe/Constants.cs | 2 +- Aaru.Images/NHDr0/Constants.cs | 4 +--- Aaru.Images/Partimage/Constants.cs | 5 +---- Aaru.Images/Virtual98/Constants.cs | 2 +- 11 files changed, 15 insertions(+), 33 deletions(-) diff --git a/Aaru.Core/Media/Detection/MMC.cs b/Aaru.Core/Media/Detection/MMC.cs index fbf4983e6..7a6687055 100644 --- a/Aaru.Core/Media/Detection/MMC.cs +++ b/Aaru.Core/Media/Detection/MMC.cs @@ -67,19 +67,13 @@ public static class MMC const string MODULE_NAME = "Media detection"; static readonly byte[] _ps3Id = - [ - 0x50, 0x6C, 0x61, 0x79, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x33, 0x00, 0x00, 0x00, 0x00 - ]; + "PlayStation3\0\0\0\0"u8.ToArray(); static readonly byte[] _ps4Id = - [ - 0x50, 0x6C, 0x61, 0x79, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x34, 0x00, 0x00, 0x00, 0x00 - ]; + "PlayStation4\0\0\0\0"u8.ToArray(); static readonly byte[] _ps5Id = - [ - 0x50, 0x6C, 0x61, 0x79, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x35, 0x00, 0x00, 0x00, 0x00 - ]; + "PlayStation5\0\0\0\0"u8.ToArray(); static readonly byte[] _operaId = [0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01]; diff --git a/Aaru.Filesystems/HPOFS/Consts.cs b/Aaru.Filesystems/HPOFS/Consts.cs index 1b2e31014..9049bcdcf 100644 --- a/Aaru.Filesystems/HPOFS/Consts.cs +++ b/Aaru.Filesystems/HPOFS/Consts.cs @@ -35,6 +35,6 @@ public sealed partial class HPOFS // Do not translate const string FS_TYPE = "hpofs"; readonly byte[] _medinfoSignature = "MEDINFO "u8.ToArray(); - readonly byte[] _type = [0x48, 0x50, 0x4F, 0x46, 0x53, 0x00, 0x00, 0x00]; + readonly byte[] _type = "HPOFS\0\0\0"u8.ToArray(); readonly byte[] _volinfoSignature = "VOLINFO "u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Filesystems/QNX4/Consts.cs b/Aaru.Filesystems/QNX4/Consts.cs index 628fdba0f..0506f7552 100644 --- a/Aaru.Filesystems/QNX4/Consts.cs +++ b/Aaru.Filesystems/QNX4/Consts.cs @@ -37,7 +37,5 @@ public sealed partial class QNX4 { const string FS_TYPE = "qnx4"; readonly byte[] _rootDirFname = - [ - 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ]; + "/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Filesystems/ReFS/Consts.cs b/Aaru.Filesystems/ReFS/Consts.cs index e3a8cebd1..89ec17889 100644 --- a/Aaru.Filesystems/ReFS/Consts.cs +++ b/Aaru.Filesystems/ReFS/Consts.cs @@ -35,5 +35,5 @@ public sealed partial class ReFS const uint FSRS = 0x53525346; const string FS_TYPE = "refs"; - readonly byte[] _signature = [0x52, 0x65, 0x46, 0x53, 0x00, 0x00, 0x00, 0x00]; + readonly byte[] _signature = "ReFS\0\0\0\0"u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser/Consts.cs b/Aaru.Filesystems/Reiser/Consts.cs index 47c3c67b1..5563706b0 100644 --- a/Aaru.Filesystems/Reiser/Consts.cs +++ b/Aaru.Filesystems/Reiser/Consts.cs @@ -36,7 +36,7 @@ public sealed partial class Reiser const string FS_TYPE = "reiserfs"; - readonly byte[] _magic35 = [0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x46, 0x73, 0x00, 0x00]; - readonly byte[] _magic36 = [0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x32, 0x46, 0x73, 0x00]; - readonly byte[] _magicJr = [0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x33, 0x46, 0x73, 0x00]; + readonly byte[] _magic35 = "ReIsErFs\0\0"u8.ToArray(); + readonly byte[] _magic36 = "ReIsEr2Fs\0"u8.ToArray(); + readonly byte[] _magicJr = "ReIsEr3Fs\0"u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser4/Consts.cs b/Aaru.Filesystems/Reiser4/Consts.cs index 7a4a56559..0fdc5fbf1 100644 --- a/Aaru.Filesystems/Reiser4/Consts.cs +++ b/Aaru.Filesystems/Reiser4/Consts.cs @@ -37,7 +37,5 @@ public sealed partial class Reiser4 const string FS_TYPE = "reiser4"; readonly byte[] _magic = - [ - 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ]; + "ReIsEr4\0\0\0\0\0\0\0\0\0"u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Filesystems/UDF/Consts.cs b/Aaru.Filesystems/UDF/Consts.cs index a9e47a61b..2b9acf00c 100644 --- a/Aaru.Filesystems/UDF/Consts.cs +++ b/Aaru.Filesystems/UDF/Consts.cs @@ -38,8 +38,5 @@ public sealed partial class UDF { const string FS_TYPE = "udf"; readonly byte[] _magic = - [ - 0x2A, 0x4F, 0x53, 0x54, 0x41, 0x20, 0x55, 0x44, 0x46, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x6C, 0x69, 0x61, 0x6E, - 0x74, 0x00, 0x00, 0x00, 0x00 - ]; + "*OSTA UDF Compliant\0\0\0\0"u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Images/DiskDupe/Constants.cs b/Aaru.Images/DiskDupe/Constants.cs index aa6f6b4d4..e295feff3 100644 --- a/Aaru.Images/DiskDupe/Constants.cs +++ b/Aaru.Images/DiskDupe/Constants.cs @@ -39,5 +39,5 @@ public sealed partial class DiskDupe const uint TRACKMAP_OFFSET = 100; /// The header identification string - readonly byte[] _headerMagic = [0x49, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + readonly byte[] _headerMagic = "IM\0\0\0\0\0\0\0\0"u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Images/NHDr0/Constants.cs b/Aaru.Images/NHDr0/Constants.cs index 4331cfc16..a24a8810e 100644 --- a/Aaru.Images/NHDr0/Constants.cs +++ b/Aaru.Images/NHDr0/Constants.cs @@ -35,7 +35,5 @@ namespace Aaru.Images; public sealed partial class Nhdr0 { readonly byte[] _signature = - [ - 0x54, 0x39, 0x38, 0x48, 0x44, 0x44, 0x49, 0x4D, 0x41, 0x47, 0x45, 0x2E, 0x52, 0x30, 0x00 - ]; + "T98HDDIMAGE.R0\0"u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Images/Partimage/Constants.cs b/Aaru.Images/Partimage/Constants.cs index fa9e89cd8..e83f06984 100644 --- a/Aaru.Images/Partimage/Constants.cs +++ b/Aaru.Images/Partimage/Constants.cs @@ -67,8 +67,5 @@ public sealed partial class Partimage const uint MAX_CACHE_SIZE = 16777216; const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512; readonly byte[] _partimageMagic = - [ - 0x50, 0x61, 0x52, 0x74, 0x49, 0x6D, 0x41, 0x67, 0x45, 0x2D, 0x56, 0x6F, 0x4C, 0x75, 0x4D, 0x65, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - ]; + "PaRtImAgE-VoLuMe\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray(); } \ No newline at end of file diff --git a/Aaru.Images/Virtual98/Constants.cs b/Aaru.Images/Virtual98/Constants.cs index dba2e922a..d4d78388f 100644 --- a/Aaru.Images/Virtual98/Constants.cs +++ b/Aaru.Images/Virtual98/Constants.cs @@ -34,5 +34,5 @@ namespace Aaru.Images; public sealed partial class Virtual98 { - readonly byte[] _signature = [0x56, 0x48, 0x44, 0x31, 0x2E, 0x30, 0x30, 0x00]; + readonly byte[] _signature = "VHD1.00\0"u8.ToArray(); } \ No newline at end of file