Add null check when creating Bktr

This commit is contained in:
Alex Barney 2018-08-25 11:30:54 -05:00
parent 1dc232e704
commit d701fdd28b
3 changed files with 2 additions and 6 deletions

View file

@ -425,7 +425,6 @@ namespace hactoolnet
using (var file = new FileStream(ctx.Options.InFile, FileMode.Open, FileAccess.Read)) using (var file = new FileStream(ctx.Options.InFile, FileMode.Open, FileAccess.Read))
{ {
var save = new Savefile(file, ctx.Logger); var save = new Savefile(file, ctx.Logger);
var layout = save.Header.Layout;
if (ctx.Options.OutDir != null) if (ctx.Options.OutDir != null)
{ {

View file

@ -20,9 +20,9 @@ namespace libhac
public Bktr(Stream patchRomfs, Stream baseRomfs, NcaSection section) public Bktr(Stream patchRomfs, Stream baseRomfs, NcaSection section)
{ {
if (section.Type != SectionType.Bktr) throw new ArgumentException("Section is not of type BKTR"); if (section.Type != SectionType.Bktr) throw new ArgumentException("Section is not of type BKTR");
Patch = patchRomfs ?? throw new NullReferenceException($"{nameof(patchRomfs)} cannot be null");
Base = baseRomfs ?? throw new NullReferenceException($"{nameof(baseRomfs)} cannot be null");
Patch = patchRomfs;
Base = baseRomfs;
IvfcLevelHeader level5 = section.Header.Bktr.IvfcHeader.LevelHeaders[5]; IvfcLevelHeader level5 = section.Header.Bktr.IvfcHeader.LevelHeaders[5];
Length = level5.LogicalOffset + level5.HashDataSize; Length = level5.LogicalOffset + level5.HashDataSize;

View file

@ -1,8 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
namespace libhac namespace libhac
{ {