mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-24 07:45:06 +00:00
Port metadata functionality from ST
This commit is contained in:
66
SabreTools.Metadata.DatFiles/DepotInformation.cs
Normal file
66
SabreTools.Metadata.DatFiles/DepotInformation.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using SabreTools.Hashing;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles
|
||||
{
|
||||
/// <summary>
|
||||
/// Depot information wrapper
|
||||
/// </summary>
|
||||
public class DepotInformation : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Name or path of the Depot
|
||||
/// </summary>
|
||||
public string? Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use this Depot or not
|
||||
/// </summary>
|
||||
public bool IsActive { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Depot byte-depth
|
||||
/// </summary>
|
||||
public int Depth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="isActive">Set active state</param>
|
||||
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
|
||||
public DepotInformation(bool isActive, int depth)
|
||||
: this(null, isActive, depth)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="name">Identifier for the depot</param>
|
||||
/// <param name="isActive">Set active state</param>
|
||||
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
|
||||
public DepotInformation(string? name, bool isActive, int depth)
|
||||
{
|
||||
Name = name;
|
||||
IsActive = isActive;
|
||||
Depth = depth;
|
||||
|
||||
// Limit depth value
|
||||
if (Depth == int.MinValue)
|
||||
Depth = 4;
|
||||
else if (Depth < 0)
|
||||
Depth = 0;
|
||||
else if (Depth > HashType.SHA1.ZeroBytes.Length)
|
||||
Depth = HashType.SHA1.ZeroBytes.Length;
|
||||
}
|
||||
|
||||
#region Cloning
|
||||
|
||||
/// <summary>
|
||||
/// Clone the current object
|
||||
/// </summary>
|
||||
public object Clone() => new DepotInformation(Name, IsActive, Depth);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user