mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-05 22:01:33 +00:00
Add editorconfig, fix issues
This commit is contained in:
167
.editorconfig
Normal file
167
.editorconfig
Normal file
@@ -0,0 +1,167 @@
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
# Indentation and spacing
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
tab_width = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# New line preferences
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
max_line_length = unset
|
||||
|
||||
# using directive preferences
|
||||
csharp_using_directive_placement = outside_namespace
|
||||
dotnet_diagnostic.IDE0005.severity = error
|
||||
|
||||
# Code-block preferences
|
||||
csharp_style_namespace_declarations = block_scoped
|
||||
csharp_style_prefer_method_group_conversion = true
|
||||
csharp_style_prefer_top_level_statements = false
|
||||
|
||||
# Expression-level preferences
|
||||
csharp_prefer_simple_default_expression = true
|
||||
csharp_style_inlined_variable_declaration = true
|
||||
csharp_style_unused_value_assignment_preference = discard_variable
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable
|
||||
dotnet_diagnostic.IDE0001.severity = warning
|
||||
dotnet_diagnostic.IDE0002.severity = warning
|
||||
dotnet_diagnostic.IDE0004.severity = warning
|
||||
dotnet_diagnostic.IDE0010.severity = error
|
||||
dotnet_diagnostic.IDE0051.severity = warning
|
||||
dotnet_diagnostic.IDE0052.severity = warning
|
||||
dotnet_diagnostic.IDE0072.severity = warning
|
||||
dotnet_diagnostic.IDE0080.severity = warning
|
||||
dotnet_diagnostic.IDE0100.severity = error
|
||||
dotnet_diagnostic.IDE0110.severity = error
|
||||
dotnet_diagnostic.IDE0120.severity = warning
|
||||
dotnet_diagnostic.IDE0121.severity = warning
|
||||
dotnet_diagnostic.IDE0240.severity = error
|
||||
dotnet_diagnostic.IDE0241.severity = error
|
||||
dotnet_style_coalesce_expression = true
|
||||
dotnet_style_namespace_match_folder = false
|
||||
dotnet_style_null_propagation = true
|
||||
dotnet_style_prefer_auto_properties = true
|
||||
dotnet_style_prefer_collection_expression = when_types_loosely_match
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
|
||||
dotnet_style_prefer_compound_assignment = true
|
||||
csharp_style_prefer_simple_property_accessors = true
|
||||
dotnet_style_prefer_simplified_interpolation = true
|
||||
dotnet_style_prefer_simplified_boolean_expressions = true
|
||||
csharp_style_prefer_unbound_generic_type_in_nameof = true
|
||||
|
||||
# Field preferences
|
||||
dotnet_diagnostic.IDE0044.severity = warning
|
||||
dotnet_style_readonly_field = true
|
||||
|
||||
# Language keyword vs. framework types preferences
|
||||
dotnet_diagnostic.IDE0049.severity = error
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true
|
||||
dotnet_style_predefined_type_for_member_access = true
|
||||
|
||||
# Modifier preferences
|
||||
csharp_prefer_static_local_function = true
|
||||
csharp_style_prefer_readonly_struct = true
|
||||
dotnet_diagnostic.IDE0036.severity = warning
|
||||
dotnet_diagnostic.IDE0040.severity = error
|
||||
dotnet_diagnostic.IDE0380.severity = error
|
||||
dotnet_style_require_accessibility_modifiers = always
|
||||
|
||||
# New-line preferences
|
||||
dotnet_diagnostic.IDE2000.severity = warning
|
||||
dotnet_diagnostic.IDE2002.severity = warning
|
||||
dotnet_diagnostic.IDE2003.severity = warning
|
||||
dotnet_diagnostic.IDE2004.severity = warning
|
||||
dotnet_diagnostic.IDE2005.severity = warning
|
||||
dotnet_diagnostic.IDE2006.severity = warning
|
||||
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
|
||||
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
|
||||
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false
|
||||
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
|
||||
dotnet_style_allow_multiple_blank_lines_experimental = false
|
||||
dotnet_style_allow_statement_immediately_after_block_experimental = false
|
||||
|
||||
# Null-checking preferences
|
||||
csharp_style_conditional_delegate_call = true
|
||||
|
||||
# Parameter preferences
|
||||
dotnet_code_quality_unused_parameters = all
|
||||
dotnet_diagnostic.IDE0280.severity = error
|
||||
|
||||
# Parentheses preferences
|
||||
dotnet_diagnostic.IDE0047.severity = warning
|
||||
dotnet_diagnostic.IDE0048.severity = warning
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_other_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
|
||||
|
||||
# Pattern-matching preferences
|
||||
dotnet_diagnostic.IDE0019.severity = warning
|
||||
dotnet_diagnostic.IDE0020.severity = warning
|
||||
dotnet_diagnostic.IDE0038.severity = warning
|
||||
dotnet_diagnostic.IDE0066.severity = none
|
||||
dotnet_diagnostic.IDE0083.severity = warning
|
||||
dotnet_diagnostic.IDE0260.severity = warning
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true
|
||||
csharp_style_prefer_not_pattern = true
|
||||
csharp_style_prefer_pattern_matching = true
|
||||
|
||||
# this. and Me. preferences
|
||||
dotnet_style_qualification_for_event = false
|
||||
dotnet_style_qualification_for_field = false
|
||||
dotnet_style_qualification_for_method = false
|
||||
dotnet_style_qualification_for_property = false
|
||||
|
||||
# var preferences
|
||||
csharp_style_var_for_built_in_types = false
|
||||
csharp_style_var_when_type_is_apparent = true
|
||||
|
||||
# .NET formatting options
|
||||
dotnet_separate_import_directive_groups = false
|
||||
dotnet_sort_system_directives_first = true
|
||||
|
||||
# C# formatting options
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_case_contents_when_block = false
|
||||
csharp_indent_labels = one_less_than_current
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
csharp_preserve_single_line_blocks = true
|
||||
csharp_preserve_single_line_statements = true
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_around_declaration_statements = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_between_square_brackets = false
|
||||
@@ -60,9 +60,9 @@ namespace SabreTools.Serialization.CrossModel
|
||||
SHA1 = item.ReadString(Data.Models.Metadata.Disk.SHA1Key),
|
||||
};
|
||||
|
||||
if (item[Data.Models.Metadata.Disk.StatusKey] as string == "nodump")
|
||||
if ((item[Data.Models.Metadata.Disk.StatusKey] as string) == "nodump")
|
||||
row.NoGoodDumpKnown = true;
|
||||
else if (item[Data.Models.Metadata.Disk.StatusKey] as string == "baddump")
|
||||
else if ((item[Data.Models.Metadata.Disk.StatusKey] as string) == "baddump")
|
||||
row.Bad = true;
|
||||
|
||||
return row;
|
||||
@@ -81,9 +81,9 @@ namespace SabreTools.Serialization.CrossModel
|
||||
SHA1 = item.ReadString(Data.Models.Metadata.Rom.SHA1Key),
|
||||
};
|
||||
|
||||
if (item[Data.Models.Metadata.Rom.StatusKey] as string == "nodump")
|
||||
if ((item[Data.Models.Metadata.Rom.StatusKey] as string) == "nodump")
|
||||
row.NoGoodDumpKnown = true;
|
||||
else if (item[Data.Models.Metadata.Rom.StatusKey] as string == "baddump")
|
||||
else if ((item[Data.Models.Metadata.Rom.StatusKey] as string) == "baddump")
|
||||
row.Bad = true;
|
||||
|
||||
return row;
|
||||
|
||||
@@ -86,6 +86,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
case SCCPlusCart sccPlusCart:
|
||||
dump[Data.Models.Metadata.Dump.SCCPlusCartKey] = ConvertToInternalModel(sccPlusCart);
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
case Data.Models.Metadata.Rom rom:
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = new Data.Models.Metadata.Rom[] { rom };
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
return machine;
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace SabreTools.Data.Extensions
|
||||
// Ignore the actual error
|
||||
return SectorMode.UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -56,6 +55,7 @@ namespace SabreTools.Data.Extensions
|
||||
{
|
||||
return mode switch
|
||||
{
|
||||
SectorMode.UNKNOWN => Constants.Mode0DataSize,
|
||||
SectorMode.MODE0 => Constants.Mode0DataSize,
|
||||
SectorMode.MODE1 => Constants.Mode1DataSize,
|
||||
SectorMode.MODE2 => Constants.Mode0DataSize,
|
||||
@@ -74,6 +74,7 @@ namespace SabreTools.Data.Extensions
|
||||
{
|
||||
return mode switch
|
||||
{
|
||||
SectorMode.UNKNOWN => Constants.Mode0UserDataEnd,
|
||||
SectorMode.MODE0 => Constants.Mode0UserDataEnd, // TODO: Support flexible sector length (2352)
|
||||
SectorMode.MODE1 => Constants.Mode1UserDataEnd,
|
||||
SectorMode.MODE2 => Constants.Mode0UserDataEnd, // TODO: Support flexible sector length (2352)
|
||||
@@ -92,6 +93,7 @@ namespace SabreTools.Data.Extensions
|
||||
{
|
||||
return mode switch
|
||||
{
|
||||
SectorMode.UNKNOWN => Constants.Mode0UserDataStart,
|
||||
SectorMode.MODE0 => Constants.Mode0UserDataStart,
|
||||
SectorMode.MODE1 => Constants.Mode1UserDataStart,
|
||||
SectorMode.MODE2 => Constants.Mode0UserDataStart,
|
||||
@@ -114,7 +116,9 @@ namespace SabreTools.Data.Extensions
|
||||
private SectorMode _currentMode = SectorMode.UNKNOWN;
|
||||
private long _userDataStart = Constants.Mode1UserDataStart;
|
||||
private long _userDataEnd = Constants.Mode1UserDataEnd;
|
||||
#pragma warning disable IDE0044
|
||||
private long _isoSectorSize = Constants.Mode1DataSize;
|
||||
#pragma warning restore IDE0044
|
||||
|
||||
public ISO9660Stream(Stream inputStream)
|
||||
{
|
||||
@@ -138,7 +142,7 @@ namespace SabreTools.Data.Extensions
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override long Length
|
||||
=> (_baseStream.Length / Constants.CDROMSectorSize) * _isoSectorSize;
|
||||
=> _baseStream.Length / Constants.CDROMSectorSize * _isoSectorSize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetLength(long value)
|
||||
@@ -167,7 +171,7 @@ namespace SabreTools.Data.Extensions
|
||||
SetState(_position);
|
||||
|
||||
// Get the number of ISO sectors before current position
|
||||
long isoPosition = (_position / Constants.CDROMSectorSize) * _isoSectorSize;
|
||||
long isoPosition = _position / Constants.CDROMSectorSize * _isoSectorSize;
|
||||
|
||||
// Add the within-sector position
|
||||
long remainder = _position % Constants.CDROMSectorSize;
|
||||
@@ -242,7 +246,7 @@ namespace SabreTools.Data.Extensions
|
||||
// Update state for base stream
|
||||
_position = _baseStream.Position;
|
||||
if (bytesToRead == (_isoSectorSize - sectorOffset))
|
||||
_position += (Constants.CDROMSectorSize - _userDataEnd) + _userDataStart;
|
||||
_position += Constants.CDROMSectorSize - _userDataEnd + _userDataStart;
|
||||
|
||||
// Update state for ISO stream
|
||||
totalRead += bytesRead;
|
||||
@@ -268,7 +272,7 @@ namespace SabreTools.Data.Extensions
|
||||
};
|
||||
|
||||
// Get the number of ISO sectors before current position
|
||||
long newPosition = (targetPosition / _isoSectorSize) * Constants.CDROMSectorSize;
|
||||
long newPosition = targetPosition / _isoSectorSize * Constants.CDROMSectorSize;
|
||||
|
||||
// Set the current sector's mode and user data location
|
||||
SetState(newPosition);
|
||||
|
||||
@@ -929,7 +929,7 @@ namespace SabreTools.Data.Extensions
|
||||
stringFileInfo.Key = data.ReadNullTerminatedUnicodeString(ref offset) ?? string.Empty;
|
||||
if (stringFileInfo.Key != "StringFileInfo")
|
||||
{
|
||||
offset -= 6 + ((stringFileInfo.Key?.Length ?? 0 + 1) * 2);
|
||||
offset -= 6 + (((stringFileInfo.Key?.Length ?? 0) + 1) * 2);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1053,7 +1053,7 @@ namespace SabreTools.Data.Extensions
|
||||
varData.Key = data.ReadNullTerminatedUnicodeString(ref offset) ?? string.Empty;
|
||||
if (varData.Key != "Translation")
|
||||
{
|
||||
offset -= 6 + ((varData.Key?.Length ?? 0 + 1) * 2);
|
||||
offset -= 6 + (((varData.Key?.Length ?? 0) + 1) * 2);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace SabreTools.Data.Extensions
|
||||
/// </summary>
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, char? value, string prefixString)
|
||||
{
|
||||
string valueString = (value is null ? "[NULL]" : value.Value.ToString());
|
||||
string valueString = value is null ? "[NULL]" : value.Value.ToString();
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace SabreTools.Data.Extensions
|
||||
/// </summary>
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte[]? value, string prefixString)
|
||||
{
|
||||
string valueString = (value is null ? "[NULL]" : BitConverter.ToString(value).Replace('-', ' '));
|
||||
string valueString = value is null ? "[NULL]" : BitConverter.ToString(value).Replace('-', ' ');
|
||||
if (valueString.Length == 0)
|
||||
return sb.AppendLine($"{prefixString}: [EMPTY]");
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace SabreTools.Data.Extensions
|
||||
/// </summary>
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte[]? value, string prefixString, Encoding encoding)
|
||||
{
|
||||
string valueString = (value is null ? "[NULL]" : encoding.GetString(value).Replace("\0", string.Empty));
|
||||
string valueString = value is null ? "[NULL]" : encoding.GetString(value).Replace("\0", string.Empty);
|
||||
if (valueString.Length == 0)
|
||||
return sb.AppendLine($"{prefixString}: [EMPTY]");
|
||||
|
||||
|
||||
@@ -148,6 +148,27 @@ namespace SabreTools.Data.Extensions
|
||||
formatBuilder.Append($", Value: {Encoding.Unicode.GetString(valueAsByteArray)}");
|
||||
break;
|
||||
|
||||
// Unimplemented
|
||||
case ASN1Type.V_ASN1_EOC:
|
||||
case ASN1Type.V_ASN1_NULL:
|
||||
case ASN1Type.V_ASN1_OBJECT_DESCRIPTOR:
|
||||
case ASN1Type.V_ASN1_EXTERNAL:
|
||||
case ASN1Type.V_ASN1_REAL:
|
||||
case ASN1Type.V_ASN1_ENUMERATED:
|
||||
case ASN1Type.V_ASN1_SEQUENCE:
|
||||
case ASN1Type.V_ASN1_SET:
|
||||
case ASN1Type.V_ASN1_NUMERICSTRING:
|
||||
case ASN1Type.V_ASN1_VIDEOTEXSTRING:
|
||||
case ASN1Type.V_ASN1_GENERALIZEDTIME:
|
||||
case ASN1Type.V_ASN1_GRAPHICSTRING:
|
||||
case ASN1Type.V_ASN1_ISO64STRING:
|
||||
case ASN1Type.V_ASN1_GENERALSTRING:
|
||||
case ASN1Type.V_ASN1_UNIVERSALSTRING:
|
||||
case ASN1Type.V_ASN1_PRIMITIVE_TAG:
|
||||
case ASN1Type.V_ASN1_CONSTRUCTED:
|
||||
case ASN1Type.V_ASN1_APPLICATION:
|
||||
case ASN1Type.V_ASN1_CONTEXT_SPECIFIC:
|
||||
case ASN1Type.V_ASN1_PRIVATE:
|
||||
default:
|
||||
formatBuilder.Append($", Value: {BitConverter.ToString(valueAsByteArray).Replace('-', ' ')}");
|
||||
break;
|
||||
|
||||
@@ -12,6 +12,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <param name="data">Byte array to parse</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
TModel? Deserialize(byte[]? data, int offset);
|
||||
public TModel? Deserialize(byte[]? data, int offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <typeparam name="T">Type of object to serialize from</typeparam>
|
||||
/// <param name="obj">Data to serialize</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
byte[]? SerializeArray(TModel? obj);
|
||||
public byte[]? SerializeArray(TModel? obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <typeparam name="U">Type of object to deserialize from</typeparam>
|
||||
/// <param name="obj">Object to deserialize from</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
TSource? Deserialize(TDest? obj);
|
||||
public TSource? Deserialize(TDest? obj);
|
||||
|
||||
/// <summary>
|
||||
/// Serialize a <typeparamref name="TSource"/> into <typeparamref name="TDest"/>
|
||||
@@ -21,6 +21,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <typeparam name="U">Type of object to serialize to</typeparam>
|
||||
/// <param name="obj">Object to serialize from</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
TDest? Serialize(TSource? obj);
|
||||
public TDest? Serialize(TSource? obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <typeparam name="T">Type of object to deserialize to</typeparam>
|
||||
/// <param name="path">Path to deserialize from</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
TModel? Deserialize(string? path);
|
||||
public TModel? Deserialize(string? path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <param name="obj">Data to serialize</param>
|
||||
/// <param name="path">Path to the file to serialize to</param>
|
||||
/// <returns>True on successful serialization, false otherwise</returns>
|
||||
bool SerializeFile(TModel? obj, string? path);
|
||||
public bool SerializeFile(TModel? obj, string? path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <typeparam name="T">Type of object to deserialize to</typeparam>
|
||||
/// <param name="data">Stream to parse</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
TModel? Deserialize(System.IO.Stream? data);
|
||||
public TModel? Deserialize(System.IO.Stream? data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <typeparam name="T">Type of object to serialize from</typeparam>
|
||||
/// <param name="obj">Data to serialize</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
System.IO.Stream? SerializeStream(TModel? obj);
|
||||
public System.IO.Stream? SerializeStream(TModel? obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <typeparam name="T">Type of object to deserialize to</typeparam>
|
||||
/// <param name="str">String to deserialize from</param>
|
||||
/// <returns>Filled object on success, null on error</returns>
|
||||
TModel? Deserialize(string? str);
|
||||
public TModel? Deserialize(string? str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces
|
||||
/// <typeparam name="T">Type of object to serialize from</typeparam>
|
||||
/// <param name="obj">Data to serialize</param>
|
||||
/// <returns>Filled string on successful serialization, null otherwise</returns>
|
||||
string? Serialize(TModel? obj);
|
||||
public string? Serialize(TModel? obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +86,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return oidPath;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// itu-t, ccitt, itu-r
|
||||
#region 0.*
|
||||
// itu-t, ccitt, itu-r
|
||||
#region 0.*
|
||||
|
||||
oid_0:
|
||||
|
||||
@@ -106,8 +106,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// recommendation
|
||||
#region 0.0.*
|
||||
// recommendation
|
||||
#region 0.0.*
|
||||
|
||||
oid_0_0:
|
||||
|
||||
@@ -143,12 +143,12 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// iso
|
||||
#region 1.*
|
||||
// iso
|
||||
#region 1.*
|
||||
|
||||
oid_1:
|
||||
|
||||
@@ -163,8 +163,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// member-body
|
||||
#region 1.2.*
|
||||
// member-body
|
||||
#region 1.2.*
|
||||
|
||||
oid_1_2:
|
||||
|
||||
@@ -202,12 +202,12 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// joint-iso-itu-t, joint-iso-ccitt
|
||||
#region 2.*
|
||||
// joint-iso-itu-t, joint-iso-ccitt
|
||||
#region 2.*
|
||||
|
||||
oid_2:
|
||||
|
||||
@@ -233,8 +233,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// country
|
||||
#region 2.16.*
|
||||
// country
|
||||
#region 2.16.*
|
||||
|
||||
oid_2_16:
|
||||
|
||||
@@ -444,10 +444,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// uuid [TODO: Requires 128-bit values]
|
||||
#region 2.25.*
|
||||
// uuid [TODO: Requires 128-bit values]
|
||||
#region 2.25.*
|
||||
|
||||
oid_2_25:
|
||||
|
||||
@@ -466,10 +466,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// telebiometrics
|
||||
#region 2.42.*
|
||||
// telebiometrics
|
||||
#region 2.42.*
|
||||
|
||||
oid_2_42:
|
||||
|
||||
@@ -484,8 +484,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// modules
|
||||
#region 2.42.0.*
|
||||
// modules
|
||||
#region 2.42.0.*
|
||||
|
||||
oid_2_42_0:
|
||||
|
||||
@@ -497,8 +497,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// main
|
||||
#region 2.42.0.0.*
|
||||
// main
|
||||
#region 2.42.0.0.*
|
||||
|
||||
oid_2_42_0_0:
|
||||
|
||||
@@ -510,12 +510,12 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// tmm
|
||||
#region 2.42.1.*
|
||||
// tmm
|
||||
#region 2.42.1.*
|
||||
|
||||
oid_2_42_1:
|
||||
|
||||
@@ -531,8 +531,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// modules
|
||||
#region 2.42.1.0.*
|
||||
// modules
|
||||
#region 2.42.1.0.*
|
||||
|
||||
oid_2_42_1_0:
|
||||
|
||||
@@ -544,8 +544,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// main
|
||||
#region 2.42.1.0.0.*
|
||||
// main
|
||||
#region 2.42.1.0.0.*
|
||||
|
||||
oid_2_42_1_0_0:
|
||||
|
||||
@@ -557,12 +557,12 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// measures, metric
|
||||
#region 2.42.1.1.*
|
||||
// measures, metric
|
||||
#region 2.42.1.1.*
|
||||
|
||||
oid_2_42_1_1:
|
||||
|
||||
@@ -578,8 +578,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// quantities
|
||||
#region 2.42.1.1.1.*
|
||||
// quantities
|
||||
#region 2.42.1.1.1.*
|
||||
|
||||
oid_2_42_1_1_1:
|
||||
|
||||
@@ -595,10 +595,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// methods
|
||||
#region 2.42.1.1.5.*
|
||||
// methods
|
||||
#region 2.42.1.1.5.*
|
||||
|
||||
oid_2_42_1_1_5:
|
||||
|
||||
@@ -614,12 +614,12 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// fields-of-study, scientific
|
||||
#region 2.42.1.2.*
|
||||
// fields-of-study, scientific
|
||||
#region 2.42.1.2.*
|
||||
|
||||
oid_2_42_1_2:
|
||||
|
||||
@@ -635,10 +635,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// modalities, sensory
|
||||
#region 2.42.1.3.*
|
||||
// modalities, sensory
|
||||
#region 2.42.1.3.*
|
||||
|
||||
oid_2_42_1_3:
|
||||
|
||||
@@ -656,12 +656,12 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// human-physiology
|
||||
#region 2.42.2.*
|
||||
// human-physiology
|
||||
#region 2.42.2.*
|
||||
|
||||
oid_2_42_2:
|
||||
|
||||
@@ -675,8 +675,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// modules
|
||||
#region 2.42.2.0.*
|
||||
// modules
|
||||
#region 2.42.2.0.*
|
||||
|
||||
oid_2_42_2_0:
|
||||
|
||||
@@ -688,8 +688,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// main
|
||||
#region 2.42.2.0.0.*
|
||||
// main
|
||||
#region 2.42.2.0.0.*
|
||||
|
||||
oid_2_42_2_0_0:
|
||||
|
||||
@@ -701,12 +701,12 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// symbols
|
||||
#region 2.42.2.1.*
|
||||
// symbols
|
||||
#region 2.42.2.1.*
|
||||
|
||||
oid_2_42_2_1:
|
||||
|
||||
@@ -731,12 +731,12 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// obj-cat, telehealth, e-health-protocol, th
|
||||
#region 2.42.3.*
|
||||
// obj-cat, telehealth, e-health-protocol, th
|
||||
#region 2.42.3.*
|
||||
|
||||
oid_2_42_3:
|
||||
|
||||
@@ -758,8 +758,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// obj-cat, telehealth, e-health-protocol, th
|
||||
#region 2.42.3.0.*
|
||||
// obj-cat, telehealth, e-health-protocol, th
|
||||
#region 2.42.3.0.*
|
||||
|
||||
oid_2_42_3_0:
|
||||
|
||||
@@ -776,8 +776,8 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
default: return $"{oidPath}/{values[index - 1]}";
|
||||
}
|
||||
|
||||
// identification
|
||||
#region 2.42.3.0.0.*
|
||||
// identification
|
||||
#region 2.42.3.0.0.*
|
||||
|
||||
oid_2_42_3_0_0:
|
||||
|
||||
@@ -789,10 +789,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// set-up
|
||||
#region 2.42.3.0.1.*
|
||||
// set-up
|
||||
#region 2.42.3.0.1.*
|
||||
|
||||
oid_2_42_3_0_1:
|
||||
|
||||
@@ -804,10 +804,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// send-and-ack
|
||||
#region 2.42.3.0.2.*
|
||||
// send-and-ack
|
||||
#region 2.42.3.0.2.*
|
||||
|
||||
oid_2_42_3_0_2:
|
||||
|
||||
@@ -819,10 +819,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// command-response
|
||||
#region 2.42.3.0.3.*
|
||||
// command-response
|
||||
#region 2.42.3.0.3.*
|
||||
|
||||
oid_2_42_3_0_3:
|
||||
|
||||
@@ -834,10 +834,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// quantity-and-units
|
||||
#region 2.42.3.0.4.*
|
||||
// quantity-and-units
|
||||
#region 2.42.3.0.4.*
|
||||
|
||||
oid_2_42_3_0_4:
|
||||
|
||||
@@ -849,10 +849,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// examples
|
||||
#region 2.42.3.0.5.*
|
||||
// examples
|
||||
#region 2.42.3.0.5.*
|
||||
|
||||
oid_2_42_3_0_5:
|
||||
|
||||
@@ -865,16 +865,16 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// cybersecurity
|
||||
#region 2.48.*
|
||||
// cybersecurity
|
||||
#region 2.48.*
|
||||
|
||||
oid_2_48:
|
||||
|
||||
@@ -887,10 +887,10 @@ namespace SabreTools.Data.ObjectIdentifier
|
||||
_ => $"{oidPath}/{values[index - 1]}",
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// alerting
|
||||
#region 2.49.*
|
||||
// alerting
|
||||
#region 2.49.*
|
||||
|
||||
oid_2_49:
|
||||
|
||||
|
||||
@@ -81,6 +81,14 @@ namespace SabreTools.Serialization.Readers
|
||||
RecordType.VerifyMediaKey => ParseVerifyMediaKeyRecord(data),
|
||||
RecordType.Copyright => ParseCopyrightRecord(data),
|
||||
|
||||
// Unimplemented
|
||||
RecordType.MediaKeyVariantData => ParseGenericRecord(data),
|
||||
RecordType.Unknown0x28_AACS2 => ParseGenericRecord(data),
|
||||
RecordType.DriveRevocationList_AACS2 => ParseGenericRecord(data),
|
||||
RecordType.HostRevocationList_AACS2 => ParseGenericRecord(data),
|
||||
RecordType.VerifyMediaKey_AACS2 => ParseGenericRecord(data),
|
||||
RecordType.EmptyRecord0xF8_AACS2 => ParseGenericRecord(data),
|
||||
|
||||
// Unknown record type
|
||||
_ => ParseGenericRecord(data),
|
||||
};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
@@ -52,6 +51,7 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(initialOffset + lumpEntry.Offset, SeekOrigin.Begin);
|
||||
|
||||
// Read according to the lump type
|
||||
#pragma warning disable IDE0010
|
||||
switch ((LumpType)l)
|
||||
{
|
||||
case LumpType.LUMP_ENTITIES:
|
||||
@@ -102,10 +102,12 @@ namespace SabreTools.Serialization.Readers
|
||||
case LumpType.LUMP_MODELS:
|
||||
file.ModelsLump = ParseModelsLump(data, lumpEntry.Offset, lumpEntry.Length);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unsupported LumpType value, ignore
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -174,11 +176,13 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Mins[i] = data.ReadInt16LittleEndian();
|
||||
}
|
||||
|
||||
obj.Maxs = new short[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
obj.Maxs[i] = data.ReadInt16LittleEndian();
|
||||
}
|
||||
|
||||
obj.FirstMarkSurfaceIndex = data.ReadUInt16LittleEndian();
|
||||
obj.MarkSurfacesCount = data.ReadUInt16LittleEndian();
|
||||
obj.AmbientLevels = data.ReadBytes(4);
|
||||
@@ -218,6 +222,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.HeadnodesIndex[i] = data.ReadInt32LittleEndian();
|
||||
}
|
||||
|
||||
obj.VisLeafsCount = data.ReadInt32LittleEndian();
|
||||
obj.FirstFaceIndex = data.ReadInt32LittleEndian();
|
||||
obj.FacesCount = data.ReadInt32LittleEndian();
|
||||
@@ -240,16 +245,19 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Children[i] = data.ReadUInt16LittleEndian();
|
||||
}
|
||||
|
||||
obj.Mins = new ushort[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
obj.Mins[i] = data.ReadUInt16LittleEndian();
|
||||
}
|
||||
|
||||
obj.Maxs = new ushort[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
obj.Maxs[i] = data.ReadUInt16LittleEndian();
|
||||
}
|
||||
|
||||
obj.FirstFace = data.ReadUInt16LittleEndian();
|
||||
obj.FaceCount = data.ReadUInt16LittleEndian();
|
||||
|
||||
|
||||
@@ -190,6 +190,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case 4:
|
||||
directorySectorCount = fileHeader.NumberOfDirectorySectors;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
// Loop through and add the directory sectors
|
||||
|
||||
@@ -255,6 +255,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Compressors[i] = (CodecType)data.ReadUInt32BigEndian();
|
||||
}
|
||||
|
||||
obj.LogicalBytes = data.ReadUInt64BigEndian();
|
||||
obj.MapOffset = data.ReadUInt64BigEndian();
|
||||
obj.MetaOffset = data.ReadUInt64BigEndian();
|
||||
|
||||
@@ -426,6 +426,7 @@ namespace SabreTools.Serialization.Readers
|
||||
var contentInfoRecord = ParseContentInfoRecord(data);
|
||||
obj.ContentInfoRecords[i] = contentInfoRecord;
|
||||
}
|
||||
|
||||
obj.ContentChunkRecords = new ContentChunkRecord[obj.ContentCount];
|
||||
for (int i = 0; i < obj.ContentCount; i++)
|
||||
{
|
||||
|
||||
@@ -149,8 +149,22 @@ namespace SabreTools.Serialization.Readers
|
||||
dat.Info?.Source = [.. sources];
|
||||
sources.Clear();
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case CmpRowType.TopLevel:
|
||||
case CmpRowType.Standalone:
|
||||
case CmpRowType.Internal:
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
// If we're at the root
|
||||
@@ -177,6 +191,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "set":
|
||||
game = new Set();
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,6 +251,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "forcepacking":
|
||||
dat.ClrMamePro.ForcePacking = reader.Standalone?.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,6 +307,9 @@ namespace SabreTools.Serialization.Readers
|
||||
};
|
||||
samples.Add(sample);
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +325,9 @@ namespace SabreTools.Serialization.Readers
|
||||
sources.Add(source);
|
||||
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +408,8 @@ namespace SabreTools.Serialization.Readers
|
||||
game.Driver = driver;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -467,6 +494,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "default":
|
||||
biosset.Default = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,6 +599,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "mia":
|
||||
rom.MIA = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,6 +641,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "flags":
|
||||
disk.Flags = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,6 +680,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "spamsum":
|
||||
media.SpamSum = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,6 +707,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "name":
|
||||
sample.Name = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,6 +734,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "name":
|
||||
archive.Name = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,6 +770,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "clock":
|
||||
chip.Clock = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,6 +815,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "freq":
|
||||
video.Freq = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,6 +842,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "channels":
|
||||
sound.Channels = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -830,6 +884,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "service":
|
||||
input.Service = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,6 +918,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "default":
|
||||
dipswitch.Default = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,6 +958,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "blit":
|
||||
driver.Blit = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,10 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
cueFiles.Add(file);
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,6 +625,10 @@ namespace SabreTools.Serialization.Readers
|
||||
case "data":
|
||||
flag |= CueTrackFlag.DATA;
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,22 @@ namespace SabreTools.Serialization.Readers
|
||||
game = null;
|
||||
files.Clear();
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case CmpRowType.TopLevel:
|
||||
case CmpRowType.Standalone:
|
||||
case CmpRowType.Internal:
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
// If we're at the root
|
||||
@@ -69,6 +83,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "game":
|
||||
game = new Game();
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +118,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "comment:":
|
||||
dat.DosCenter.Comment = reader.Standalone?.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +135,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "name":
|
||||
game.Name = reader.Standalone?.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,6 +201,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case "date":
|
||||
file.Date = kvp.Value;
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,6 @@ namespace SabreTools.Serialization.Readers
|
||||
#endif
|
||||
obj.FileComment = data.ReadNullTerminatedAnsiString();
|
||||
|
||||
|
||||
#if NET20 || NET35
|
||||
if ((obj.Flags & Flags.FHCRC) != 0)
|
||||
#else
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace SabreTools.Serialization.Readers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Data.Models.Hashfile.Hashfile? Deserialize(Stream? data, HashType hash)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return hash switch
|
||||
{
|
||||
HashType.CRC32 => DeserializeSFV(data),
|
||||
@@ -84,6 +85,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
_ => null,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
|
||||
@@ -456,16 +456,19 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(locationL * blockLength, SeekOrigin.Begin);
|
||||
groupL.PathTableL = ParsePathTable(data, sizeL, true);
|
||||
}
|
||||
|
||||
if (locationL2 != 0 && ((locationL2 * blockLength) + sizeL) < data.Length)
|
||||
{
|
||||
data.SeekIfPossible(locationL2 * blockLength, SeekOrigin.Begin);
|
||||
groupL.OptionalPathTableL = ParsePathTable(data, sizeL, true);
|
||||
}
|
||||
|
||||
if (locationM != 0 && ((locationM * blockLength) + sizeL) < data.Length)
|
||||
{
|
||||
data.SeekIfPossible(locationM * blockLength, SeekOrigin.Begin);
|
||||
groupL.PathTableM = ParsePathTable(data, sizeL, false);
|
||||
}
|
||||
|
||||
if (locationM2 != 0 && ((locationM2 * blockLength) + sizeL) < data.Length)
|
||||
{
|
||||
data.SeekIfPossible(locationM2 * blockLength, SeekOrigin.Begin);
|
||||
@@ -487,16 +490,19 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(locationL * blockLength, SeekOrigin.Begin);
|
||||
groupB.PathTableL = ParsePathTable(data, sizeB, true);
|
||||
}
|
||||
|
||||
if (locationL2 != 0 && ((locationL2 * blockLength) + sizeB) < data.Length)
|
||||
{
|
||||
data.SeekIfPossible(locationL2 * blockLength, SeekOrigin.Begin);
|
||||
groupB.OptionalPathTableL = ParsePathTable(data, sizeB, true);
|
||||
}
|
||||
|
||||
if (locationM != 0 && ((locationM * blockLength) + sizeB) < data.Length)
|
||||
{
|
||||
data.SeekIfPossible(locationM * blockLength, SeekOrigin.Begin);
|
||||
groupB.PathTableM = ParsePathTable(data, sizeB, false);
|
||||
}
|
||||
|
||||
if (locationM2 != 0 && ((locationM2 * blockLength) + sizeB) < data.Length)
|
||||
{
|
||||
data.SeekIfPossible(locationM2 * blockLength, SeekOrigin.Begin);
|
||||
@@ -636,19 +642,19 @@ namespace SabreTools.Serialization.Readers
|
||||
// Use provided extent endinanness
|
||||
int extentLocation = bigEndian ? dr.ExtentLocation.BigEndian : dr.ExtentLocation.LittleEndian;
|
||||
uint extentLength = bigEndian ? dr.ExtentLength.BigEndian : dr.ExtentLength.LittleEndian;
|
||||
long extentOffset = (long)extentLocation * (long)blockLength;
|
||||
long extentFinal = extentOffset + (long)extentLength;
|
||||
long extentOffset = extentLocation * (long)blockLength;
|
||||
long extentFinal = extentOffset + extentLength;
|
||||
|
||||
// Deal with extent length ambiguity
|
||||
if (!dr.ExtentLength.IsValid)
|
||||
{
|
||||
// If provided extent length is invalid, use the other value
|
||||
if (extentLength <= 0 || extentFinal > (long)data.Length)
|
||||
if (extentLength <= 0 || extentFinal > data.Length)
|
||||
extentLength = bigEndian ? dr.ExtentLength.LittleEndian : dr.ExtentLength.BigEndian;
|
||||
}
|
||||
|
||||
// Validate extent length
|
||||
if (extentLength <= 0 || extentFinal > (long)data.Length)
|
||||
if (extentLength <= 0 || extentFinal > data.Length)
|
||||
return null;
|
||||
|
||||
// Move stream to directory location
|
||||
|
||||
@@ -367,6 +367,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Guid[i] = data.ReadGuid();
|
||||
}
|
||||
|
||||
obj.CLSIDOffset = data.ReadUInt32LittleEndian();
|
||||
obj.Reserved2 = data.ReadBytes(28);
|
||||
obj.Reserved3 = data.ReadBytes(majorVersion <= 5 ? 2 : 1);
|
||||
@@ -502,11 +503,13 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.FileGroupOffsets[i] = data.ReadUInt32LittleEndian();
|
||||
}
|
||||
|
||||
obj.ComponentOffsets = new uint[71];
|
||||
for (int i = 0; i < 71; i++)
|
||||
{
|
||||
obj.ComponentOffsets[i] = data.ReadUInt32LittleEndian();
|
||||
}
|
||||
|
||||
obj.SetupTypesOffset = data.ReadUInt32LittleEndian();
|
||||
obj.SetupTableOffset = data.ReadUInt32LittleEndian();
|
||||
obj.Reserved7 = data.ReadUInt32LittleEndian();
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace SabreTools.Serialization.Readers
|
||||
extensions.UnknownDataLength = data.ReadUInt16LittleEndian();
|
||||
extensions.UnknownData = data.ReadBytes((int)extensions.UnknownDataLength);
|
||||
}
|
||||
|
||||
if (header.HeaderFlags.HasFlag(KWAJHeaderFlags.HasFileName))
|
||||
extensions.FileName = data.ReadNullTerminatedAnsiString();
|
||||
if (header.HeaderFlags.HasFlag(KWAJHeaderFlags.HasFileExtension))
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(offset, SeekOrigin.Begin);
|
||||
|
||||
// Create the fix-up page table
|
||||
executable.FixupPageTable = new FixupPageTableEntry[executable.ObjectPageMap?.Length ?? 0 + 1];
|
||||
executable.FixupPageTable = new FixupPageTableEntry[(executable.ObjectPageMap?.Length ?? 0) + 1];
|
||||
|
||||
// Try to parse the fix-up page table
|
||||
for (int i = 0; i < executable.FixupPageTable.Length; i++)
|
||||
@@ -264,7 +264,7 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(offset, SeekOrigin.Begin);
|
||||
|
||||
// Create the fix-up record table
|
||||
executable.FixupRecordTable = new FixupRecordTableEntry[executable.ObjectPageMap?.Length ?? 0 + 1];
|
||||
executable.FixupRecordTable = new FixupRecordTableEntry[(executable.ObjectPageMap?.Length ?? 0) + 1];
|
||||
|
||||
// Try to parse the fix-up record table
|
||||
for (int i = 0; i < executable.FixupRecordTable.Length; i++)
|
||||
@@ -489,6 +489,10 @@ namespace SabreTools.Serialization.Readers
|
||||
entry.ImportOrdinalNumber = data.ReadUInt32LittleEndian();
|
||||
break;
|
||||
|
||||
// Bitflag that is ignored
|
||||
case BundleType.ParameterTypingInformationPresent:
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Reserved1[i] = data.ReadUInt16LittleEndian();
|
||||
}
|
||||
|
||||
obj.OEMIdentifier = data.ReadUInt16LittleEndian();
|
||||
obj.OEMInformation = data.ReadUInt16LittleEndian();
|
||||
obj.Reserved2 = new ushort[10];
|
||||
@@ -111,6 +112,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Reserved2[i] = data.ReadUInt16LittleEndian();
|
||||
}
|
||||
|
||||
obj.NewExeHeaderAddr = data.ReadUInt32LittleEndian();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace SabreTools.Serialization.Readers
|
||||
public static BlockEntry[]? ParseBlockTable(Stream data, long initialOffset, ArchiveHeader header, MoPaQDecrypter decrypter)
|
||||
{
|
||||
// Get the block table offset
|
||||
long offset = initialOffset + ((uint)header.BlockTablePositionHi << 23) | header.BlockTablePosition;
|
||||
long offset = initialOffset + (((uint)header.BlockTablePositionHi << 23) | header.BlockTablePosition);
|
||||
if (offset <= initialOffset || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Descriptors[i] = (ARM9AccessControlDescriptors)data.ReadByteValue();
|
||||
}
|
||||
|
||||
obj.DescriptorVersion = data.ReadByteValue();
|
||||
|
||||
return obj;
|
||||
@@ -176,6 +177,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Descriptors[i] = data.ReadUInt32LittleEndian();
|
||||
}
|
||||
|
||||
obj.Reserved = data.ReadBytes(0x10);
|
||||
|
||||
return obj;
|
||||
@@ -201,17 +203,20 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.ResourceLimitDescriptors[i] = data.ReadUInt16LittleEndian();
|
||||
}
|
||||
|
||||
obj.StorageInfo = ParseStorageInfo(data);
|
||||
obj.ServiceAccessControl = new ulong[32];
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
obj.ServiceAccessControl[i] = data.ReadUInt64LittleEndian();
|
||||
}
|
||||
|
||||
obj.ExtendedServiceAccessControl = new ulong[2];
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
obj.ExtendedServiceAccessControl[i] = data.ReadUInt64LittleEndian();
|
||||
}
|
||||
|
||||
obj.Reserved = data.ReadBytes(0x0F);
|
||||
obj.ResourceLimitCategory = (ResourceLimitCategory)data.ReadByteValue();
|
||||
|
||||
@@ -307,6 +312,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.FileHeaders[i] = ParseExeFSFileHeader(data);
|
||||
}
|
||||
|
||||
obj.Reserved = data.ReadBytes(0x20);
|
||||
obj.FileHashes = new byte[10][];
|
||||
for (int i = 0; i < 10; i++)
|
||||
@@ -561,6 +567,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.DependencyModuleList[i] = data.ReadUInt64LittleEndian();
|
||||
}
|
||||
|
||||
obj.SystemInfo = ParseSystemInfo(data);
|
||||
|
||||
return obj;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SabreTools.Data.Models.NCF;
|
||||
|
||||
@@ -212,7 +212,12 @@ namespace SabreTools.Serialization.Readers
|
||||
entry.MoveableSegmentNumber = data.ReadByteValue();
|
||||
entry.MoveableOffset = data.ReadUInt16LittleEndian();
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
entryTable.Add(entry);
|
||||
}
|
||||
|
||||
@@ -253,7 +258,7 @@ namespace SabreTools.Serialization.Readers
|
||||
obj.MovableEntriesCount = data.ReadUInt16LittleEndian();
|
||||
obj.SegmentAlignmentShiftCount = data.ReadUInt16LittleEndian();
|
||||
obj.ResourceEntriesCount = data.ReadUInt16LittleEndian();
|
||||
obj.TargetOperatingSystem = (Data.Models.NewExecutable.OperatingSystem)data.ReadByteValue();
|
||||
obj.TargetOperatingSystem = (OperatingSystem)data.ReadByteValue();
|
||||
obj.AdditionalFlags = (OS2Flag)data.ReadByteValue();
|
||||
obj.ReturnThunkOffset = data.ReadUInt16LittleEndian();
|
||||
obj.SegmentReferenceThunkOffset = data.ReadUInt16LittleEndian();
|
||||
@@ -469,6 +474,12 @@ namespace SabreTools.Serialization.Readers
|
||||
case RelocationRecordFlag.OSFIXUP:
|
||||
obj.OSFixupRelocationRecord = ParseOSFixupRelocationRecord(data);
|
||||
break;
|
||||
case RelocationRecordFlag.ADDITIVE:
|
||||
// TODO: Figure out the record for this, if possible
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -666,7 +677,6 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(obj.Offset + initialOffset, SeekOrigin.Begin);
|
||||
obj.Data = data.ReadBytes(obj.Length);
|
||||
|
||||
|
||||
#if NET20 || NET35
|
||||
if ((obj.FlagWord & SegmentTableEntryFlag.RELOCINFO) != 0)
|
||||
#else
|
||||
|
||||
@@ -175,16 +175,19 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.GlobalMBK15Settings[i] = data.ReadUInt32LittleEndian();
|
||||
}
|
||||
|
||||
obj.LocalMBK68SettingsARM9 = new uint[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
obj.LocalMBK68SettingsARM9[i] = data.ReadUInt32LittleEndian();
|
||||
}
|
||||
|
||||
obj.LocalMBK68SettingsARM7 = new uint[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
obj.LocalMBK68SettingsARM7[i] = data.ReadUInt32LittleEndian();
|
||||
}
|
||||
|
||||
obj.GlobalMBK9Setting = data.ReadUInt32LittleEndian();
|
||||
obj.RegionFlags = data.ReadUInt32LittleEndian();
|
||||
obj.AccessControl = data.ReadUInt32LittleEndian();
|
||||
|
||||
@@ -108,6 +108,9 @@ namespace SabreTools.Serialization.Readers
|
||||
case DiscTypeIdentifierRecordable:
|
||||
obj.FormatDependentContents = data.ReadBytes(100);
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
||||
@@ -108,6 +108,10 @@ namespace SabreTools.Serialization.Readers
|
||||
validBlock = true;
|
||||
archive.ArchiveExtraDataRecord = aedr;
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
// If there was an invalid block
|
||||
@@ -209,6 +213,7 @@ namespace SabreTools.Serialization.Readers
|
||||
else
|
||||
obj.FileName = Encoding.ASCII.GetString(filenameBytes);
|
||||
}
|
||||
|
||||
if (obj.ExtraFieldLength > 0 && data.Position + obj.ExtraFieldLength <= data.Length)
|
||||
{
|
||||
byte[] extraBytes = data.ReadBytes(obj.ExtraFieldLength);
|
||||
@@ -217,6 +222,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
obj.ExtraFields = ParseExtraFields(obj, extraBytes);
|
||||
}
|
||||
|
||||
if (obj.FileCommentLength > 0 && data.Position + obj.FileCommentLength <= data.Length)
|
||||
{
|
||||
byte[] commentBytes = data.ReadBytes(obj.FileCommentLength);
|
||||
@@ -562,6 +568,7 @@ namespace SabreTools.Serialization.Readers
|
||||
else
|
||||
obj.FileName = Encoding.ASCII.GetString(filenameBytes);
|
||||
}
|
||||
|
||||
if (obj.ExtraFieldLength > 0 && data.Position + obj.ExtraFieldLength <= data.Length)
|
||||
{
|
||||
byte[] extraBytes = data.ReadBytes(obj.ExtraFieldLength);
|
||||
|
||||
@@ -1041,7 +1041,7 @@ namespace SabreTools.Serialization.Readers
|
||||
obj.Add(entry);
|
||||
|
||||
// All zero values means the last entry
|
||||
if (entry.OrdinalNameFlag == false
|
||||
if (!entry.OrdinalNameFlag
|
||||
&& entry.OrdinalNumber == 0
|
||||
&& entry.HintNameTableRVA == 0)
|
||||
break;
|
||||
@@ -1103,7 +1103,7 @@ namespace SabreTools.Serialization.Readers
|
||||
if (obj.OrdinalNameFlag)
|
||||
obj.OrdinalNumber = (ushort)(value & ~0x80000000);
|
||||
else
|
||||
obj.HintNameTableRVA = (uint)(value & ~0x80000000);
|
||||
obj.HintNameTableRVA = value & ~0x80000000;
|
||||
}
|
||||
else if (magic == OptionalHeaderMagicNumber.PE32Plus)
|
||||
{
|
||||
@@ -1182,7 +1182,7 @@ namespace SabreTools.Serialization.Readers
|
||||
obj.Add(entry);
|
||||
|
||||
// All zero values means the last entry
|
||||
if (entry.OrdinalNameFlag == false
|
||||
if (!entry.OrdinalNameFlag
|
||||
&& entry.OrdinalNumber == 0
|
||||
&& entry.HintNameTableRVA == 0)
|
||||
break;
|
||||
@@ -1246,7 +1246,7 @@ namespace SabreTools.Serialization.Readers
|
||||
if (obj.OrdinalNameFlag)
|
||||
obj.OrdinalNumber = (ushort)(value & ~0x80000000);
|
||||
else
|
||||
obj.HintNameTableRVA = (uint)(value & ~0x80000000);
|
||||
obj.HintNameTableRVA = value & ~0x80000000;
|
||||
}
|
||||
else if (magic == OptionalHeaderMagicNumber.PE32Plus)
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace SabreTools.Serialization.Readers
|
||||
case IniRowType.None:
|
||||
case IniRowType.Comment:
|
||||
continue;
|
||||
|
||||
case IniRowType.SectionHeader:
|
||||
switch (reader.Section?.ToLowerInvariant())
|
||||
{
|
||||
@@ -53,8 +54,16 @@ namespace SabreTools.Serialization.Readers
|
||||
case "games":
|
||||
dat.Games ??= new Games();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case IniRowType.KeyValue:
|
||||
case IniRowType.Invalid:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// If we're in credits
|
||||
@@ -86,6 +95,8 @@ namespace SabreTools.Serialization.Readers
|
||||
case "comment":
|
||||
dat.Credits.Comment = reader.KeyValuePair?.Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +120,8 @@ namespace SabreTools.Serialization.Readers
|
||||
case "merge":
|
||||
dat.Dat.Merge = reader.KeyValuePair?.Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +139,8 @@ namespace SabreTools.Serialization.Readers
|
||||
case "version":
|
||||
dat.Emulator.Version = reader.KeyValuePair?.Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace SabreTools.Serialization.Readers
|
||||
// TODO: If indexed by position, I think it needs to be adjusted by start of table
|
||||
|
||||
// Create the strings dictionary
|
||||
directory.StringTable = new Dictionary<long, string>((int)directoryHeader.StringTableCount);
|
||||
directory.StringTable = new Dictionary<long, string>(directoryHeader.StringTableCount);
|
||||
|
||||
// Get the current position to adjust the offsets
|
||||
long stringTableStart = data.Position;
|
||||
|
||||
@@ -151,6 +151,7 @@ namespace SabreTools.Serialization.Readers
|
||||
Status = reader.Line[16],
|
||||
};
|
||||
}
|
||||
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Lumps[i] = ParseVbspLumpEntry(data);
|
||||
}
|
||||
|
||||
obj.MapRevision = data.ReadInt32LittleEndian();
|
||||
|
||||
return obj;
|
||||
@@ -572,6 +573,7 @@ namespace SabreTools.Serialization.Readers
|
||||
if (occluderData is not null)
|
||||
lump.Data[i] = occluderData;
|
||||
}
|
||||
|
||||
lump.PolyDataCount = data.ReadInt32LittleEndian();
|
||||
lump.PolyData = new OccluderPolyData[lump.Count];
|
||||
for (int i = 0; i < lump.Count; i++)
|
||||
@@ -580,6 +582,7 @@ namespace SabreTools.Serialization.Readers
|
||||
if (polyData is not null)
|
||||
lump.PolyData[i] = polyData;
|
||||
}
|
||||
|
||||
lump.VertexIndexCount = data.ReadInt32LittleEndian();
|
||||
lump.VertexIndicies = new int[lump.VertexIndexCount];
|
||||
for (int i = 0; i < lump.VertexIndexCount; i++)
|
||||
@@ -625,11 +628,13 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
leaf.Mins[i] = data.ReadInt16LittleEndian();
|
||||
}
|
||||
|
||||
leaf.Maxs = new short[3];
|
||||
for (int i = 0; i < leaf.Maxs.Length; i++)
|
||||
{
|
||||
leaf.Maxs[i] = data.ReadInt16LittleEndian();
|
||||
}
|
||||
|
||||
leaf.FirstLeafFace = data.ReadUInt16LittleEndian();
|
||||
leaf.NumLeafFaces = data.ReadUInt16LittleEndian();
|
||||
leaf.FirstLeafBrush = data.ReadUInt16LittleEndian();
|
||||
|
||||
@@ -165,11 +165,13 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.FontInfo[i] = ParseCharInfo(data);
|
||||
}
|
||||
|
||||
obj.Data = new byte[obj.Height][];
|
||||
for (int i = 0; i < obj.Height; i++)
|
||||
{
|
||||
obj.Data[i] = data.ReadBytes((int)obj.Width);
|
||||
}
|
||||
|
||||
obj.ColorsUsed = data.ReadUInt16LittleEndian();
|
||||
obj.Palette = new byte[obj.ColorsUsed][];
|
||||
for (int i = 0; i < obj.ColorsUsed; i++)
|
||||
@@ -233,11 +235,13 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.MipOffsets[i] = data.ReadUInt32LittleEndian();
|
||||
}
|
||||
|
||||
obj.MipImages = new MipMap[4];
|
||||
for (int i = 0; i < obj.MipImages.Length; i++)
|
||||
{
|
||||
obj.MipImages[i] = ParseMipMap(data, obj.Width, obj.Height);
|
||||
}
|
||||
|
||||
obj.ColorsUsed = data.ReadUInt16LittleEndian();
|
||||
obj.Palette = new byte[obj.ColorsUsed][];
|
||||
for (int i = 0; i < obj.ColorsUsed; i++)
|
||||
@@ -264,6 +268,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
obj.Data[i] = data.ReadBytes((int)obj.Width);
|
||||
}
|
||||
|
||||
obj.ColorsUsed = data.ReadUInt16LittleEndian();
|
||||
obj.Palette = new byte[obj.ColorsUsed][];
|
||||
for (int i = 0; i < obj.ColorsUsed; i++)
|
||||
|
||||
@@ -69,9 +69,9 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(current, SeekOrigin.Begin);
|
||||
|
||||
// If the strings are valid
|
||||
if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
if (ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)
|
||||
&& logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))
|
||||
&& messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))
|
||||
&& !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0))
|
||||
{
|
||||
// TODO: Figure out if this maps to existing fields
|
||||
@@ -92,9 +92,9 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(current, SeekOrigin.Begin);
|
||||
|
||||
// If the strings are valid
|
||||
if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
if (ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)
|
||||
&& logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))
|
||||
&& messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))
|
||||
&& !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0))
|
||||
{
|
||||
header.Flags = data.ReadByteValue();
|
||||
@@ -117,9 +117,9 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(current, SeekOrigin.Begin);
|
||||
|
||||
// If the strings are valid
|
||||
if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
if (ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)
|
||||
&& logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))
|
||||
&& messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))
|
||||
&& !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0))
|
||||
{
|
||||
header.Flags = data.ReadByteValue();
|
||||
|
||||
@@ -309,6 +309,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
oneCount++;
|
||||
}
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace SabreTools.Serialization.Readers
|
||||
}
|
||||
|
||||
// Parse the padding as needed
|
||||
int paddingLength = 4 - (int)(data.Position - currentOffset) % 4;
|
||||
int paddingLength = 4 - ((int)(data.Position - currentOffset) % 4);
|
||||
if (paddingLength >= 0)
|
||||
obj.Padding = data.ReadBytes(paddingLength);
|
||||
|
||||
|
||||
@@ -63,6 +63,11 @@ namespace SabreTools.Serialization
|
||||
WrapperType.XZ => XZ.Create(data),
|
||||
WrapperType.XZP => XZP.Create(data),
|
||||
WrapperType.ZSTD => ZSTD.Create(data),
|
||||
|
||||
// Unimplemented
|
||||
WrapperType.UNKNOWN => null,
|
||||
WrapperType.WiseOverlayHeader => null,
|
||||
WrapperType.WiseScript => null,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,6 +82,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
case CopyrightRecord c:
|
||||
Print(builder, c);
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Create the filename
|
||||
string filename = $"lump_{index}.bin";
|
||||
#pragma warning disable IDE0010
|
||||
switch ((LumpType)index)
|
||||
{
|
||||
case LumpType.LUMP_ENTITIES:
|
||||
@@ -57,6 +58,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
filename = "texture_data.bin";
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
// If we have an invalid output directory
|
||||
if (string.IsNullOrEmpty(outputDirectory))
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(lump.Offset, " Offset");
|
||||
builder.AppendLine(lump.Length, " Length");
|
||||
|
||||
#pragma warning disable IDE0010
|
||||
switch ((LumpType)i)
|
||||
{
|
||||
case LumpType.LUMP_ENTITIES:
|
||||
@@ -108,6 +109,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" Unsupported lump type: {(LumpType)i} (0x{i:X4})");
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
@@ -115,6 +117,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
private static string GetLumpName(int i)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return (LumpType)i switch
|
||||
{
|
||||
LumpType.LUMP_ENTITIES => " - LUMP_ENTITIES",
|
||||
@@ -134,6 +137,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
LumpType.LUMP_MODELS => " - LUMP_MODELS",
|
||||
_ => string.Empty,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, EntitiesLump lump)
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <param name="data">Byte array representing the CDROM data track</param>
|
||||
/// <param name="offset">Offset within the array to parse</param>
|
||||
/// <returns>A CDROM data track wrapper on success, null on failure</returns>
|
||||
public new static CDROM? Create(byte[]? data, int offset)
|
||||
public static new CDROM? Create(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data is null || data.Length == 0)
|
||||
@@ -62,7 +62,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// </summary>
|
||||
/// <param name="data">Seekable Stream representing the CDROM data track</param>
|
||||
/// <returns>A CDROM data track wrapper on success, null on failure</returns>
|
||||
public new static CDROM? Create(Stream? data)
|
||||
public static new CDROM? Create(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data is null || !data.CanRead || !data.CanSeek)
|
||||
|
||||
@@ -138,6 +138,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
compressorsLine += string.Join(", ", [.. compressors]);
|
||||
}
|
||||
|
||||
builder.AppendLine(compressorsLine);
|
||||
|
||||
builder.AppendLine(header.LogicalBytes, $"Logical bytes");
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
case 0: certificateName = " (CA)"; break;
|
||||
case 1: certificateName = " (Ticket)"; break;
|
||||
case 2: certificateName = " (TMD)"; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Certificate {i}{certificateName}");
|
||||
@@ -87,6 +88,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(certificate.ECCPublicKey, " Public key");
|
||||
builder.AppendLine(certificate.ECCPadding, " Padding");
|
||||
break;
|
||||
default:
|
||||
builder.AppendLine($"Key type '{certificate.KeyType}' not recognized");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +138,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(ticket.Limits[i], $" Limit {i}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine(ticket.ContentIndexSize, " Content index size");
|
||||
builder.AppendLine(ticket.ContentIndex, " Content index");
|
||||
builder.AppendLine();
|
||||
@@ -155,6 +160,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
case 0: certificateName = " (Ticket)"; break;
|
||||
case 1: certificateName = " (CA)"; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Certificate {i}{certificateName}");
|
||||
@@ -179,6 +185,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(certificate.ECCPublicKey, " Public key");
|
||||
builder.AppendLine(certificate.ECCPadding, " Padding");
|
||||
break;
|
||||
default:
|
||||
builder.AppendLine($"Key type '{certificate.KeyType}' not recognized");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,6 +287,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
case 0: certificateName = " (TMD)"; break;
|
||||
case 1: certificateName = " (CA)"; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
builder.AppendLine($" Certificate {i}{certificateName}");
|
||||
@@ -302,6 +312,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(certificate.ECCPublicKey, " Public key");
|
||||
builder.AppendLine(certificate.ECCPadding, " Padding");
|
||||
break;
|
||||
default:
|
||||
builder.AppendLine($"Key type '{certificate.KeyType}' not recognized");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <param name="outputDirectory">Output directory to write to</param>
|
||||
/// <param name="includeDebug">True to include debug data, false otherwise</param>
|
||||
/// <returns>True if extraction succeeded, false otherwise</returns>
|
||||
bool Extract(string outputDirectory, bool includeDebug);
|
||||
public bool Extract(string outputDirectory, bool includeDebug);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Export the item information as JSON
|
||||
/// </summary>
|
||||
string ExportJSON();
|
||||
public string ExportJSON();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Print information associated with a model
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
void PrintInformation(StringBuilder builder);
|
||||
public void PrintInformation(StringBuilder builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(encoding.GetString(vd.SystemIdentifier), " System Identifier");
|
||||
builder.AppendLine(encoding.GetString(vd.VolumeIdentifier), " Volume Identifier");
|
||||
|
||||
|
||||
if (vd.Unused8Bytes is not null && Array.TrueForAll(vd.Unused8Bytes, b => b == 0))
|
||||
builder.AppendLine("Zeroed", " Unused 8 Bytes");
|
||||
else
|
||||
@@ -149,6 +148,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
else
|
||||
builder.AppendLine(pvd2.Unused32Bytes, " Unused 32 Bytes");
|
||||
}
|
||||
|
||||
if (vd is SupplementaryVolumeDescriptor svd2)
|
||||
{
|
||||
// TODO: Trim trailing 0x00 and split array into characters (multi-byte encoding detection)
|
||||
@@ -279,6 +279,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" No Type-L Path Table {tableNum}:");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
if (ptgs[tableNum].OptionalPathTableL is not null)
|
||||
{
|
||||
builder.AppendLine($" Optional Type-L Path Table {tableNum}:");
|
||||
@@ -290,6 +291,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" No Optional Type-L Path Table {tableNum}:");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
if (ptgs[tableNum].PathTableM is not null)
|
||||
{
|
||||
builder.AppendLine($" Type-M Path Table {tableNum}:");
|
||||
@@ -301,6 +303,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" No Type-M Path Table {tableNum}:");
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
if (ptgs[tableNum].OptionalPathTableM is not null)
|
||||
{
|
||||
builder.AppendLine($" Optional Type-M Path Table {tableNum}:");
|
||||
@@ -439,7 +442,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(drdt.Hour, " Hour");
|
||||
builder.AppendLine(drdt.Minute, " Minute");
|
||||
builder.AppendLine(drdt.Second, " Second");
|
||||
string tz = $"{((drdt.TimezoneOffset - 48) * 15 / 60):+0;-0}:{((drdt.TimezoneOffset - 48) * 15 % 60 + 60) % 60:00} (0x{drdt.TimezoneOffset:X2})";
|
||||
string tz = $"{(drdt.TimezoneOffset - 48) * 15 / 60:+0;-0}:{(((drdt.TimezoneOffset - 48) * 15 % 60) + 60) % 60:00} (0x{drdt.TimezoneOffset:X2})";
|
||||
builder.AppendLine(tz, " Timezone Offset");
|
||||
}
|
||||
|
||||
@@ -466,7 +469,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
else
|
||||
builder.AppendLine(" Fixed Bits: Not All Set");
|
||||
|
||||
|
||||
builder.AppendLine(Format(ear.FileCreationDateTime), " File Creation Date Time");
|
||||
builder.AppendLine(Format(ear.FileModificationDateTime), " File Modification Date Time");
|
||||
builder.AppendLine(Format(ear.FileExpirationDateTime), " File Expiration Date Time");
|
||||
@@ -512,7 +514,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
? Encoding.ASCII.GetString(dt.Centisecond)
|
||||
: BitConverter.ToString(dt.Centisecond).Replace('-', ' ');
|
||||
|
||||
string tz = $"{((dt.TimezoneOffset - 48) * 15 / 60):+0;-0}:{((dt.TimezoneOffset - 48) * 15 % 60 + 60) % 60:00} (0x{dt.TimezoneOffset:X2})";
|
||||
string tz = $"{(dt.TimezoneOffset - 48) * 15 / 60:+0;-0}:{(((dt.TimezoneOffset - 48) * 15 % 60) + 60) % 60:00} (0x{dt.TimezoneOffset:X2})";
|
||||
|
||||
return $"{year}-{month}-{day} {hour}:{minute}:{second}.{csecond} [{tz}]";
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Get a human-readable description of the wrapper
|
||||
/// </summary>
|
||||
string Description();
|
||||
public string Description();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Get the backing model
|
||||
/// </summary>
|
||||
TModel GetModel();
|
||||
public TModel GetModel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName is not null && !System.IO.Directory.Exists(directoryName))
|
||||
System.IO.Directory.CreateDirectory(directoryName);
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
try
|
||||
|
||||
@@ -452,7 +452,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Uncompress a source byte array to a destination
|
||||
/// </summary>
|
||||
private unsafe static int Uncompress(byte[] dest, ref uint destLen, byte[] source, ref uint sourceLen)
|
||||
private static unsafe int Uncompress(byte[] dest, ref uint destLen, byte[] source, ref uint sourceLen)
|
||||
{
|
||||
fixed (byte* sourcePtr = source, destPtr = dest)
|
||||
{
|
||||
@@ -485,7 +485,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Uncompress a source byte array to a destination (old version)
|
||||
/// </summary>
|
||||
private unsafe static int UncompressOld(byte[] dest, ref uint destLen, byte[] source, ref uint sourceLen)
|
||||
private static unsafe int UncompressOld(byte[] dest, ref uint destLen, byte[] source, ref uint sourceLen)
|
||||
{
|
||||
fixed (byte* sourcePtr = source, destPtr = dest)
|
||||
{
|
||||
|
||||
@@ -85,6 +85,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.LastFileSizeCompressed, " Last file size compressed");
|
||||
builder.AppendLine(header.LastFileSizeCompressedHigh, " Last file size compressed high");
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return Path.GetFileNameWithoutExtension(input);
|
||||
|
||||
// Handle replacing characters
|
||||
char c = (char.IsUpper(input[0]) ? char.ToLower(LastChar) : char.ToUpper(LastChar));
|
||||
char c = char.IsUpper(input[0]) ? char.ToLower(LastChar) : char.ToUpper(LastChar);
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
string text2 = extension[..^1] + c;
|
||||
#else
|
||||
|
||||
@@ -301,6 +301,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(entry.ImportOrdinalNumber, " Import ordinal number");
|
||||
break;
|
||||
|
||||
case BundleType.ParameterTypingInformationPresent:
|
||||
default:
|
||||
builder.AppendLine($" Unknown entry type {type}");
|
||||
break;
|
||||
@@ -601,6 +602,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(entry.SourceOffsetList[j], $" Source Offset List Entry {j}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,7 +439,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
_fileStream = GetFileStream(filename, outputDirectory);
|
||||
|
||||
|
||||
// Loop through the data blocks
|
||||
// Has to be a while loop instead of a for loop due to cab spanning continue blocks
|
||||
for (int j = 0; j < _folder.DataCount; j++)
|
||||
@@ -494,6 +493,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
CompressionType.TYPE_LZX => [],
|
||||
|
||||
// Should be impossible
|
||||
CompressionType.MASK_TYPE => [],
|
||||
_ => [],
|
||||
};
|
||||
|
||||
@@ -549,7 +549,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
_fileStream.Write(data, (int)tempBytesLeft, data.Length - (int)tempBytesLeft);
|
||||
_bytesLeft -= (data.Length - tempBytesLeft);
|
||||
_bytesLeft -= data.Length - tempBytesLeft;
|
||||
}
|
||||
|
||||
// Top if block occurs on http://redump.org/disc/107833/ , middle on https://dbox.tools/titles/pc/57520FA0 , bottom still unobserved
|
||||
@@ -595,6 +595,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// not supplied by the cabinet file creating application, the checksum field is set to 0 (zero). Cabinet
|
||||
/// extracting applications do not compute or verify the checksum if the field is set to 0 (zero).
|
||||
/// </summary>
|
||||
#pragma warning disable IDE0051
|
||||
private static uint ChecksumData(byte[] data)
|
||||
{
|
||||
uint[] C =
|
||||
@@ -607,6 +608,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
return C[0] ^ C[1] ^ C[2] ^ C[3];
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
/// <summary>
|
||||
/// Individual algorithmic step
|
||||
|
||||
@@ -165,6 +165,8 @@ namespace SabreTools.Serialization.Wrappers
|
||||
FolderIndex.CONTINUED_FROM_PREV => 0,
|
||||
FolderIndex.CONTINUED_TO_NEXT => Header.FolderCount - 1,
|
||||
FolderIndex.CONTINUED_PREV_AND_NEXT => 0,
|
||||
|
||||
FolderIndex.FIRST_FOLDER => (int)file.FolderIndex,
|
||||
_ => (int)file.FolderIndex,
|
||||
};
|
||||
}
|
||||
@@ -305,38 +307,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return [.. prevFiles, .. files, .. nextFiles];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all files for the current folder index
|
||||
/// </summary>
|
||||
/// <param name="folderIndex">Index of the folder in the cabinet</param>
|
||||
/// <param name="ignorePrev">True to ignore previous links, false otherwise</param>
|
||||
/// <returns>Array of all files for the folder</returns>
|
||||
private CFFILE[] GetFiles(int folderIndex, bool ignorePrev = false)
|
||||
{
|
||||
// Ignore invalid archives
|
||||
if (Files is null)
|
||||
return [];
|
||||
|
||||
// Get all files with a name and matching index
|
||||
return Array.FindAll(Files, f =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(f.Name))
|
||||
return false;
|
||||
|
||||
// Ignore links to previous cabinets, if required
|
||||
if (ignorePrev)
|
||||
{
|
||||
if (f.FolderIndex == FolderIndex.CONTINUED_FROM_PREV)
|
||||
return false;
|
||||
else if (f.FolderIndex == FolderIndex.CONTINUED_PREV_AND_NEXT)
|
||||
return false;
|
||||
}
|
||||
|
||||
int fileFolder = GetFolderIndex(f);
|
||||
return fileFolder == folderIndex;
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,6 +414,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(descriptorsStr, " Descriptors");
|
||||
builder.AppendLine(entry.ACIForLimitations.ARM9AccessControl.DescriptorVersion, " Descriptor version");
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -297,6 +297,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(entry.MoveableSegmentNumber, " Segment number");
|
||||
builder.AppendLine(entry.MoveableOffset, " Offset");
|
||||
break;
|
||||
case SegmentEntryType.Unused:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
r3 <<= 8;
|
||||
r3 |= arg1[(j * 4 + i) & 7];
|
||||
r3 |= arg1[((j * 4) + i) & 7];
|
||||
}
|
||||
|
||||
_cardHash[j] ^= r3;
|
||||
@@ -409,6 +409,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
_cardHash[i + 0] = tmp1;
|
||||
_cardHash[i + 1] = tmp2;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 0x400; i += 2)
|
||||
{
|
||||
Encrypt(ref tmp1, ref tmp2);
|
||||
|
||||
@@ -305,6 +305,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
case MicrosoftOpenPackagingGrowthHint field: Print(builder, field); break;
|
||||
|
||||
case UnknownExtraField field: Print(builder, field); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.ExportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ExportTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.ImportTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Import Table (2)");
|
||||
@@ -157,6 +158,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.ImportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ImportTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.ResourceTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Resource Table (3)");
|
||||
@@ -164,6 +166,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.ResourceTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ResourceTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.ExceptionTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Exception Table (4)");
|
||||
@@ -171,6 +174,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.ExceptionTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ExceptionTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.CertificateTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Certificate Table (5)");
|
||||
@@ -178,6 +182,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.CertificateTable.VirtualAddress, " Physical address");
|
||||
builder.AppendLine(header.CertificateTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.BaseRelocationTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Base Relocation Table (6)");
|
||||
@@ -185,6 +190,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.BaseRelocationTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.BaseRelocationTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.Debug is not null)
|
||||
{
|
||||
builder.AppendLine(" Debug Table (7)");
|
||||
@@ -192,6 +198,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.Debug.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.Debug.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.NumberOfRvaAndSizes >= 8)
|
||||
{
|
||||
builder.AppendLine(" Architecture Table (8)");
|
||||
@@ -199,6 +206,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(" Physical address: 0 (0x00000000)");
|
||||
builder.AppendLine(" Size: 0 (0x00000000)");
|
||||
}
|
||||
|
||||
if (header.GlobalPtr is not null)
|
||||
{
|
||||
builder.AppendLine(" Global Pointer Register (9)");
|
||||
@@ -206,6 +214,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.GlobalPtr.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.GlobalPtr.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.ThreadLocalStorageTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Thread Local Storage (TLS) Table (10)");
|
||||
@@ -213,6 +222,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.LoadConfigTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Load Config Table (11)");
|
||||
@@ -220,6 +230,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.LoadConfigTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.LoadConfigTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.BoundImport is not null)
|
||||
{
|
||||
builder.AppendLine(" Bound Import Table (12)");
|
||||
@@ -227,6 +238,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.BoundImport.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.BoundImport.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.ImportAddressTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Import Address Table (13)");
|
||||
@@ -234,6 +246,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.ImportAddressTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ImportAddressTable.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.DelayImportDescriptor is not null)
|
||||
{
|
||||
builder.AppendLine(" Delay Import Descriptor (14)");
|
||||
@@ -241,6 +254,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.DelayImportDescriptor.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.DelayImportDescriptor.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.CLRRuntimeHeader is not null)
|
||||
{
|
||||
builder.AppendLine(" CLR Runtime Header (15)");
|
||||
@@ -248,6 +262,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.CLRRuntimeHeader.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.CLRRuntimeHeader.Size, " Size");
|
||||
}
|
||||
|
||||
if (header.NumberOfRvaAndSizes >= 16)
|
||||
{
|
||||
builder.AppendLine(" Reserved (16)");
|
||||
@@ -317,6 +332,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
case FileRecord item: Print(builder, item, i); break;
|
||||
case SectionDefinition item: Print(builder, item, i); break;
|
||||
case CLRTokenDefinition item: Print(builder, item, i); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,6 +351,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(entry.Zeroes, " Zeroes");
|
||||
builder.AppendLine(entry.Offset, " Offset");
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.Value, " Value");
|
||||
builder.AppendLine($" Section number: {entry.SectionNumber} (0x{entry.SectionNumber:X})");
|
||||
builder.AppendLine($" Symbol type: {entry.SymbolType} (0x{entry.SymbolType:X})");
|
||||
@@ -612,6 +629,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(table.OrdinalTableRVA, " Ordinal table RVA");
|
||||
builder.AppendLine(table.OrdinalTableRVA.ConvertVirtualAddress(sections), " Ordinal table physical address");
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
@@ -946,15 +964,18 @@ namespace SabreTools.Serialization.Wrappers
|
||||
PrintResourceRT_CURSOR(entry, level, builder);
|
||||
break;
|
||||
case ResourceType.RT_BITMAP:
|
||||
case ResourceType.RT_NEWBITMAP:
|
||||
PrintResourceRT_BITMAP(entry, level, builder);
|
||||
break;
|
||||
case ResourceType.RT_ICON:
|
||||
PrintResourceRT_ICON(entry, level, builder);
|
||||
break;
|
||||
case ResourceType.RT_MENU:
|
||||
case ResourceType.RT_NEWMENU:
|
||||
PrintResourceRT_MENU(entry, level, builder);
|
||||
break;
|
||||
case ResourceType.RT_DIALOG:
|
||||
case ResourceType.RT_NEWDIALOG:
|
||||
PrintResourceRT_DIALOG(entry, level, builder);
|
||||
break;
|
||||
case ResourceType.RT_STRING:
|
||||
@@ -1005,6 +1026,16 @@ namespace SabreTools.Serialization.Wrappers
|
||||
case ResourceType.RT_MANIFEST:
|
||||
PrintResourceRT_MANIFEST(entry, level, builder);
|
||||
break;
|
||||
|
||||
// Bitflag, ignore
|
||||
case ResourceType.RT_NEWRESOURCE:
|
||||
break;
|
||||
|
||||
// Error state, ignore
|
||||
case ResourceType.RT_ERROR:
|
||||
PrintResourceUNKNOWN(entry, level, types[0], builder);
|
||||
break;
|
||||
|
||||
default:
|
||||
PrintResourceUNKNOWN(entry, level, types[0], builder);
|
||||
break;
|
||||
@@ -1042,6 +1073,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
MenuResource? menu = null;
|
||||
try { menu = entry.AsMenu(); } catch { }
|
||||
|
||||
if (menu is null)
|
||||
{
|
||||
builder.AppendLine($"{padding}Menu resource found, but malformed");
|
||||
@@ -1063,6 +1095,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
builder.AppendLine($"{padding}Menu header found, but malformed");
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
|
||||
builder.AppendLine($"{padding}Menu items");
|
||||
@@ -1117,6 +1150,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
DialogBoxResource? dialogBox = null;
|
||||
try { dialogBox = entry.AsDialogBox(); } catch { }
|
||||
|
||||
if (dialogBox is null)
|
||||
{
|
||||
builder.AppendLine($"{padding}Dialog box resource found, but malformed");
|
||||
@@ -1252,6 +1286,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
Dictionary<int, string?>? stringTable = null;
|
||||
try { stringTable = entry.AsStringTable(); } catch { }
|
||||
|
||||
if (stringTable is null)
|
||||
{
|
||||
builder.AppendLine($"{padding}String table resource found, but malformed");
|
||||
@@ -1284,6 +1319,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
AcceleratorTableEntry[]? acceleratorTable = null;
|
||||
try { acceleratorTable = entry.AsAcceleratorTableResource(); } catch { }
|
||||
|
||||
if (acceleratorTable is null)
|
||||
{
|
||||
builder.AppendLine($"{padding}Accelerator table resource found, but malformed");
|
||||
@@ -1366,6 +1402,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
MessageResourceData? messageTable = null;
|
||||
try { messageTable = entry.AsMessageResourceData(); } catch { }
|
||||
|
||||
if (messageTable is null)
|
||||
{
|
||||
builder.AppendLine($"{padding}Message resource data found, but malformed");
|
||||
@@ -1397,6 +1434,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(messageResourceBlock.OffsetToEntries, $"{padding} Offset to entries");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
|
||||
builder.AppendLine($"{padding}Message resource entries");
|
||||
@@ -1443,6 +1481,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
VersionInfo? versionInfo = null;
|
||||
try { versionInfo = entry.AsVersionInfo(); } catch { }
|
||||
|
||||
if (versionInfo is null)
|
||||
{
|
||||
builder.AppendLine($"{padding}Version info resource found, but malformed");
|
||||
@@ -1607,6 +1646,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
AssemblyManifest? assemblyManifest = null;
|
||||
try { assemblyManifest = entry.AsAssemblyManifest(); } catch { }
|
||||
|
||||
if (assemblyManifest is null)
|
||||
{
|
||||
builder.AppendLine($"{padding}Assembly manifest found, but malformed");
|
||||
@@ -1663,6 +1703,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.PublicKeyToken, $"{padding}[Dependency {i} Assembly Identity] Public key token");
|
||||
builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.Language, $"{padding}[Dependency {i} Assembly Identity] Language");
|
||||
}
|
||||
|
||||
if (dependency.DependentAssembly.BindingRedirect is not null && dependency.DependentAssembly.BindingRedirect.Length > 0)
|
||||
{
|
||||
for (int j = 0; j < dependency.DependentAssembly.BindingRedirect.Length; j++)
|
||||
|
||||
@@ -1880,15 +1880,18 @@ namespace SabreTools.Serialization.Wrappers
|
||||
value = entry.Data;
|
||||
break;
|
||||
case ResourceType.RT_BITMAP:
|
||||
case ResourceType.RT_NEWBITMAP:
|
||||
value = entry.Data;
|
||||
break;
|
||||
case ResourceType.RT_ICON:
|
||||
value = entry.Data;
|
||||
break;
|
||||
case ResourceType.RT_MENU:
|
||||
case ResourceType.RT_NEWMENU:
|
||||
value = entry.AsMenu();
|
||||
break;
|
||||
case ResourceType.RT_DIALOG:
|
||||
case ResourceType.RT_NEWDIALOG:
|
||||
value = entry.AsDialogBox();
|
||||
break;
|
||||
case ResourceType.RT_STRING:
|
||||
@@ -1941,6 +1944,16 @@ namespace SabreTools.Serialization.Wrappers
|
||||
_assemblyManifest = entry.AsAssemblyManifest();
|
||||
value = _assemblyManifest;
|
||||
break;
|
||||
|
||||
// Bitflag, ignore
|
||||
case ResourceType.RT_NEWRESOURCE:
|
||||
break;
|
||||
|
||||
// Error state, ignore
|
||||
case ResourceType.RT_ERROR:
|
||||
value = entry.Data;
|
||||
break;
|
||||
|
||||
default:
|
||||
value = entry.Data;
|
||||
break;
|
||||
|
||||
@@ -257,6 +257,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (includeDebug) Console.Error.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(Model.BlockOrHeaderSize, "Block or header size");
|
||||
builder.AppendLine();
|
||||
|
||||
|
||||
Print(builder, Model.Entries);
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (includeDebug) Console.Error.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -268,7 +269,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Increment the index
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <param name="data">Byte array representing the archive</param>
|
||||
/// <param name="offset">Offset within the array to parse</param>
|
||||
/// <returns>An Skeleton Volume wrapper on success, null on failure</returns>
|
||||
public new static Skeleton? Create(byte[]? data, int offset)
|
||||
public static new Skeleton? Create(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data is null || data.Length == 0)
|
||||
@@ -62,7 +62,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// </summary>
|
||||
/// <param name="data">Stream representing the archive</param>
|
||||
/// <returns>An Skeleton Volume wrapper on success, null on failure</returns>
|
||||
public new static Skeleton? Create(Stream? data)
|
||||
public static new Skeleton? Create(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data is null || !data.CanRead)
|
||||
|
||||
@@ -81,9 +81,16 @@ namespace SabreTools.Serialization.Wrappers
|
||||
else if (Path.DirectorySeparatorChar == '/')
|
||||
entryDirectory = entryDirectory.Replace('\\', '/');
|
||||
|
||||
// Create the director
|
||||
// Create the directory
|
||||
Directory.CreateDirectory(entryDirectory);
|
||||
continue;
|
||||
|
||||
// File types have no special handling
|
||||
case TypeFlag.REGTYPE:
|
||||
case TypeFlag.AREGTYPE:
|
||||
case TypeFlag.CONTTYPE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the file size
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Create the filename
|
||||
string filename = $"lump_{index}.bin";
|
||||
#pragma warning disable IDE0010
|
||||
switch ((LumpType)index)
|
||||
{
|
||||
case LumpType.LUMP_ENTITIES:
|
||||
@@ -61,6 +62,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
filename = "pakfile.zip";
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
// Ensure directory separators are consistent
|
||||
if (Path.DirectorySeparatorChar == '\\')
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" Header String {i}: {entry}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
@@ -144,6 +145,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" File Text {i}: {entry}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine(data.Source, $" Source");
|
||||
builder.AppendLine();
|
||||
}
|
||||
@@ -172,6 +174,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" Title/Text String {i}: {entry}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
@@ -193,6 +196,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" Script Line {i}: {entry}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
@@ -304,6 +308,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
@@ -381,6 +386,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" Description {i}: {entry}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
builder.AppendLine(data.Source, $" Source");
|
||||
builder.AppendLine();
|
||||
|
||||
@@ -162,6 +162,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Loop through the state machine and process
|
||||
foreach (var state in States)
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
switch (state.Op)
|
||||
{
|
||||
case OperationCode.InstallFile:
|
||||
@@ -234,6 +235,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
if (includeDebug) Console.WriteLine($"Directory {createDirectory.Pathname} could not be created!");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OperationCode.CopyLocalFile:
|
||||
@@ -326,6 +328,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" String {i}: {entry}");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +164,9 @@ namespace SabreTools.Serialization.Writers
|
||||
case Set:
|
||||
writer.WriteStartElement(name: "set");
|
||||
break;
|
||||
default:
|
||||
// TODO: Log invalid values
|
||||
break;
|
||||
}
|
||||
|
||||
// Write the standalone values
|
||||
@@ -471,6 +474,7 @@ namespace SabreTools.Serialization.Writers
|
||||
{
|
||||
writer.WriteRequiredAttributeString("entry", entry);
|
||||
}
|
||||
|
||||
writer.WriteOptionalAttributeString("default", dipswitch.Default);
|
||||
writer.WriteEndElement(); // dipswitch
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace SabreTools.Serialization.Writers
|
||||
};
|
||||
|
||||
// Write out the items, if they exist
|
||||
#pragma warning disable IDE0010
|
||||
switch (hash)
|
||||
{
|
||||
case HashType.CRC32:
|
||||
@@ -116,6 +117,7 @@ namespace SabreTools.Serialization.Writers
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(hash));
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
// Return the stream
|
||||
stream.SeekIfPossible(0, SeekOrigin.Begin);
|
||||
|
||||
@@ -258,7 +258,6 @@ namespace StormLibSharp
|
||||
return (MpqArchiveVerificationResult)NativeMethods.SFileVerifyArchive(_handle);
|
||||
}
|
||||
|
||||
|
||||
#region IDisposable implementation
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -52,7 +52,6 @@ namespace StormLibSharp.Native
|
||||
[DllImport(STORMLIB, CallingConvention = CallingConvention.Winapi, ExactSpelling = true, PreserveSig = true, SetLastError = true, ThrowOnUnmappableChar = false)]
|
||||
public static extern bool SFileFlushArchive(MpqArchiveSafeHandle? hMpq);
|
||||
|
||||
|
||||
[DllImport(STORMLIB, CallingConvention = CallingConvention.Winapi, ExactSpelling = true, PreserveSig = true, SetLastError = true, ThrowOnUnmappableChar = false)]
|
||||
public static extern bool SFileCloseArchive(IntPtr hMpq);
|
||||
|
||||
@@ -461,6 +460,8 @@ namespace StormLibSharp.Native
|
||||
}
|
||||
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable IDE0044
|
||||
#pragma warning disable IDE0051
|
||||
internal struct SFILE_CREATE_MPQ
|
||||
{
|
||||
public uint cbSize;
|
||||
@@ -476,6 +477,8 @@ namespace StormLibSharp.Native
|
||||
public uint dwMaxFileCount;
|
||||
}
|
||||
#pragma warning restore CS0169
|
||||
#pragma warning restore IDE0044
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
internal unsafe struct _SFILE_FIND_DATA
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user