Files
git.stella-ops.org/src/__Libraries/StellaOps.AuditPack/Services/AuditBundleWriter.EntryHelpers.cs

54 lines
1.5 KiB
C#

using StellaOps.AuditPack.Models;
namespace StellaOps.AuditPack.Services;
public sealed partial class AuditBundleWriter
{
private static string? AddRequiredEntry(
List<BundleEntry> entries,
List<BundleFileEntry> files,
List<ArchiveEntry> archiveEntries,
string path,
byte[]? content,
BundleContentType type)
{
return content is null
? null
: AddEntry(entries, files, archiveEntries, path, content, type);
}
private static string? AddOptionalEntry(
List<BundleEntry> entries,
List<BundleFileEntry> files,
List<ArchiveEntry> archiveEntries,
string path,
byte[]? content,
BundleContentType type)
{
return content is null
? null
: AddEntry(entries, files, archiveEntries, path, content, type);
}
private static string AddEntry(
List<BundleEntry> entries,
List<BundleFileEntry> files,
List<ArchiveEntry> archiveEntries,
string path,
byte[] content,
BundleContentType type)
{
var digest = ComputeSha256(content);
entries.Add(new BundleEntry(path, digest, content.Length));
files.Add(new BundleFileEntry
{
RelativePath = path,
Digest = digest,
SizeBytes = content.Length,
ContentType = type
});
archiveEntries.Add(new ArchiveEntry(path, content));
return digest;
}
}