Use new IO byte array extensions

This commit is contained in:
Matt Nadareski
2024-10-24 00:46:28 -04:00
parent 15dba6fbbd
commit c6109fdf97
11 changed files with 52 additions and 99 deletions

View File

@@ -399,7 +399,7 @@ namespace SabreTools.FileTypes.Archives
Size = extractedsize,
CRC = headercrc,
MD5 = headermd5,
SHA1 = TextHelper.StringToByteArray(Path.GetFileNameWithoutExtension(this.Filename)),
SHA1 = ByteArrayExtensions.StringToByteArray(Path.GetFileNameWithoutExtension(this.Filename)),
Parent = Path.GetFileNameWithoutExtension(this.Filename).ToLowerInvariant(),
};
@@ -446,7 +446,7 @@ namespace SabreTools.FileTypes.Archives
baseFile = GetInfo(inputStream, keepReadOpen: true);
// Get the output file name
string outfile = Path.Combine(outDir, Utilities.GetDepotPath(TextHelper.ByteArrayToString(baseFile.SHA1), Depth) ?? string.Empty);
string outfile = Path.Combine(outDir, Utilities.GetDepotPath(ByteArrayExtensions.ByteArrayToString(baseFile.SHA1), Depth) ?? string.Empty);
// Check to see if the folder needs to be created
if (!Directory.Exists(Path.GetDirectoryName(outfile)))

View File

@@ -4,8 +4,8 @@ using System.IO;
using System.Text.RegularExpressions;
using SabreTools.Core.Tools;
using SabreTools.Hashing;
#if NET462_OR_GREATER || NETCOREAPP
using SabreTools.IO.Extensions;
#if NET462_OR_GREATER || NETCOREAPP
using SharpCompress.Compressors.Xz;
#endif
@@ -286,7 +286,7 @@ namespace SabreTools.FileTypes.Archives
BaseFile baseFile = new()
{
Filename = Path.GetFileNameWithoutExtension(this.Filename).ToLowerInvariant(),
SHA1 = TextHelper.StringToByteArray(Path.GetFileNameWithoutExtension(this.Filename)),
SHA1 = ByteArrayExtensions.StringToByteArray(Path.GetFileNameWithoutExtension(this.Filename)),
Parent = Path.GetFileNameWithoutExtension(this.Filename).ToLowerInvariant(),
};
@@ -334,7 +334,7 @@ namespace SabreTools.FileTypes.Archives
baseFile = GetInfo(inputStream, keepReadOpen: true);
// Get the output file name
string outfile = Path.Combine(outDir, Utilities.GetDepotPath(TextHelper.ByteArrayToString(baseFile.SHA1), Depth)!);
string outfile = Path.Combine(outDir, Utilities.GetDepotPath(ByteArrayExtensions.ByteArrayToString(baseFile.SHA1), Depth)!);
outfile = outfile.Replace(".gz", ".xz");
// Check to see if the folder needs to be created

View File

@@ -328,13 +328,13 @@ namespace SabreTools.FileTypes
var baseFile = new BaseFile()
{
Size = size,
CRC = hashDict.ContainsKey(HashType.CRC32) ? TextHelper.StringToByteArray(hashDict[HashType.CRC32]) : null,
MD5 = hashDict.ContainsKey(HashType.MD5) ? TextHelper.StringToByteArray(hashDict[HashType.MD5]) : null,
SHA1 = hashDict.ContainsKey(HashType.SHA1) ? TextHelper.StringToByteArray(hashDict[HashType.SHA1]) : null,
SHA256 = hashDict.ContainsKey(HashType.SHA256) ? TextHelper.StringToByteArray(hashDict[HashType.SHA256]) : null,
SHA384 = hashDict.ContainsKey(HashType.SHA384) ? TextHelper.StringToByteArray(hashDict[HashType.SHA384]) : null,
SHA512 = hashDict.ContainsKey(HashType.SHA512) ? TextHelper.StringToByteArray(hashDict[HashType.SHA512]) : null,
SpamSum = hashDict.ContainsKey(HashType.SpamSum) ? TextHelper.StringToByteArray(hashDict[HashType.SpamSum]) : null,
CRC = hashDict.ContainsKey(HashType.CRC32) ? ByteArrayExtensions.StringToByteArray(hashDict[HashType.CRC32]) : null,
MD5 = hashDict.ContainsKey(HashType.MD5) ? ByteArrayExtensions.StringToByteArray(hashDict[HashType.MD5]) : null,
SHA1 = hashDict.ContainsKey(HashType.SHA1) ? ByteArrayExtensions.StringToByteArray(hashDict[HashType.SHA1]) : null,
SHA256 = hashDict.ContainsKey(HashType.SHA256) ? ByteArrayExtensions.StringToByteArray(hashDict[HashType.SHA256]) : null,
SHA384 = hashDict.ContainsKey(HashType.SHA384) ? ByteArrayExtensions.StringToByteArray(hashDict[HashType.SHA384]) : null,
SHA512 = hashDict.ContainsKey(HashType.SHA512) ? ByteArrayExtensions.StringToByteArray(hashDict[HashType.SHA512]) : null,
SpamSum = hashDict.ContainsKey(HashType.SpamSum) ? ByteArrayExtensions.StringToByteArray(hashDict[HashType.SpamSum]) : null,
};
// Deal with the input stream