mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Fix device merging, add new parsing prototypes
This commit is contained in:
@@ -563,6 +563,30 @@ namespace SabreTools.Library.Tools
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a sanitized Date from an input string
|
||||
/// </summary>
|
||||
/// <param name="input">String to get value from</param>
|
||||
/// <returns>Date as a string, if possible</returns>
|
||||
public static string GetDate(string input)
|
||||
{
|
||||
string date = "";
|
||||
if (input != null)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now;
|
||||
if (DateTime.TryParse(input, out dateTime))
|
||||
{
|
||||
date = dateTime.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
date = input;
|
||||
}
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a specific type of DatFile to be used based on an input file and a base DAT
|
||||
/// </summary>
|
||||
@@ -794,6 +818,26 @@ namespace SabreTools.Library.Tools
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a sanitized size from an input string
|
||||
/// </summary>
|
||||
/// <param name="input">String to get value from</param>
|
||||
/// <returns>Size as a long, if possible</returns>
|
||||
public static long GetSize(string input)
|
||||
{
|
||||
long size = -1;
|
||||
if (input != null && input.Contains("0x"))
|
||||
{
|
||||
size = Convert.ToInt64(input, 16);
|
||||
}
|
||||
else if (input != null)
|
||||
{
|
||||
Int64.TryParse(input, out size);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get SplitType value from input ForceMerging
|
||||
/// </summary>
|
||||
@@ -822,15 +866,16 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="yesno">String to get value from</param>
|
||||
/// <returns>Bool corresponding to the string</returns>
|
||||
public static bool GetYesNo(string yesno)
|
||||
public static bool? GetYesNo(string yesno)
|
||||
{
|
||||
switch (yesno?.ToLowerInvariant())
|
||||
{
|
||||
case "yes":
|
||||
return true;
|
||||
default:
|
||||
case "no":
|
||||
return false;
|
||||
return false;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user