mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Perform some TODO cleanup
This commit is contained in:
@@ -355,9 +355,6 @@ namespace SabreTools.DatFiles
|
|||||||
.Replace("%size%", size)
|
.Replace("%size%", size)
|
||||||
.Replace("%spamsum%", spamsum);
|
.Replace("%spamsum%", spamsum);
|
||||||
|
|
||||||
// TODO: Add GameName logic here too?
|
|
||||||
// TODO: Figure out what I meant by the above ^
|
|
||||||
|
|
||||||
return fix;
|
return fix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -721,7 +721,6 @@ namespace SabreTools.DatFiles
|
|||||||
List<string> usedExtensions = new List<string>();
|
List<string> usedExtensions = new List<string>();
|
||||||
|
|
||||||
// Get the extensions from the output type
|
// Get the extensions from the output type
|
||||||
// TODO: Can the system of adding be more automated?
|
|
||||||
|
|
||||||
#region .csv
|
#region .csv
|
||||||
|
|
||||||
|
|||||||
@@ -433,7 +433,6 @@ namespace SabreTools.DatItems
|
|||||||
/// <param name="lower">True if the key should be lowercased (default), false otherwise</param>
|
/// <param name="lower">True if the key should be lowercased (default), false otherwise</param>
|
||||||
/// <param name="norename">True if games should only be compared on game and file name, false if system and source are counted</param>
|
/// <param name="norename">True if games should only be compared on game and file name, false if system and source are counted</param>
|
||||||
/// <returns>String representing the key to be used for the DatItem</returns>
|
/// <returns>String representing the key to be used for the DatItem</returns>
|
||||||
/// TODO: What other fields can we reasonably allow bucketing on?
|
|
||||||
public virtual string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
|
public virtual string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
|
||||||
{
|
{
|
||||||
// Set the output key as the default blank string
|
// Set the output key as the default blank string
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ namespace SabreTools.DatItems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Manipulate DatItems
|
/// Manipulate DatItems
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO: Use these instead of the baked in ones
|
|
||||||
public static class DatItemTool
|
public static class DatItemTool
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -21,7 +20,6 @@ namespace SabreTools.DatItems
|
|||||||
/// <param name="datItemFields">DatItem fields to remove</param>
|
/// <param name="datItemFields">DatItem fields to remove</param>
|
||||||
/// <param name="machineFields">Machine fields to remove</param>
|
/// <param name="machineFields">Machine fields to remove</param>
|
||||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||||
/// TODO: Extract out setting name to common
|
|
||||||
public static void RemoveFields(
|
public static void RemoveFields(
|
||||||
DatItem datItem,
|
DatItem datItem,
|
||||||
List<DatItemField> datItemFields = null,
|
List<DatItemField> datItemFields = null,
|
||||||
@@ -39,15 +37,15 @@ namespace SabreTools.DatItems
|
|||||||
if (datItemFields == null)
|
if (datItemFields == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (datItemFields.Contains(DatItemField.Name))
|
||||||
|
datItem.SetName(null);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Adjuster
|
#region Adjuster
|
||||||
|
|
||||||
if (datItem is Adjuster adjuster)
|
if (datItem is Adjuster adjuster)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
adjuster.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Default))
|
if (datItemFields.Contains(DatItemField.Default))
|
||||||
adjuster.Default = null;
|
adjuster.Default = null;
|
||||||
|
|
||||||
@@ -72,23 +70,10 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Archive
|
|
||||||
|
|
||||||
else if (datItem is Archive archive)
|
|
||||||
{
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
archive.Name = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region BiosSet
|
#region BiosSet
|
||||||
|
|
||||||
else if (datItem is BiosSet biosSet)
|
else if (datItem is BiosSet biosSet)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
biosSet.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Description))
|
if (datItemFields.Contains(DatItemField.Description))
|
||||||
biosSet.Description = null;
|
biosSet.Description = null;
|
||||||
|
|
||||||
@@ -102,9 +87,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Chip chip)
|
else if (datItem is Chip chip)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
chip.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Tag))
|
if (datItemFields.Contains(DatItemField.Tag))
|
||||||
chip.Tag = null;
|
chip.Tag = null;
|
||||||
|
|
||||||
@@ -157,9 +139,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Configuration configuration)
|
else if (datItem is Configuration configuration)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
configuration.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Tag))
|
if (datItemFields.Contains(DatItemField.Tag))
|
||||||
configuration.Tag = null;
|
configuration.Tag = null;
|
||||||
|
|
||||||
@@ -293,25 +272,12 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DeviceReference
|
|
||||||
|
|
||||||
else if (datItem is DeviceReference deviceReference)
|
|
||||||
{
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
deviceReference.Name = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region DipSwitch
|
#region DipSwitch
|
||||||
|
|
||||||
else if (datItem is DipSwitch dipSwitch)
|
else if (datItem is DipSwitch dipSwitch)
|
||||||
{
|
{
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
dipSwitch.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Tag))
|
if (datItemFields.Contains(DatItemField.Tag))
|
||||||
dipSwitch.Tag = null;
|
dipSwitch.Tag = null;
|
||||||
|
|
||||||
@@ -360,9 +326,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
disk.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.MD5))
|
if (datItemFields.Contains(DatItemField.MD5))
|
||||||
disk.MD5 = null;
|
disk.MD5 = null;
|
||||||
|
|
||||||
@@ -510,9 +473,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Info info)
|
else if (datItem is Info info)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
info.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Value))
|
if (datItemFields.Contains(DatItemField.Value))
|
||||||
info.Value = null;
|
info.Value = null;
|
||||||
}
|
}
|
||||||
@@ -579,9 +539,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Media media)
|
else if (datItem is Media media)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
media.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.MD5))
|
if (datItemFields.Contains(DatItemField.MD5))
|
||||||
media.MD5 = null;
|
media.MD5 = null;
|
||||||
|
|
||||||
@@ -653,9 +610,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is RamOption ramOption)
|
else if (datItem is RamOption ramOption)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
ramOption.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Default))
|
if (datItemFields.Contains(DatItemField.Default))
|
||||||
ramOption.Default = null;
|
ramOption.Default = null;
|
||||||
|
|
||||||
@@ -669,9 +623,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Release release)
|
else if (datItem is Release release)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
release.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Region))
|
if (datItemFields.Contains(DatItemField.Region))
|
||||||
release.Region = null;
|
release.Region = null;
|
||||||
|
|
||||||
@@ -693,9 +644,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
rom.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Bios))
|
if (datItemFields.Contains(DatItemField.Bios))
|
||||||
rom.Bios = null;
|
rom.Bios = null;
|
||||||
|
|
||||||
@@ -794,16 +742,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sample
|
|
||||||
|
|
||||||
else if (datItem is Sample sample)
|
|
||||||
{
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
sample.Name = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Setting
|
#region Setting
|
||||||
|
|
||||||
else if (datItem is Setting setting)
|
else if (datItem is Setting setting)
|
||||||
@@ -832,9 +770,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is SharedFeature sharedFeature)
|
else if (datItem is SharedFeature sharedFeature)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
sharedFeature.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Value))
|
if (datItemFields.Contains(DatItemField.Value))
|
||||||
sharedFeature.Value = null;
|
sharedFeature.Value = null;
|
||||||
}
|
}
|
||||||
@@ -845,9 +780,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Slot slot)
|
else if (datItem is Slot slot)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
slot.Name = null;
|
|
||||||
|
|
||||||
if (slot.SlotOptionsSpecified)
|
if (slot.SlotOptionsSpecified)
|
||||||
{
|
{
|
||||||
foreach (SlotOption subSlotOption in slot.SlotOptions)
|
foreach (SlotOption subSlotOption in slot.SlotOptions)
|
||||||
@@ -879,9 +811,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is SoftwareList softwareList)
|
else if (datItem is SoftwareList softwareList)
|
||||||
{
|
{
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
softwareList.Name = null;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.SoftwareListStatus))
|
if (datItemFields.Contains(DatItemField.SoftwareListStatus))
|
||||||
softwareList.Status = SoftwareListStatus.NULL;
|
softwareList.Status = SoftwareListStatus.NULL;
|
||||||
|
|
||||||
@@ -1049,24 +978,27 @@ namespace SabreTools.DatItems
|
|||||||
/// <param name="datItem">DatItem to replace fields in</param>
|
/// <param name="datItem">DatItem to replace fields in</param>
|
||||||
/// <param name="repMachine">DatItem to pull new information from</param>
|
/// <param name="repMachine">DatItem to pull new information from</param>
|
||||||
/// <param name="datItemFields">List of fields representing what should be updated</param>
|
/// <param name="datItemFields">List of fields representing what should be updated</param>
|
||||||
/// TODO: Extract out setting name to common
|
|
||||||
public static void ReplaceFields(DatItem datItem, DatItem repDatItem, List<DatItemField> datItemFields)
|
public static void ReplaceFields(DatItem datItem, DatItem repDatItem, List<DatItemField> datItemFields)
|
||||||
{
|
{
|
||||||
if (datItem == null || repDatItem == null || datItemFields == null)
|
if (datItem == null || repDatItem == null || datItemFields == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#region Common
|
||||||
|
|
||||||
if (datItem.ItemType != repDatItem.ItemType)
|
if (datItem.ItemType != repDatItem.ItemType)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (datItemFields.Contains(DatItemField.Name))
|
||||||
|
datItem.SetName(repDatItem.GetName());
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Adjuster
|
#region Adjuster
|
||||||
|
|
||||||
if (datItem is Adjuster adjuster)
|
if (datItem is Adjuster adjuster)
|
||||||
{
|
{
|
||||||
Adjuster newItem = repDatItem as Adjuster;
|
Adjuster newItem = repDatItem as Adjuster;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
adjuster.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Default))
|
if (datItemFields.Contains(DatItemField.Default))
|
||||||
adjuster.Default = newItem.Default;
|
adjuster.Default = newItem.Default;
|
||||||
|
|
||||||
@@ -1089,27 +1021,12 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Archive
|
|
||||||
|
|
||||||
else if (datItem is Archive archive)
|
|
||||||
{
|
|
||||||
Archive newItem = repDatItem as Archive;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
archive.Name = newItem.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region BiosSet
|
#region BiosSet
|
||||||
|
|
||||||
else if (datItem is BiosSet biosSet)
|
else if (datItem is BiosSet biosSet)
|
||||||
{
|
{
|
||||||
BiosSet newItem = repDatItem as BiosSet;
|
BiosSet newItem = repDatItem as BiosSet;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
biosSet.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Description))
|
if (datItemFields.Contains(DatItemField.Description))
|
||||||
biosSet.Description = newItem.Description;
|
biosSet.Description = newItem.Description;
|
||||||
|
|
||||||
@@ -1125,9 +1042,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
Chip newItem = repDatItem as Chip;
|
Chip newItem = repDatItem as Chip;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
chip.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Tag))
|
if (datItemFields.Contains(DatItemField.Tag))
|
||||||
chip.Tag = newItem.Tag;
|
chip.Tag = newItem.Tag;
|
||||||
|
|
||||||
@@ -1175,9 +1089,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
Configuration newItem = repDatItem as Configuration;
|
Configuration newItem = repDatItem as Configuration;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
configuration.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Tag))
|
if (datItemFields.Contains(DatItemField.Tag))
|
||||||
configuration.Tag = newItem.Tag;
|
configuration.Tag = newItem.Tag;
|
||||||
|
|
||||||
@@ -1297,18 +1208,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DeviceReference
|
|
||||||
|
|
||||||
else if (datItem is DeviceReference deviceReference)
|
|
||||||
{
|
|
||||||
DeviceReference newItem = repDatItem as DeviceReference;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
deviceReference.Name = newItem.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region DipSwitch
|
#region DipSwitch
|
||||||
|
|
||||||
else if (datItem is DipSwitch dipSwitch)
|
else if (datItem is DipSwitch dipSwitch)
|
||||||
@@ -1317,9 +1216,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
dipSwitch.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Tag))
|
if (datItemFields.Contains(DatItemField.Tag))
|
||||||
dipSwitch.Tag = newItem.Tag;
|
dipSwitch.Tag = newItem.Tag;
|
||||||
|
|
||||||
@@ -1358,9 +1254,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
disk.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.MD5))
|
if (datItemFields.Contains(DatItemField.MD5))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(disk.MD5) && !string.IsNullOrEmpty(newItem.MD5))
|
if (string.IsNullOrEmpty(disk.MD5) && !string.IsNullOrEmpty(newItem.MD5))
|
||||||
@@ -1526,9 +1419,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
Info newItem = repDatItem as Info;
|
Info newItem = repDatItem as Info;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
info.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Value))
|
if (datItemFields.Contains(DatItemField.Value))
|
||||||
info.Value = newItem.Value;
|
info.Value = newItem.Value;
|
||||||
}
|
}
|
||||||
@@ -1599,9 +1489,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
Media newItem = repDatItem as Media;
|
Media newItem = repDatItem as Media;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
media.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.MD5))
|
if (datItemFields.Contains(DatItemField.MD5))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(media.MD5) && !string.IsNullOrEmpty(newItem.MD5))
|
if (string.IsNullOrEmpty(media.MD5) && !string.IsNullOrEmpty(newItem.MD5))
|
||||||
@@ -1665,13 +1552,8 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#region Port
|
#region Port
|
||||||
|
|
||||||
else if (datItem is Port port)
|
else if (datItem is Port)
|
||||||
{
|
{
|
||||||
Port newItem = repDatItem as Port;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
port.Tag = newItem.Tag;
|
|
||||||
|
|
||||||
// Analog_* doesn't make sense here
|
// Analog_* doesn't make sense here
|
||||||
// since not every analog under the other item
|
// since not every analog under the other item
|
||||||
// can replace every analog under this item
|
// can replace every analog under this item
|
||||||
@@ -1685,9 +1567,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
RamOption newItem = repDatItem as RamOption;
|
RamOption newItem = repDatItem as RamOption;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
ramOption.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Default))
|
if (datItemFields.Contains(DatItemField.Default))
|
||||||
ramOption.Default = newItem.Default;
|
ramOption.Default = newItem.Default;
|
||||||
|
|
||||||
@@ -1703,9 +1582,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
Release newItem = repDatItem as Release;
|
Release newItem = repDatItem as Release;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
release.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Region))
|
if (datItemFields.Contains(DatItemField.Region))
|
||||||
release.Region = newItem.Region;
|
release.Region = newItem.Region;
|
||||||
|
|
||||||
@@ -1729,9 +1605,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
rom.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Bios))
|
if (datItemFields.Contains(DatItemField.Bios))
|
||||||
rom.Bios = newItem.Bios;
|
rom.Bios = newItem.Bios;
|
||||||
|
|
||||||
@@ -1851,18 +1724,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sample
|
|
||||||
|
|
||||||
else if (datItem is Sample sample)
|
|
||||||
{
|
|
||||||
Sample newItem = repDatItem as Sample;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
sample.Name = newItem.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Setting
|
#region Setting
|
||||||
|
|
||||||
else if (datItem is Setting setting)
|
else if (datItem is Setting setting)
|
||||||
@@ -1891,9 +1752,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
SharedFeature newItem = repDatItem as SharedFeature;
|
SharedFeature newItem = repDatItem as SharedFeature;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
sharedFeature.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Value))
|
if (datItemFields.Contains(DatItemField.Value))
|
||||||
sharedFeature.Value = newItem.Value;
|
sharedFeature.Value = newItem.Value;
|
||||||
}
|
}
|
||||||
@@ -1902,13 +1760,8 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#region Slot
|
#region Slot
|
||||||
|
|
||||||
else if (datItem is Slot slot)
|
else if (datItem is Slot)
|
||||||
{
|
{
|
||||||
Slot newItem = repDatItem as Slot;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
slot.Name = newItem.Name;
|
|
||||||
|
|
||||||
// SlotOption_* doesn't make sense here
|
// SlotOption_* doesn't make sense here
|
||||||
// since not every slot option under the other item
|
// since not every slot option under the other item
|
||||||
// can replace every slot option under this item
|
// can replace every slot option under this item
|
||||||
@@ -1940,9 +1793,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
SoftwareList newItem = repDatItem as SoftwareList;
|
SoftwareList newItem = repDatItem as SoftwareList;
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.Name))
|
|
||||||
softwareList.Name = newItem.Name;
|
|
||||||
|
|
||||||
if (datItemFields.Contains(DatItemField.SoftwareListStatus))
|
if (datItemFields.Contains(DatItemField.SoftwareListStatus))
|
||||||
softwareList.Status = newItem.Status;
|
softwareList.Status = newItem.Status;
|
||||||
|
|
||||||
@@ -2118,7 +1968,6 @@ namespace SabreTools.DatItems
|
|||||||
/// <param name="datItemMappings">DatItem mappings dictionary</param>
|
/// <param name="datItemMappings">DatItem mappings dictionary</param>
|
||||||
/// <param name="machineMappings">Machine mappings dictionary</param>
|
/// <param name="machineMappings">Machine mappings dictionary</param>
|
||||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||||
/// TODO: Extract out setting name to common
|
|
||||||
public static void SetFields(
|
public static void SetFields(
|
||||||
DatItem datItem,
|
DatItem datItem,
|
||||||
Dictionary<DatItemField, string> datItemMappings,
|
Dictionary<DatItemField, string> datItemMappings,
|
||||||
@@ -2136,15 +1985,15 @@ namespace SabreTools.DatItems
|
|||||||
if (datItemMappings == null)
|
if (datItemMappings == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||||
|
datItem.SetName(datItemMappings[DatItemField.Name]);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Adjuster
|
#region Adjuster
|
||||||
|
|
||||||
if (datItem is Adjuster adjuster)
|
if (datItem is Adjuster adjuster)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
adjuster.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Default))
|
if (datItemMappings.Keys.Contains(DatItemField.Default))
|
||||||
adjuster.Default = datItemMappings[DatItemField.Default].AsYesNo();
|
adjuster.Default = datItemMappings[DatItemField.Default].AsYesNo();
|
||||||
|
|
||||||
@@ -2170,23 +2019,10 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Archive
|
|
||||||
|
|
||||||
else if (datItem is Archive archive)
|
|
||||||
{
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
archive.Name = datItemMappings[DatItemField.Name];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region BiosSet
|
#region BiosSet
|
||||||
|
|
||||||
else if (datItem is BiosSet biosSet)
|
else if (datItem is BiosSet biosSet)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
biosSet.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Description))
|
if (datItemMappings.Keys.Contains(DatItemField.Description))
|
||||||
biosSet.Description = datItemMappings[DatItemField.Description];
|
biosSet.Description = datItemMappings[DatItemField.Description];
|
||||||
|
|
||||||
@@ -2200,9 +2036,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Chip chip)
|
else if (datItem is Chip chip)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
chip.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||||
chip.Tag = datItemMappings[DatItemField.Tag];
|
chip.Tag = datItemMappings[DatItemField.Tag];
|
||||||
|
|
||||||
@@ -2255,9 +2088,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Configuration configuration)
|
else if (datItem is Configuration configuration)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
configuration.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||||
configuration.Tag = datItemMappings[DatItemField.Tag];
|
configuration.Tag = datItemMappings[DatItemField.Tag];
|
||||||
|
|
||||||
@@ -2338,9 +2168,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is DataArea dataArea)
|
else if (datItem is DataArea dataArea)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.AreaName))
|
|
||||||
dataArea.Name = datItemMappings[DatItemField.AreaName];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.AreaSize))
|
if (datItemMappings.Keys.Contains(DatItemField.AreaSize))
|
||||||
dataArea.Size = Utilities.CleanLong(datItemMappings[DatItemField.AreaSize]);
|
dataArea.Size = Utilities.CleanLong(datItemMappings[DatItemField.AreaSize]);
|
||||||
|
|
||||||
@@ -2391,25 +2218,12 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DeviceReference
|
|
||||||
|
|
||||||
else if (datItem is DeviceReference deviceReference)
|
|
||||||
{
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
deviceReference.Name = datItemMappings[DatItemField.Name];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region DipSwitch
|
#region DipSwitch
|
||||||
|
|
||||||
else if (datItem is DipSwitch dipSwitch)
|
else if (datItem is DipSwitch dipSwitch)
|
||||||
{
|
{
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
dipSwitch.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||||
dipSwitch.Tag = datItemMappings[DatItemField.Tag];
|
dipSwitch.Tag = datItemMappings[DatItemField.Tag];
|
||||||
|
|
||||||
@@ -2461,9 +2275,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
disk.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.MD5))
|
if (datItemMappings.Keys.Contains(DatItemField.MD5))
|
||||||
disk.MD5 = datItemMappings[DatItemField.MD5];
|
disk.MD5 = datItemMappings[DatItemField.MD5];
|
||||||
|
|
||||||
@@ -2507,16 +2318,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DiskArea
|
|
||||||
|
|
||||||
else if (datItem is DiskArea diskArea)
|
|
||||||
{
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.AreaName))
|
|
||||||
diskArea.Name = datItemMappings[DatItemField.AreaName];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Display
|
#region Display
|
||||||
|
|
||||||
else if (datItem is Display display)
|
else if (datItem is Display display)
|
||||||
@@ -2588,16 +2389,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Extension
|
|
||||||
|
|
||||||
else if (datItem is Extension extension)
|
|
||||||
{
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Extension_Name))
|
|
||||||
extension.Name = datItemMappings[DatItemField.Extension_Name];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Feature
|
#region Feature
|
||||||
|
|
||||||
else if (datItem is Feature feature)
|
else if (datItem is Feature feature)
|
||||||
@@ -2618,9 +2409,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Info info)
|
else if (datItem is Info info)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
info.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Value))
|
if (datItemMappings.Keys.Contains(DatItemField.Value))
|
||||||
info.Value = datItemMappings[DatItemField.Value];
|
info.Value = datItemMappings[DatItemField.Value];
|
||||||
}
|
}
|
||||||
@@ -2658,9 +2446,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Instance instance)
|
else if (datItem is Instance instance)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Instance_Name))
|
|
||||||
instance.Name = datItemMappings[DatItemField.Instance_Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Instance_BriefName))
|
if (datItemMappings.Keys.Contains(DatItemField.Instance_BriefName))
|
||||||
instance.BriefName = datItemMappings[DatItemField.Instance_BriefName];
|
instance.BriefName = datItemMappings[DatItemField.Instance_BriefName];
|
||||||
}
|
}
|
||||||
@@ -2671,9 +2456,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Location location)
|
else if (datItem is Location location)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Location_Name))
|
|
||||||
location.Name = datItemMappings[DatItemField.Location_Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Location_Number))
|
if (datItemMappings.Keys.Contains(DatItemField.Location_Number))
|
||||||
location.Number = Utilities.CleanLong(datItemMappings[DatItemField.Location_Number]);
|
location.Number = Utilities.CleanLong(datItemMappings[DatItemField.Location_Number]);
|
||||||
|
|
||||||
@@ -2687,9 +2469,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Media media)
|
else if (datItem is Media media)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
media.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.MD5))
|
if (datItemMappings.Keys.Contains(DatItemField.MD5))
|
||||||
media.MD5 = datItemMappings[DatItemField.MD5];
|
media.MD5 = datItemMappings[DatItemField.MD5];
|
||||||
|
|
||||||
@@ -2761,9 +2540,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is RamOption ramOption)
|
else if (datItem is RamOption ramOption)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
ramOption.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Default))
|
if (datItemMappings.Keys.Contains(DatItemField.Default))
|
||||||
ramOption.Default = datItemMappings[DatItemField.Default].AsYesNo();
|
ramOption.Default = datItemMappings[DatItemField.Default].AsYesNo();
|
||||||
|
|
||||||
@@ -2777,9 +2553,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Release release)
|
else if (datItem is Release release)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
release.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Region))
|
if (datItemMappings.Keys.Contains(DatItemField.Region))
|
||||||
release.Region = datItemMappings[DatItemField.Region];
|
release.Region = datItemMappings[DatItemField.Region];
|
||||||
|
|
||||||
@@ -2801,9 +2574,6 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
#region Common
|
#region Common
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
rom.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Bios))
|
if (datItemMappings.Keys.Contains(DatItemField.Bios))
|
||||||
rom.Bios = datItemMappings[DatItemField.Bios];
|
rom.Bios = datItemMappings[DatItemField.Bios];
|
||||||
|
|
||||||
@@ -2906,16 +2676,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sample
|
|
||||||
|
|
||||||
else if (datItem is Sample sample)
|
|
||||||
{
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
sample.Name = datItemMappings[DatItemField.Name];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Setting
|
#region Setting
|
||||||
|
|
||||||
else if (datItem is Setting setting)
|
else if (datItem is Setting setting)
|
||||||
@@ -2944,9 +2704,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is SharedFeature sharedFeature)
|
else if (datItem is SharedFeature sharedFeature)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
sharedFeature.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Value))
|
if (datItemMappings.Keys.Contains(DatItemField.Value))
|
||||||
sharedFeature.Value = datItemMappings[DatItemField.Value];
|
sharedFeature.Value = datItemMappings[DatItemField.Value];
|
||||||
}
|
}
|
||||||
@@ -2957,9 +2714,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is Slot slot)
|
else if (datItem is Slot slot)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
slot.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (slot.SlotOptionsSpecified)
|
if (slot.SlotOptionsSpecified)
|
||||||
{
|
{
|
||||||
foreach (SlotOption subSlotOption in slot.SlotOptions)
|
foreach (SlotOption subSlotOption in slot.SlotOptions)
|
||||||
@@ -2991,9 +2745,6 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
else if (datItem is SoftwareList softwareList)
|
else if (datItem is SoftwareList softwareList)
|
||||||
{
|
{
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
|
||||||
softwareList.Name = datItemMappings[DatItemField.Name];
|
|
||||||
|
|
||||||
if (datItemMappings.Keys.Contains(DatItemField.SoftwareListStatus))
|
if (datItemMappings.Keys.Contains(DatItemField.SoftwareListStatus))
|
||||||
softwareList.Status = datItemMappings[DatItemField.SoftwareListStatus].AsSoftwareListStatus();
|
softwareList.Status = datItemMappings[DatItemField.SoftwareListStatus].AsSoftwareListStatus();
|
||||||
|
|
||||||
|
|||||||
@@ -337,7 +337,6 @@ namespace SabreTools.Filtering
|
|||||||
/// <param name="datItem">DatItem to check</param>
|
/// <param name="datItem">DatItem to check</param>
|
||||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||||
/// TODO: Split this somehow
|
|
||||||
/// TODO: Name can be made into a common one if name exists
|
/// TODO: Name can be made into a common one if name exists
|
||||||
public bool PassesFilters(DatItem datItem, bool sub = false)
|
public bool PassesFilters(DatItem datItem, bool sub = false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ namespace SabreTools.Filtering
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the filtering operations that need to be performed on a DatHeader
|
/// Represents the filtering operations that need to be performed on a DatHeader
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO: Investigate how to reduce the amount of hardcoded filter statements
|
|
||||||
/// TODO: Add DatHeader filters
|
|
||||||
public class DatHeaderFilter : Filter
|
public class DatHeaderFilter : Filter
|
||||||
{
|
{
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ namespace SabreTools.Filtering
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the filtering operations that need to be performed on a set of items, usually a DAT
|
/// Represents the filtering operations that need to be performed on a set of items, usually a DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO: Can clever use of Filtering allow for easier external splitting methods?
|
|
||||||
/// TODO: Investigate how to reduce the amount of hardcoded filter statements
|
|
||||||
public class DatItemFilter : Filter
|
public class DatItemFilter : Filter
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ namespace SabreTools.Filtering
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the filtering operations that need to be performed on a set of items, usually a DAT
|
/// Represents the filtering operations that need to be performed on a set of items, usually a DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO: Can clever use of Filtering allow for easier external splitting methods?
|
|
||||||
/// TODO: Investigate how to reduce the amount of hardcoded filter statements
|
|
||||||
public class MachineFilter : Filter
|
public class MachineFilter : Filter
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ namespace SabreTools.Skippers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the output directory if it doesn't already
|
// Create the output directory if it doesn't already
|
||||||
Ensure(Path.GetDirectoryName(output));
|
if (!Directory.Exists(Path.GetDirectoryName(output)))
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(output));
|
||||||
|
|
||||||
//logger.User($"Attempting to apply rule to '{input}'");
|
//logger.User($"Attempting to apply rule to '{input}'");
|
||||||
bool success = TransformStream(File.OpenRead(input), File.Create(output));
|
bool success = TransformStream(File.OpenRead(input), File.Create(output));
|
||||||
@@ -237,38 +238,5 @@ namespace SabreTools.Skippers
|
|||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this region once IO namespace is separated out properly
|
|
||||||
#region TEMPORARY - REMOVEME
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ensure the output directory is a proper format and can be created
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dir">Directory to check</param>
|
|
||||||
/// <param name="create">True if the directory should be created, false otherwise (default)</param>
|
|
||||||
/// <param name="temp">True if this is a temp directory, false otherwise</param>
|
|
||||||
/// <returns>Full path to the directory</returns>
|
|
||||||
public static string Ensure(string dir, bool create = false, bool temp = false)
|
|
||||||
{
|
|
||||||
// If the output directory is invalid
|
|
||||||
if (string.IsNullOrWhiteSpace(dir))
|
|
||||||
{
|
|
||||||
if (temp)
|
|
||||||
dir = Path.GetTempPath();
|
|
||||||
else
|
|
||||||
dir = Environment.CurrentDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the full path for the output directory
|
|
||||||
dir = Path.GetFullPath(dir);
|
|
||||||
|
|
||||||
// If we're creating the output folder, do so
|
|
||||||
if (create)
|
|
||||||
Directory.CreateDirectory(dir);
|
|
||||||
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user