mirror of
https://github.com/rvtr/ctr_test_tools.git
synced 2025-06-19 00:55:31 -04:00

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_test_tools@33 6b0af911-cb57-b745-895f-eec5701120e1
119 lines
3.6 KiB
C#
119 lines
3.6 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
|
|
namespace TwlBackupBlock
|
|
{
|
|
public enum BkpType
|
|
{
|
|
NORMAL,
|
|
WITH_PRIVATE_SAVE,
|
|
LEGACY
|
|
};
|
|
|
|
/// <summary>
|
|
/// ブロックの集合です。
|
|
/// </summary>
|
|
public class Blocks : ICloneable
|
|
{
|
|
private const int NUM_BLOCKS = 15;
|
|
|
|
public Block banner;
|
|
public Block header;
|
|
public Block signature;
|
|
public Block tmd;
|
|
public Block[] content;
|
|
public Block publicSave;
|
|
public Block subBanner;
|
|
public Block privateSave;
|
|
|
|
/// <summary>
|
|
/// Blocksクラスの新しいインスタンスを初期化します。
|
|
/// </summary>
|
|
public Blocks()
|
|
{
|
|
banner = new Block();
|
|
header = new Block();
|
|
signature = new Block();
|
|
tmd = new Block();
|
|
content = new Block[HeaderBody.MAX_CONTENTS];
|
|
for (int i = 0; i < HeaderBody.MAX_CONTENTS; i++)
|
|
{
|
|
content[i] = new Block();
|
|
}
|
|
publicSave = new Block();
|
|
subBanner = new Block();
|
|
privateSave = new Block();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 指定したインデックスのブロックにアクセスします。
|
|
/// </summary>
|
|
/// <param name="index">インデックス。</param>
|
|
/// <returns>指定したインデックスのブロック。</returns>
|
|
public Block this[int index]
|
|
{
|
|
get
|
|
{
|
|
if (4 <= index && index < 4 + HeaderBody.MAX_CONTENTS)
|
|
{
|
|
return content[index - 4];
|
|
}
|
|
else
|
|
{
|
|
switch (index)
|
|
{
|
|
case 0: return banner;
|
|
case 1: return header;
|
|
case 2: return signature;
|
|
case 3: return tmd;
|
|
case 12: return publicSave;
|
|
case 13: return subBanner;
|
|
case 14: return privateSave;
|
|
default:
|
|
Debug.Assert(false);
|
|
return null; // never reach
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ブロック数を取得します。
|
|
/// </summary>
|
|
public int Length
|
|
{
|
|
get
|
|
{
|
|
return NUM_BLOCKS;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Blocksのディープコピーを作成します。
|
|
/// </summary>
|
|
/// <returns>Blocksのコピー</returns>
|
|
public object Clone()
|
|
{
|
|
Blocks newBlocks = new Blocks();
|
|
newBlocks.banner = (Block)banner.Clone();
|
|
newBlocks.header = (Block)header.Clone();
|
|
newBlocks.signature = (Block)signature.Clone();
|
|
newBlocks.tmd = (Block)tmd.Clone();
|
|
for (int i = 0; i < HeaderBody.MAX_CONTENTS; i++)
|
|
{
|
|
if (content[i].body != null)
|
|
{
|
|
newBlocks.content[i] = (Block)content[i].Clone();
|
|
}
|
|
}
|
|
newBlocks.publicSave = (Block)publicSave.Clone();
|
|
newBlocks.subBanner = (Block)subBanner.Clone();
|
|
if (privateSave.body != null)
|
|
{
|
|
newBlocks.privateSave = (Block)privateSave.Clone();
|
|
}
|
|
return newBlocks;
|
|
}
|
|
}
|
|
}
|