mirror of
https://github.com/rvtr/ctr_test_tools.git
synced 2025-10-31 13:41:24 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_test_tools@4 6b0af911-cb57-b745-895f-eec5701120e1
89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using System;
|
||
using System.Diagnostics;
|
||
|
||
namespace TwlBackupBlock
|
||
{
|
||
/// <summary>
|
||
/// ブロックの集合です。
|
||
/// </summary>
|
||
public class Blocks : ICloneable
|
||
{
|
||
private const int NUM_BLOCKS = 7;
|
||
|
||
public Block banner;
|
||
public Block header;
|
||
public Block signature;
|
||
public Block tmd;
|
||
public Block content;
|
||
public Block saveData;
|
||
public Block subBanner;
|
||
|
||
/// <summary>
|
||
/// Blocksクラスの新しいインスタンスを初期化します。
|
||
/// </summary>
|
||
public Blocks()
|
||
{
|
||
banner = new Block();
|
||
header = new Block();
|
||
signature = new Block();
|
||
tmd = new Block();
|
||
content = new Block();
|
||
saveData = new Block();
|
||
subBanner = new Block();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 指定したインデックスのブロックにアクセスします。
|
||
/// </summary>
|
||
/// <param name="index">インデックス。</param>
|
||
/// <returns>指定したインデックスのブロック。</returns>
|
||
public Block this[int index]
|
||
{
|
||
get
|
||
{
|
||
switch (index)
|
||
{
|
||
case 0: return banner;
|
||
case 1: return header;
|
||
case 2: return signature;
|
||
case 3: return tmd;
|
||
case 4: return content;
|
||
case 5: return saveData;
|
||
case 6: return subBanner;
|
||
default:
|
||
Debug.Assert(false);
|
||
return null; // never reach
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// ブロック数(=7)を取得します。
|
||
/// </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();
|
||
newBlocks.content = (Block)content.Clone();
|
||
newBlocks.saveData = (Block)saveData.Clone();
|
||
newBlocks.subBanner = (Block)subBanner.Clone();
|
||
return newBlocks;
|
||
}
|
||
}
|
||
}
|