diff --git a/RombaSharp/Features/RefreshDats.cs b/RombaSharp/Features/RefreshDats.cs
index 04c31487..584a9358 100644
--- a/RombaSharp/Features/RefreshDats.cs
+++ b/RombaSharp/Features/RefreshDats.cs
@@ -5,7 +5,7 @@ using SabreTools.Data;
using SabreTools.Help;
using SabreTools.Library.DatFiles;
using SabreTools.Library.DatItems;
-using SabreTools.Library.Tools;
+using SabreTools.Logging;
using Microsoft.Data.Sqlite;
namespace RombaSharp.Features
diff --git a/SabreTools.Data/Enums.cs b/SabreTools.Data/Enums.cs
index 2227f078..305d9e43 100644
--- a/SabreTools.Data/Enums.cs
+++ b/SabreTools.Data/Enums.cs
@@ -162,6 +162,362 @@ namespace SabreTools.Data
ALL = Int32.MaxValue,
}
+ ///
+ /// Determines the DAT deduplication type
+ ///
+ public enum DedupeType
+ {
+ None = 0,
+ Full,
+
+ // Force only deduping with certain types
+ Game,
+ CRC,
+ MD5,
+#if NET_FRAMEWORK
+ RIPEMD160,
+#endif
+ SHA1,
+ SHA256,
+ SHA384,
+ SHA512,
+ }
+
+ ///
+ /// List of valid field types within a DatItem/Machine
+ ///
+ public enum Field : int
+ {
+ NULL = 0,
+
+ #region DatHeader
+
+ #region Common
+
+ DatHeader_FileName,
+ DatHeader_Name,
+ DatHeader_Description,
+ DatHeader_RootDir,
+ DatHeader_Category,
+ DatHeader_Version,
+ DatHeader_Date,
+ DatHeader_Author,
+ DatHeader_Email,
+ DatHeader_Homepage,
+ DatHeader_Url,
+ DatHeader_Comment,
+ DatHeader_HeaderSkipper,
+ DatHeader_Type,
+ DatHeader_ForceMerging,
+ DatHeader_ForceNodump,
+ DatHeader_ForcePacking,
+
+ #endregion
+
+ #region ListXML
+
+ DatHeader_Debug,
+ DatHeader_MameConfig,
+
+ #endregion
+
+ #region Logiqx
+
+ DatHeader_Build,
+ DatHeader_RomMode,
+ DatHeader_BiosMode,
+ DatHeader_SampleMode,
+ DatHeader_LockRomMode,
+ DatHeader_LockBiosMode,
+ DatHeader_LockSampleMode,
+
+ #endregion
+
+ #region OfflineList
+
+ DatHeader_System,
+ DatHeader_ScreenshotsWidth,
+ DatHeader_ScreenshotsHeight,
+ DatHeader_CanOpen,
+ DatHeader_RomTitle,
+
+ // Infos
+ DatHeader_Info_Name,
+ DatHeader_Info_Visible,
+ DatHeader_Info_IsNamingOption,
+ DatHeader_Info_Default,
+
+ #endregion
+
+ #region RomCenter
+
+ DatHeader_RomCenterVersion,
+
+ #endregion
+
+ #endregion // DatHeader
+
+ #region Machine
+
+ #region Common
+
+ Machine_Name,
+ Machine_Comment,
+ Machine_Description,
+ Machine_Year,
+ Machine_Manufacturer,
+ Machine_Publisher,
+ Machine_Category,
+ Machine_RomOf,
+ Machine_CloneOf,
+ Machine_SampleOf,
+ Machine_Type,
+
+ #endregion
+
+ #region AttractMode
+
+ Machine_Players,
+ Machine_Rotation,
+ Machine_Control,
+ Machine_Status,
+ Machine_DisplayCount,
+ Machine_DisplayType,
+ Machine_Buttons,
+
+ #endregion
+
+ #region ListXML
+
+ Machine_SourceFile,
+ Machine_Runnable,
+
+ #endregion
+
+ #region Logiqx
+
+ Machine_Board,
+ Machine_RebuildTo,
+
+ #endregion
+
+ #region Logiqx EmuArc
+
+ Machine_TitleID,
+ Machine_Developer,
+ Machine_Genre,
+ Machine_Subgenre,
+ Machine_Ratings,
+ Machine_Score,
+ Machine_Enabled,
+ Machine_CRC,
+ Machine_RelatedTo,
+
+ #endregion
+
+ #region OpenMSX
+
+ Machine_GenMSXID,
+ Machine_System,
+ Machine_Country,
+
+ #endregion
+
+ #region SoftwareList
+
+ Machine_Supported,
+
+ #endregion
+
+ #endregion // Machine
+
+ #region DatItem
+
+ #region Common
+
+ DatItem_Type,
+
+ #endregion
+
+ #region Item-Specific
+
+ #region Actionable
+
+ // Rom
+ DatItem_Name,
+ DatItem_Bios,
+ DatItem_Size,
+ DatItem_CRC,
+ DatItem_MD5,
+#if NET_FRAMEWORK
+ DatItem_RIPEMD160,
+#endif
+ DatItem_SHA1,
+ DatItem_SHA256,
+ DatItem_SHA384,
+ DatItem_SHA512,
+ DatItem_SpamSum,
+ DatItem_Merge,
+ DatItem_Region,
+ DatItem_Offset,
+ DatItem_Date,
+ DatItem_Status,
+ DatItem_Optional,
+ DatItem_Inverted,
+
+ // Rom (AttractMode)
+ DatItem_AltName,
+ DatItem_AltTitle,
+
+ // Rom (OpenMSX)
+ DatItem_Original,
+ DatItem_OpenMSXSubType,
+ DatItem_OpenMSXType,
+ DatItem_Remark,
+ DatItem_Boot,
+
+ // Rom (SoftwareList)
+ DatItem_LoadFlag,
+ DatItem_Value,
+
+ // Disk
+ DatItem_Index,
+ DatItem_Writable,
+
+ #endregion
+
+ #region Auxiliary
+
+ // Adjuster
+ DatItem_Default,
+
+ // Analog
+ DatItem_Analog_Mask,
+
+ // BiosSet
+ DatItem_Description,
+
+ // Chip
+ DatItem_Tag,
+ DatItem_ChipType,
+ DatItem_Clock,
+
+ // Condition
+ DatItem_Mask,
+ DatItem_Relation,
+ DatItem_Condition_Tag,
+ DatItem_Condition_Mask,
+ DatItem_Condition_Relation,
+ DatItem_Condition_Value,
+
+ // Control
+ DatItem_Control_Type,
+ DatItem_Control_Player,
+ DatItem_Control_Buttons,
+ DatItem_Control_RequiredButtons,
+ DatItem_Control_Minimum,
+ DatItem_Control_Maximum,
+ DatItem_Control_Sensitivity,
+ DatItem_Control_KeyDelta,
+ DatItem_Control_Reverse,
+ DatItem_Control_Ways,
+ DatItem_Control_Ways2,
+ DatItem_Control_Ways3,
+
+ // DataArea
+ DatItem_AreaName,
+ DatItem_AreaSize,
+ DatItem_AreaWidth,
+ DatItem_AreaEndianness,
+
+ // Device
+ DatItem_DeviceType,
+ DatItem_FixedImage,
+ DatItem_Mandatory,
+ DatItem_Interface,
+
+ // Display
+ DatItem_DisplayType,
+ DatItem_Rotate,
+ DatItem_FlipX,
+ DatItem_Width,
+ DatItem_Height,
+ DatItem_Refresh,
+ DatItem_PixClock,
+ DatItem_HTotal,
+ DatItem_HBEnd,
+ DatItem_HBStart,
+ DatItem_VTotal,
+ DatItem_VBEnd,
+ DatItem_VBStart,
+
+ // Driver
+ DatItem_SupportStatus,
+ DatItem_EmulationStatus,
+ DatItem_CocktailStatus,
+ DatItem_SaveStateStatus,
+
+ // Extension
+ DatItem_Extension_Name,
+
+ // Feature
+ DatItem_FeatureType,
+ DatItem_FeatureStatus,
+ DatItem_FeatureOverall,
+
+ // Input
+ DatItem_Service,
+ DatItem_Tilt,
+ DatItem_Players,
+ DatItem_Coins,
+
+ // Instance
+ DatItem_Instance_Name,
+ DatItem_Instance_BriefName,
+
+ // Location
+ DatItem_Location_Name,
+ DatItem_Location_Number,
+ DatItem_Location_Inverted,
+
+ // Part
+ DatItem_Part_Name,
+ DatItem_Part_Interface,
+
+ // PartFeature
+ DatItem_Part_Feature_Name,
+ DatItem_Part_Feature_Value,
+
+ // RamOption
+ DatItem_Content,
+
+ // Release
+ DatItem_Language,
+
+ // Setting
+ DatItem_Setting_Name,
+ DatItem_Setting_Value,
+ DatItem_Setting_Default,
+
+ // SlotOption
+ DatItem_SlotOption_Name,
+ DatItem_SlotOption_DeviceName,
+ DatItem_SlotOption_Default,
+
+ // SoftwareList
+ DatItem_SoftwareListStatus,
+ DatItem_Filter,
+
+ // Sound
+ DatItem_Channels,
+
+ #endregion
+
+ #endregion // Item-Specific
+
+ #endregion // DatItem
+ }
+
///
/// Available hashing types
///
diff --git a/SabreTools.Library/DatFiles/AttractMode.cs b/SabreTools.Library/DatFiles/AttractMode.cs
index a0fce09e..b4fa6b44 100644
--- a/SabreTools.Library/DatFiles/AttractMode.cs
+++ b/SabreTools.Library/DatFiles/AttractMode.cs
@@ -6,7 +6,6 @@ using System.Text;
using SabreTools.Data;
using SabreTools.IO;
using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
namespace SabreTools.Library.DatFiles
{
diff --git a/SabreTools.Library/DatFiles/ClrMamePro.cs b/SabreTools.Library/DatFiles/ClrMamePro.cs
index 31863e8d..5ca24b02 100644
--- a/SabreTools.Library/DatFiles/ClrMamePro.cs
+++ b/SabreTools.Library/DatFiles/ClrMamePro.cs
@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
+using SabreTools.Data;
using SabreTools.IO;
using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
using SabreTools.Library.Tools;
namespace SabreTools.Library.DatFiles
diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs
index f93a8da4..84883745 100644
--- a/SabreTools.Library/DatFiles/DatFile.cs
+++ b/SabreTools.Library/DatFiles/DatFile.cs
@@ -2898,7 +2898,7 @@ namespace SabreTools.Library.DatFiles
Folder outputArchive = GetPreconfiguredFolder(date, outputFormat);
// Now rebuild to the output file
- outputArchive.Write(fileStream, outDir, item as Rom);
+ outputArchive.Write(fileStream, outDir, (item as Rom).ConvertToBaseFile());
}
// Close the input stream
@@ -2939,8 +2939,8 @@ namespace SabreTools.Library.DatFiles
// Now rebuild to the output file
bool eitherSuccess = false;
- eitherSuccess |= outputArchive.Write(transformStream, outDir, item as Rom);
- eitherSuccess |= outputArchive.Write(fileStream, outDir, datItem as Rom);
+ eitherSuccess |= outputArchive.Write(transformStream, outDir, (item as Rom).ConvertToBaseFile());
+ eitherSuccess |= outputArchive.Write(fileStream, outDir, (datItem as Rom).ConvertToBaseFile());
// Now add the success of either rebuild
rebuilt &= eitherSuccess;
diff --git a/SabreTools.Library/DatFiles/DosCenter.cs b/SabreTools.Library/DatFiles/DosCenter.cs
index f797c7fe..f3c2f3ab 100644
--- a/SabreTools.Library/DatFiles/DosCenter.cs
+++ b/SabreTools.Library/DatFiles/DosCenter.cs
@@ -6,7 +6,6 @@ using System.Text;
using SabreTools.IO;
using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
using SabreTools.Library.Tools;
namespace SabreTools.Library.DatFiles
diff --git a/SabreTools.Library/DatFiles/Enums.cs b/SabreTools.Library/DatFiles/Enums.cs
index 752c6cbf..b0f5ce3a 100644
--- a/SabreTools.Library/DatFiles/Enums.cs
+++ b/SabreTools.Library/DatFiles/Enums.cs
@@ -2,27 +2,6 @@
namespace SabreTools.Library.DatFiles
{
- ///
- /// Determines the DAT deduplication type
- ///
- public enum DedupeType
- {
- None = 0,
- Full,
-
- // Force only deduping with certain types
- Game,
- CRC,
- MD5,
-#if NET_FRAMEWORK
- RIPEMD160,
-#endif
- SHA1,
- SHA256,
- SHA384,
- SHA512,
- }
-
///
/// Determines merging tag handling for DAT output
///
diff --git a/SabreTools.Library/DatFiles/EverdriveSmdb.cs b/SabreTools.Library/DatFiles/EverdriveSmdb.cs
index a0c44874..051b76d3 100644
--- a/SabreTools.Library/DatFiles/EverdriveSmdb.cs
+++ b/SabreTools.Library/DatFiles/EverdriveSmdb.cs
@@ -5,7 +5,6 @@ using System.Text;
using SabreTools.IO;
using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
namespace SabreTools.Library.DatFiles
{
diff --git a/SabreTools.Library/DatFiles/Hashfile.cs b/SabreTools.Library/DatFiles/Hashfile.cs
index 21fba2f0..87d5c27c 100644
--- a/SabreTools.Library/DatFiles/Hashfile.cs
+++ b/SabreTools.Library/DatFiles/Hashfile.cs
@@ -6,7 +6,6 @@ using System.Text;
using SabreTools.Data;
using SabreTools.IO;
using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
namespace SabreTools.Library.DatFiles
{
diff --git a/SabreTools.Library/DatFiles/RomCenter.cs b/SabreTools.Library/DatFiles/RomCenter.cs
index 7f2c8cb3..d816c8c2 100644
--- a/SabreTools.Library/DatFiles/RomCenter.cs
+++ b/SabreTools.Library/DatFiles/RomCenter.cs
@@ -5,7 +5,6 @@ using System.Text;
using SabreTools.IO;
using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
using SabreTools.Library.Tools;
namespace SabreTools.Library.DatFiles
diff --git a/SabreTools.Library/DatFiles/SabreJSON.cs b/SabreTools.Library/DatFiles/SabreJSON.cs
index 40039159..ba61f986 100644
--- a/SabreTools.Library/DatFiles/SabreJSON.cs
+++ b/SabreTools.Library/DatFiles/SabreJSON.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
-using SabreTools.IO;
using SabreTools.Library.DatItems;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatFiles/SeparatedValue.cs b/SabreTools.Library/DatFiles/SeparatedValue.cs
index f081287f..74f53d10 100644
--- a/SabreTools.Library/DatFiles/SeparatedValue.cs
+++ b/SabreTools.Library/DatFiles/SeparatedValue.cs
@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
+using SabreTools.Data;
using SabreTools.IO;
using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
using SabreTools.Library.Tools;
namespace SabreTools.Library.DatFiles
diff --git a/SabreTools.Library/DatItems/Adjuster.cs b/SabreTools.Library/DatItems/Adjuster.cs
index 81193924..98631810 100644
--- a/SabreTools.Library/DatItems/Adjuster.cs
+++ b/SabreTools.Library/DatItems/Adjuster.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Analog.cs b/SabreTools.Library/DatItems/Analog.cs
index 00030424..77d3db0b 100644
--- a/SabreTools.Library/DatItems/Analog.cs
+++ b/SabreTools.Library/DatItems/Analog.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Archive.cs b/SabreTools.Library/DatItems/Archive.cs
index 064e71b4..23a8a755 100644
--- a/SabreTools.Library/DatItems/Archive.cs
+++ b/SabreTools.Library/DatItems/Archive.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/BiosSet.cs b/SabreTools.Library/DatItems/BiosSet.cs
index 2034ef00..2279b0d3 100644
--- a/SabreTools.Library/DatItems/BiosSet.cs
+++ b/SabreTools.Library/DatItems/BiosSet.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Chip.cs b/SabreTools.Library/DatItems/Chip.cs
index 7fd474b1..de3ccf78 100644
--- a/SabreTools.Library/DatItems/Chip.cs
+++ b/SabreTools.Library/DatItems/Chip.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Condition.cs b/SabreTools.Library/DatItems/Condition.cs
index 6e38ddb7..ce3d6f51 100644
--- a/SabreTools.Library/DatItems/Condition.cs
+++ b/SabreTools.Library/DatItems/Condition.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Configuration.cs b/SabreTools.Library/DatItems/Configuration.cs
index 1288f27f..db3e2a66 100644
--- a/SabreTools.Library/DatItems/Configuration.cs
+++ b/SabreTools.Library/DatItems/Configuration.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Control.cs b/SabreTools.Library/DatItems/Control.cs
index 43c54f41..98365ed7 100644
--- a/SabreTools.Library/DatItems/Control.cs
+++ b/SabreTools.Library/DatItems/Control.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/DataArea.cs b/SabreTools.Library/DatItems/DataArea.cs
index 338a8aee..8ea00a44 100644
--- a/SabreTools.Library/DatItems/DataArea.cs
+++ b/SabreTools.Library/DatItems/DataArea.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Device.cs b/SabreTools.Library/DatItems/Device.cs
index e1406c1c..45a24d59 100644
--- a/SabreTools.Library/DatItems/Device.cs
+++ b/SabreTools.Library/DatItems/Device.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/DeviceReference.cs b/SabreTools.Library/DatItems/DeviceReference.cs
index b68ef830..3518e6f4 100644
--- a/SabreTools.Library/DatItems/DeviceReference.cs
+++ b/SabreTools.Library/DatItems/DeviceReference.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/DipSwitch.cs b/SabreTools.Library/DatItems/DipSwitch.cs
index 61cbb690..7398b563 100644
--- a/SabreTools.Library/DatItems/DipSwitch.cs
+++ b/SabreTools.Library/DatItems/DipSwitch.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Disk.cs b/SabreTools.Library/DatItems/Disk.cs
index d5907940..00e82fa4 100644
--- a/SabreTools.Library/DatItems/Disk.cs
+++ b/SabreTools.Library/DatItems/Disk.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.FileTypes;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
@@ -273,6 +274,20 @@ namespace SabreTools.Library.DatItems
};
}
+ ///
+ /// Convert Disk object to a BaseFile
+ ///
+ public BaseFile ConvertToBaseFile()
+ {
+ return new BaseFile()
+ {
+ Filename = this.Name,
+ Parent = this.Machine?.Name,
+ MD5 = this._md5,
+ SHA1 = this._sha1,
+ };
+ }
+
///
/// Convert a disk to the closest Rom approximation
///
diff --git a/SabreTools.Library/DatItems/DiskArea.cs b/SabreTools.Library/DatItems/DiskArea.cs
index 74758759..36c69144 100644
--- a/SabreTools.Library/DatItems/DiskArea.cs
+++ b/SabreTools.Library/DatItems/DiskArea.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Display.cs b/SabreTools.Library/DatItems/Display.cs
index ea9f5d99..0f20587c 100644
--- a/SabreTools.Library/DatItems/Display.cs
+++ b/SabreTools.Library/DatItems/Display.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Driver.cs b/SabreTools.Library/DatItems/Driver.cs
index 163a9dc8..67d63ad6 100644
--- a/SabreTools.Library/DatItems/Driver.cs
+++ b/SabreTools.Library/DatItems/Driver.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Enums.cs b/SabreTools.Library/DatItems/Enums.cs
index 18a5217b..aa2e84a3 100644
--- a/SabreTools.Library/DatItems/Enums.cs
+++ b/SabreTools.Library/DatItems/Enums.cs
@@ -169,341 +169,6 @@ namespace SabreTools.Library.DatItems
Timing = 1 << 13,
}
- ///
- /// List of valid field types within a DatItem/Machine
- ///
- public enum Field : int
- {
- NULL = 0,
-
- #region DatHeader
-
- #region Common
-
- DatHeader_FileName,
- DatHeader_Name,
- DatHeader_Description,
- DatHeader_RootDir,
- DatHeader_Category,
- DatHeader_Version,
- DatHeader_Date,
- DatHeader_Author,
- DatHeader_Email,
- DatHeader_Homepage,
- DatHeader_Url,
- DatHeader_Comment,
- DatHeader_HeaderSkipper,
- DatHeader_Type,
- DatHeader_ForceMerging,
- DatHeader_ForceNodump,
- DatHeader_ForcePacking,
-
- #endregion
-
- #region ListXML
-
- DatHeader_Debug,
- DatHeader_MameConfig,
-
- #endregion
-
- #region Logiqx
-
- DatHeader_Build,
- DatHeader_RomMode,
- DatHeader_BiosMode,
- DatHeader_SampleMode,
- DatHeader_LockRomMode,
- DatHeader_LockBiosMode,
- DatHeader_LockSampleMode,
-
- #endregion
-
- #region OfflineList
-
- DatHeader_System,
- DatHeader_ScreenshotsWidth,
- DatHeader_ScreenshotsHeight,
- DatHeader_CanOpen,
- DatHeader_RomTitle,
-
- // Infos
- DatHeader_Info_Name,
- DatHeader_Info_Visible,
- DatHeader_Info_IsNamingOption,
- DatHeader_Info_Default,
-
- #endregion
-
- #region RomCenter
-
- DatHeader_RomCenterVersion,
-
- #endregion
-
- #endregion // DatHeader
-
- #region Machine
-
- #region Common
-
- Machine_Name,
- Machine_Comment,
- Machine_Description,
- Machine_Year,
- Machine_Manufacturer,
- Machine_Publisher,
- Machine_Category,
- Machine_RomOf,
- Machine_CloneOf,
- Machine_SampleOf,
- Machine_Type,
-
- #endregion
-
- #region AttractMode
-
- Machine_Players,
- Machine_Rotation,
- Machine_Control,
- Machine_Status,
- Machine_DisplayCount,
- Machine_DisplayType,
- Machine_Buttons,
-
- #endregion
-
- #region ListXML
-
- Machine_SourceFile,
- Machine_Runnable,
-
- #endregion
-
- #region Logiqx
-
- Machine_Board,
- Machine_RebuildTo,
-
- #endregion
-
- #region Logiqx EmuArc
-
- Machine_TitleID,
- Machine_Developer,
- Machine_Genre,
- Machine_Subgenre,
- Machine_Ratings,
- Machine_Score,
- Machine_Enabled,
- Machine_CRC,
- Machine_RelatedTo,
-
- #endregion
-
- #region OpenMSX
-
- Machine_GenMSXID,
- Machine_System,
- Machine_Country,
-
- #endregion
-
- #region SoftwareList
-
- Machine_Supported,
-
- #endregion
-
- #endregion // Machine
-
- #region DatItem
-
- #region Common
-
- DatItem_Type,
-
- #endregion
-
- #region Item-Specific
-
- #region Actionable
-
- // Rom
- DatItem_Name,
- DatItem_Bios,
- DatItem_Size,
- DatItem_CRC,
- DatItem_MD5,
-#if NET_FRAMEWORK
- DatItem_RIPEMD160,
-#endif
- DatItem_SHA1,
- DatItem_SHA256,
- DatItem_SHA384,
- DatItem_SHA512,
- DatItem_SpamSum,
- DatItem_Merge,
- DatItem_Region,
- DatItem_Offset,
- DatItem_Date,
- DatItem_Status,
- DatItem_Optional,
- DatItem_Inverted,
-
- // Rom (AttractMode)
- DatItem_AltName,
- DatItem_AltTitle,
-
- // Rom (OpenMSX)
- DatItem_Original,
- DatItem_OpenMSXSubType,
- DatItem_OpenMSXType,
- DatItem_Remark,
- DatItem_Boot,
-
- // Rom (SoftwareList)
- DatItem_LoadFlag,
- DatItem_Value,
-
- // Disk
- DatItem_Index,
- DatItem_Writable,
-
- #endregion
-
- #region Auxiliary
-
- // Adjuster
- DatItem_Default,
-
- // Analog
- DatItem_Analog_Mask,
-
- // BiosSet
- DatItem_Description,
-
- // Chip
- DatItem_Tag,
- DatItem_ChipType,
- DatItem_Clock,
-
- // Condition
- DatItem_Mask,
- DatItem_Relation,
- DatItem_Condition_Tag,
- DatItem_Condition_Mask,
- DatItem_Condition_Relation,
- DatItem_Condition_Value,
-
- // Control
- DatItem_Control_Type,
- DatItem_Control_Player,
- DatItem_Control_Buttons,
- DatItem_Control_RequiredButtons,
- DatItem_Control_Minimum,
- DatItem_Control_Maximum,
- DatItem_Control_Sensitivity,
- DatItem_Control_KeyDelta,
- DatItem_Control_Reverse,
- DatItem_Control_Ways,
- DatItem_Control_Ways2,
- DatItem_Control_Ways3,
-
- // DataArea
- DatItem_AreaName,
- DatItem_AreaSize,
- DatItem_AreaWidth,
- DatItem_AreaEndianness,
-
- // Device
- DatItem_DeviceType,
- DatItem_FixedImage,
- DatItem_Mandatory,
- DatItem_Interface,
-
- // Display
- DatItem_DisplayType,
- DatItem_Rotate,
- DatItem_FlipX,
- DatItem_Width,
- DatItem_Height,
- DatItem_Refresh,
- DatItem_PixClock,
- DatItem_HTotal,
- DatItem_HBEnd,
- DatItem_HBStart,
- DatItem_VTotal,
- DatItem_VBEnd,
- DatItem_VBStart,
-
- // Driver
- DatItem_SupportStatus,
- DatItem_EmulationStatus,
- DatItem_CocktailStatus,
- DatItem_SaveStateStatus,
-
- // Extension
- DatItem_Extension_Name,
-
- // Feature
- DatItem_FeatureType,
- DatItem_FeatureStatus,
- DatItem_FeatureOverall,
-
- // Input
- DatItem_Service,
- DatItem_Tilt,
- DatItem_Players,
- DatItem_Coins,
-
- // Instance
- DatItem_Instance_Name,
- DatItem_Instance_BriefName,
-
- // Location
- DatItem_Location_Name,
- DatItem_Location_Number,
- DatItem_Location_Inverted,
-
- // Part
- DatItem_Part_Name,
- DatItem_Part_Interface,
-
- // PartFeature
- DatItem_Part_Feature_Name,
- DatItem_Part_Feature_Value,
-
- // RamOption
- DatItem_Content,
-
- // Release
- DatItem_Language,
-
- // Setting
- DatItem_Setting_Name,
- DatItem_Setting_Value,
- DatItem_Setting_Default,
-
- // SlotOption
- DatItem_SlotOption_Name,
- DatItem_SlotOption_DeviceName,
- DatItem_SlotOption_Default,
-
- // SoftwareList
- DatItem_SoftwareListStatus,
- DatItem_Filter,
-
- // Sound
- DatItem_Channels,
-
- #endregion
-
- #endregion // Item-Specific
-
- #endregion // DatItem
- }
-
///
/// Determine the status of the item
///
diff --git a/SabreTools.Library/DatItems/Extension.cs b/SabreTools.Library/DatItems/Extension.cs
index 919e7695..0ba81c9e 100644
--- a/SabreTools.Library/DatItems/Extension.cs
+++ b/SabreTools.Library/DatItems/Extension.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Feature.cs b/SabreTools.Library/DatItems/Feature.cs
index 4b6b2dee..b0349e19 100644
--- a/SabreTools.Library/DatItems/Feature.cs
+++ b/SabreTools.Library/DatItems/Feature.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Info.cs b/SabreTools.Library/DatItems/Info.cs
index 4d5a83c9..da88d7ca 100644
--- a/SabreTools.Library/DatItems/Info.cs
+++ b/SabreTools.Library/DatItems/Info.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Input.cs b/SabreTools.Library/DatItems/Input.cs
index e4243599..cc0b239c 100644
--- a/SabreTools.Library/DatItems/Input.cs
+++ b/SabreTools.Library/DatItems/Input.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Instance.cs b/SabreTools.Library/DatItems/Instance.cs
index 163e64a5..9889c163 100644
--- a/SabreTools.Library/DatItems/Instance.cs
+++ b/SabreTools.Library/DatItems/Instance.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Location.cs b/SabreTools.Library/DatItems/Location.cs
index 7cd14f54..22664ea4 100644
--- a/SabreTools.Library/DatItems/Location.cs
+++ b/SabreTools.Library/DatItems/Location.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Machine.cs b/SabreTools.Library/DatItems/Machine.cs
index 5cfe88a6..874c08de 100644
--- a/SabreTools.Library/DatItems/Machine.cs
+++ b/SabreTools.Library/DatItems/Machine.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Media.cs b/SabreTools.Library/DatItems/Media.cs
index 0f73eb69..eda7991e 100644
--- a/SabreTools.Library/DatItems/Media.cs
+++ b/SabreTools.Library/DatItems/Media.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.FileTypes;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
@@ -171,6 +172,22 @@ namespace SabreTools.Library.DatItems
};
}
+ ///
+ /// Convert Media object to a BaseFile
+ ///
+ public BaseFile ConvertToBaseFile()
+ {
+ return new BaseFile()
+ {
+ Filename = this.Name,
+ Parent = this.Machine?.Name,
+ MD5 = this._md5,
+ SHA1 = this._sha1,
+ SHA256 = this._sha256,
+ SpamSum = this._spamsum,
+ };
+ }
+
///
/// Convert a media to the closest Rom approximation
///
diff --git a/SabreTools.Library/DatItems/Part.cs b/SabreTools.Library/DatItems/Part.cs
index d80b2311..6566dcb1 100644
--- a/SabreTools.Library/DatItems/Part.cs
+++ b/SabreTools.Library/DatItems/Part.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/PartFeature.cs b/SabreTools.Library/DatItems/PartFeature.cs
index eadc8fb7..11867a0c 100644
--- a/SabreTools.Library/DatItems/PartFeature.cs
+++ b/SabreTools.Library/DatItems/PartFeature.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Port.cs b/SabreTools.Library/DatItems/Port.cs
index 954dc51d..d3aae491 100644
--- a/SabreTools.Library/DatItems/Port.cs
+++ b/SabreTools.Library/DatItems/Port.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/RamOption.cs b/SabreTools.Library/DatItems/RamOption.cs
index 52601c5d..d6e1bd2f 100644
--- a/SabreTools.Library/DatItems/RamOption.cs
+++ b/SabreTools.Library/DatItems/RamOption.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Release.cs b/SabreTools.Library/DatItems/Release.cs
index d707adb6..1ee8b8d3 100644
--- a/SabreTools.Library/DatItems/Release.cs
+++ b/SabreTools.Library/DatItems/Release.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Rom.cs b/SabreTools.Library/DatItems/Rom.cs
index a9d8be4d..8ad7dd72 100644
--- a/SabreTools.Library/DatItems/Rom.cs
+++ b/SabreTools.Library/DatItems/Rom.cs
@@ -587,6 +587,30 @@ namespace SabreTools.Library.DatItems
};
}
+ ///
+ /// Convert Rom object to a BaseFile
+ ///
+ public BaseFile ConvertToBaseFile()
+ {
+ return new BaseFile()
+ {
+ Filename = this.Name,
+ Parent = this.Machine?.Name,
+ Date = this.Date,
+ Size = this.Size,
+ CRC = this._crc,
+ MD5 = this._md5,
+#if NET_FRAMEWORK
+ RIPEMD160 = this._ripemd160,
+#endif
+ SHA1 = this._sha1,
+ SHA256 = this._sha256,
+ SHA384 = this._sha384,
+ SHA512 = this._sha512,
+ SpamSum = this._spamsum,
+ };
+ }
+
#endregion
#region Comparision Methods
diff --git a/SabreTools.Library/DatItems/Sample.cs b/SabreTools.Library/DatItems/Sample.cs
index 3ecab9ed..d544cefd 100644
--- a/SabreTools.Library/DatItems/Sample.cs
+++ b/SabreTools.Library/DatItems/Sample.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Setting.cs b/SabreTools.Library/DatItems/Setting.cs
index 4646dbc2..5f0fc678 100644
--- a/SabreTools.Library/DatItems/Setting.cs
+++ b/SabreTools.Library/DatItems/Setting.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/SharedFeature.cs b/SabreTools.Library/DatItems/SharedFeature.cs
index 9faf07c0..1a805348 100644
--- a/SabreTools.Library/DatItems/SharedFeature.cs
+++ b/SabreTools.Library/DatItems/SharedFeature.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Slot.cs b/SabreTools.Library/DatItems/Slot.cs
index 59e3823b..3c5b9c1d 100644
--- a/SabreTools.Library/DatItems/Slot.cs
+++ b/SabreTools.Library/DatItems/Slot.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/SlotOption.cs b/SabreTools.Library/DatItems/SlotOption.cs
index fec66cfc..d00c7cae 100644
--- a/SabreTools.Library/DatItems/SlotOption.cs
+++ b/SabreTools.Library/DatItems/SlotOption.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/SoftwareList.cs b/SabreTools.Library/DatItems/SoftwareList.cs
index 992829a2..3a49dbe0 100644
--- a/SabreTools.Library/DatItems/SoftwareList.cs
+++ b/SabreTools.Library/DatItems/SoftwareList.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/DatItems/Sound.cs b/SabreTools.Library/DatItems/Sound.cs
index ea4d5e95..61d87b7d 100644
--- a/SabreTools.Library/DatItems/Sound.cs
+++ b/SabreTools.Library/DatItems/Sound.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
+using SabreTools.Data;
using SabreTools.Library.Filtering;
using SabreTools.Library.Tools;
using Newtonsoft.Json;
diff --git a/SabreTools.Library/FileTypes/AaruFormat.cs b/SabreTools.Library/FileTypes/AaruFormat.cs
index 16dca453..78ad3c52 100644
--- a/SabreTools.Library/FileTypes/AaruFormat.cs
+++ b/SabreTools.Library/FileTypes/AaruFormat.cs
@@ -5,7 +5,6 @@ using System.Text;
using SabreTools.IO;
using SabreTools.Data;
using SabreTools.Library.FileTypes.Aaru;
-using SabreTools.Library.IO;
namespace SabreTools.Library.FileTypes
{
diff --git a/SabreTools.Library/FileTypes/BaseArchive.cs b/SabreTools.Library/FileTypes/BaseArchive.cs
index 409a0851..ba2515a2 100644
--- a/SabreTools.Library/FileTypes/BaseArchive.cs
+++ b/SabreTools.Library/FileTypes/BaseArchive.cs
@@ -2,8 +2,6 @@
using System.IO;
using SabreTools.Data;
-using SabreTools.IO;
-using SabreTools.Library.DatItems;
namespace SabreTools.Library.FileTypes
{
@@ -127,44 +125,23 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override abstract bool CopyAll(string outDir);
- ///
- /// Attempt to extract an entry from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override abstract string CopyToFile(string entryName, string outDir);
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override abstract (MemoryStream, string) CopyToStream(string entryName);
#endregion
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override abstract List GetChildren();
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override abstract List GetEmptyFolders();
///
@@ -176,32 +153,14 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to an archive
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override abstract bool Write(string inputFile, string outDir, Rom rom);
+ ///
+ public override abstract bool Write(string inputFile, string outDir, BaseFile baseFile);
- ///
- /// Write an input stream to an archive
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override abstract bool Write(Stream inputStream, string outDir, Rom rom);
+ ///
+ public override abstract bool Write(Stream inputStream, string outDir, BaseFile baseFile);
- ///
- /// Write a set of input files to an archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override abstract bool Write(List inputFiles, string outDir, List roms);
+ ///
+ public override abstract bool Write(List inputFiles, string outDir, List baseFiles);
#endregion
}
diff --git a/SabreTools.Library/FileTypes/Folder.cs b/SabreTools.Library/FileTypes/Folder.cs
index 5c43d77e..5dfa69cf 100644
--- a/SabreTools.Library/FileTypes/Folder.cs
+++ b/SabreTools.Library/FileTypes/Folder.cs
@@ -6,7 +6,6 @@ using System.Linq;
using SabreTools.Data;
using SabreTools.IO;
using SabreTools.Logging;
-using SabreTools.Library.DatItems;
using SabreTools.Library.Tools;
namespace SabreTools.Library.FileTypes
@@ -227,7 +226,6 @@ namespace SabreTools.Library.FileTypes
/// Attempt to extract a stream from an archive
///
/// Name of the entry to be extracted
- /// Output representing the entry name that was found
/// MemoryStream representing the entry, null on error
public virtual (MemoryStream, string) CopyToStream(string entryName)
{
@@ -310,13 +308,13 @@ namespace SabreTools.Library.FileTypes
///
/// Input filename to be moved
/// Output directory to build to
- /// DatItem representing the new information
+ /// BaseFile representing the new information
/// True if the write was a success, false otherwise
/// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public virtual bool Write(string inputFile, string outDir, Rom rom)
+ public virtual bool Write(string inputFile, string outDir, BaseFile baseFile)
{
FileStream fs = File.OpenRead(inputFile);
- return Write(fs, outDir, rom);
+ return Write(fs, outDir, baseFile);
}
///
@@ -324,15 +322,15 @@ namespace SabreTools.Library.FileTypes
///
/// Input stream to be moved
/// Output directory to build to
- /// DatItem representing the new information
+ /// BaseFile representing the new information
/// True if the write was a success, false otherwise
/// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public virtual bool Write(Stream inputStream, string outDir, Rom rom)
+ public virtual bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
bool success = false;
// If either input is null or empty, return
- if (inputStream == null || rom == null || rom.Name == null)
+ if (inputStream == null || baseFile == null || baseFile.Filename == null)
return success;
// If the stream is not readable, return
@@ -345,9 +343,9 @@ namespace SabreTools.Library.FileTypes
// Get the output folder name from the first rebuild rom
string fileName;
if (writeToParent)
- fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Name));
+ fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Filename));
else
- fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name), Sanitizer.RemovePathUnsafeCharacters(rom.Name));
+ fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Parent), Sanitizer.RemovePathUnsafeCharacters(baseFile.Filename));
try
{
@@ -374,11 +372,8 @@ namespace SabreTools.Library.FileTypes
outputStream.Dispose();
- if (rom.ItemType == ItemType.Rom)
- {
- if (!string.IsNullOrWhiteSpace(rom.Date))
- File.SetCreationTime(fileName, DateTime.Parse(rom.Date));
- }
+ if (!string.IsNullOrWhiteSpace(baseFile.Date))
+ File.SetCreationTime(fileName, DateTime.Parse(baseFile.Date));
success = true;
}
@@ -401,9 +396,9 @@ namespace SabreTools.Library.FileTypes
///
/// Input files to be moved
/// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public virtual bool Write(List inputFiles, string outDir, List roms)
+ /// BaseFiles representing the new information
+ /// True if the inputs were written properly, false otherwise
+ public virtual bool Write(List inputFiles, string outDir, List baseFiles)
{
throw new NotImplementedException();
}
diff --git a/SabreTools.Library/FileTypes/GZipArchive.cs b/SabreTools.Library/FileTypes/GZipArchive.cs
index 5c81f827..bde07f6f 100644
--- a/SabreTools.Library/FileTypes/GZipArchive.cs
+++ b/SabreTools.Library/FileTypes/GZipArchive.cs
@@ -6,9 +6,6 @@ using System.Text.RegularExpressions;
using SabreTools.Data;
using SabreTools.IO;
-using SabreTools.Library.DatFiles;
-using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
using SabreTools.Library.Tools;
using Compress;
using Compress.gZip;
@@ -57,11 +54,7 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -104,12 +97,7 @@ namespace SabreTools.Library.FileTypes
return encounteredErrors;
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
@@ -150,12 +138,7 @@ namespace SabreTools.Library.FileTypes
return realEntry;
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
@@ -196,10 +179,7 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
if (_children == null || _children.Count == 0)
@@ -261,20 +241,14 @@ namespace SabreTools.Library.FileTypes
return _children;
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
// GZip files don't contain directories
return new List();
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
// Check for the file existing first
@@ -301,7 +275,7 @@ namespace SabreTools.Library.FileTypes
// Check if the file is at least the minimum length
if (filesize < 40 /* bytes */)
{
- logger.Warning($"Possibly corrupt file '{Path.GetFullPath(this.Filename)}' with size {Utilities.GetBytesReadable(filesize)}");
+ logger.Warning($"Possibly corrupt file '{Path.GetFullPath(this.Filename)}' with size {filesize}");
return false;
}
@@ -362,7 +336,7 @@ namespace SabreTools.Library.FileTypes
// Check if the file is at least the minimum length
if (filesize < 40 /* bytes */)
{
- logger.Warning($"Possibly corrupt file '{Path.GetFullPath(this.Filename)}' with size {Utilities.GetBytesReadable(filesize)}");
+ logger.Warning($"Possibly corrupt file '{Path.GetFullPath(this.Filename)}' with size {filesize}");
return null;
}
@@ -415,15 +389,8 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrent GZ file
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(string inputFile, string outDir, Rom rom = null)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile = null)
{
// Check that the input file exists
if (!File.Exists(inputFile))
@@ -435,18 +402,11 @@ namespace SabreTools.Library.FileTypes
inputFile = Path.GetFullPath(inputFile);
// Get the file stream for the file and write out
- return Write(File.OpenRead(inputFile), outDir, rom);
+ return Write(File.OpenRead(inputFile), outDir, baseFile);
}
- ///
- /// Write an input stream to a torrent GZ file
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(Stream inputStream, string outDir, Rom rom = null)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile = null)
{
bool success = false;
@@ -461,10 +421,10 @@ namespace SabreTools.Library.FileTypes
outDir = Path.GetFullPath(outDir);
// Now get the Rom info for the file so we have hashes and size
- rom = new Rom(GetInfo(inputStream, keepReadOpen: true));
+ baseFile = GetInfo(inputStream, keepReadOpen: true);
// Get the output file name
- string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(rom.SHA1, Depth));
+ string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(Utilities.ByteArrayToString(baseFile.SHA1), Depth));
// Check to see if the folder needs to be created
if (!Directory.Exists(Path.GetDirectoryName(outfile)))
@@ -481,11 +441,11 @@ namespace SabreTools.Library.FileTypes
// Write standard header and TGZ info
byte[] data = Constants.TorrentGZHeader
- .Concat(Utilities.StringToByteArray(rom.MD5)) // MD5
- .Concat(Utilities.StringToByteArray(rom.CRC)) // CRC
+ .Concat(baseFile.MD5) // MD5
+ .Concat(baseFile.CRC) // CRC
.ToArray();
sw.Write(data);
- sw.Write((ulong)(rom.Size ?? 0)); // Long size (Unsigned, Mirrored)
+ sw.Write((ulong)(baseFile.Size ?? 0)); // Long size (Unsigned, Mirrored)
// Now create a deflatestream from the input file
ZlibBaseStream ds = new ZlibBaseStream(outputStream, CompressionMode.Compress, CompressionLevel.BestCompression, ZlibStreamFlavor.DEFLATE, true);
@@ -502,8 +462,8 @@ namespace SabreTools.Library.FileTypes
ds.Dispose();
// Now write the standard footer
- sw.Write(Utilities.StringToByteArray(rom.CRC).Reverse().ToArray());
- sw.Write((uint)(rom.Size ?? 0));
+ sw.Write(baseFile.CRC.Reverse().ToArray());
+ sw.Write((uint)(baseFile.Size ?? 0));
// Dispose of everything
sw.Dispose();
@@ -513,14 +473,8 @@ namespace SabreTools.Library.FileTypes
return true;
}
- ///
- /// Write a set of input files to a torrent GZ archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFile)
{
throw new NotImplementedException();
}
diff --git a/SabreTools.Library/FileTypes/LRZipArchive.cs b/SabreTools.Library/FileTypes/LRZipArchive.cs
index 7e2eff23..31e3e59e 100644
--- a/SabreTools.Library/FileTypes/LRZipArchive.cs
+++ b/SabreTools.Library/FileTypes/LRZipArchive.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using SabreTools.Data;
-using SabreTools.Library.DatItems;
namespace SabreTools.Library.FileTypes
{
@@ -39,33 +38,19 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
throw new NotImplementedException();
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
throw new NotImplementedException();
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
throw new NotImplementedException();
@@ -75,28 +60,19 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
throw new NotImplementedException();
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
throw new NotImplementedException();
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
throw new NotImplementedException();
@@ -106,40 +82,20 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrent LRZip file
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile)
{
throw new NotImplementedException();
}
- ///
- /// Write an input stream to a torrent LRZip file
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
throw new NotImplementedException();
}
- ///
- /// Write a set of input files to a torrent LRZip archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFiles)
{
throw new NotImplementedException();
}
diff --git a/SabreTools.Library/FileTypes/LZ4Archive.cs b/SabreTools.Library/FileTypes/LZ4Archive.cs
index 9091ac1e..29d79c6e 100644
--- a/SabreTools.Library/FileTypes/LZ4Archive.cs
+++ b/SabreTools.Library/FileTypes/LZ4Archive.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using SabreTools.Data;
-using SabreTools.Library.DatItems;
namespace SabreTools.Library.FileTypes
{
@@ -39,33 +38,19 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
throw new NotImplementedException();
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
throw new NotImplementedException();
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
throw new NotImplementedException();
@@ -75,28 +60,19 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
throw new NotImplementedException();
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
throw new NotImplementedException();
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
throw new NotImplementedException();
@@ -106,40 +82,20 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrent LZ4 file
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile rom)
{
throw new NotImplementedException();
}
- ///
- /// Write an input stream to a torrent LZ4 file
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile rom)
{
throw new NotImplementedException();
}
- ///
- /// Write a set of input files to a torrent LZ4 archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFiles)
{
throw new NotImplementedException();
}
diff --git a/SabreTools.Library/FileTypes/RarArchive.cs b/SabreTools.Library/FileTypes/RarArchive.cs
index 52c147bb..660f99f8 100644
--- a/SabreTools.Library/FileTypes/RarArchive.cs
+++ b/SabreTools.Library/FileTypes/RarArchive.cs
@@ -4,8 +4,6 @@ using System.IO;
using System.Linq;
using SabreTools.Data;
-using SabreTools.IO;
-using SabreTools.Library.DatItems;
using SharpCompress.Archives;
using SharpCompress.Archives.Rar;
using SharpCompress.Readers;
@@ -44,11 +42,7 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -86,12 +80,7 @@ namespace SabreTools.Library.FileTypes
return encounteredErrors;
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
@@ -132,12 +121,7 @@ namespace SabreTools.Library.FileTypes
return realEntry;
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
@@ -171,10 +155,7 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
List found = new List();
@@ -222,11 +203,7 @@ namespace SabreTools.Library.FileTypes
return found;
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
List empties = new List();
@@ -262,9 +239,7 @@ namespace SabreTools.Library.FileTypes
return empties;
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
throw new NotImplementedException();
@@ -274,39 +249,21 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrentrar archive
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile)
{
// Get the file stream for the file and write out
- return Write(File.OpenRead(inputFile), outDir, rom);
+ return Write(File.OpenRead(inputFile), outDir, baseFile);
}
- ///
- /// Write an input stream to a torrentrar archive
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
throw new NotImplementedException();
}
- ///
- /// Write a set of input files to a torrentrar archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List roms)
{
throw new NotImplementedException();
}
diff --git a/SabreTools.Library/FileTypes/SevenZipArchive.cs b/SabreTools.Library/FileTypes/SevenZipArchive.cs
index a8002f43..9970ab52 100644
--- a/SabreTools.Library/FileTypes/SevenZipArchive.cs
+++ b/SabreTools.Library/FileTypes/SevenZipArchive.cs
@@ -4,8 +4,6 @@ using System.IO;
using System.Linq;
using SabreTools.Data;
-using SabreTools.IO;
-using SabreTools.Library.DatItems;
using SabreTools.Library.Tools;
using Compress;
using Compress.SevenZip;
@@ -46,11 +44,7 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -135,12 +129,7 @@ namespace SabreTools.Library.FileTypes
return encounteredErrors;
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
@@ -181,12 +170,7 @@ namespace SabreTools.Library.FileTypes
return realEntry;
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
@@ -255,10 +239,7 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
List found = new List();
@@ -329,11 +310,7 @@ namespace SabreTools.Library.FileTypes
return found;
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
List empties = new List();
@@ -381,9 +358,7 @@ namespace SabreTools.Library.FileTypes
return empties;
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
SevenZ zf = new SevenZ();
@@ -400,33 +375,21 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrent7z archive
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile)
{
// Get the file stream for the file and write out
- return Write(File.OpenRead(inputFile), outDir, rom);
+ return Write(File.OpenRead(inputFile), outDir, baseFile);
}
- ///
- /// Write an input file to a torrent7z archive
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
// If either input is null or empty, return
- if (inputStream == null || rom == null || rom.Name == null)
+ if (inputStream == null || baseFile == null || baseFile.Filename == null)
return success;
// If the stream is not readable, return
@@ -437,7 +400,7 @@ namespace SabreTools.Library.FileTypes
inputStream.Seek(0, SeekOrigin.Begin);
// Get the output archive name from the first rebuild rom
- string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name) + (rom.Machine.Name.EndsWith(".7z") ? string.Empty : ".7z"));
+ string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".7z") ? string.Empty : ".7z"));
// Set internal variables
Stream writeStream = null;
@@ -461,14 +424,14 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now;
- if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
- zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, false, baseFile.Filename.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
}
else
{
- zipFile.ZipFileOpenWriteStream(false, true, rom.Name.Replace('\\', '/'), istreamSize, 0, null, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, true, baseFile.Filename.Replace('\\', '/'), istreamSize, 0, null, out writeStream);
}
// Copy the input stream to the output
@@ -480,7 +443,7 @@ namespace SabreTools.Library.FileTypes
writeStream.Flush();
}
- zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(rom.CRC));
+ zipFile.ZipFileCloseWriteStream(baseFile.CRC);
}
// Otherwise, sort the input files and write out in the correct order
@@ -498,9 +461,9 @@ namespace SabreTools.Library.FileTypes
}
// If the old one doesn't contain the new file, then add it
- if (!oldZipFileContents.Contains(rom.Name.Replace('\\', '/')))
+ if (!oldZipFileContents.Contains(baseFile.Filename.Replace('\\', '/')))
{
- inputIndexMap.Add(rom.Name.Replace('\\', '/'), -1);
+ inputIndexMap.Add(baseFile.Filename.Replace('\\', '/'), -1);
}
// Then add all of the old entries to it too
@@ -536,14 +499,14 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now;
- if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
- zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, false, baseFile.Filename.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
}
else
{
- zipFile.ZipFileOpenWriteStream(false, true, rom.Name.Replace('\\', '/'), istreamSize, 0, null, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, true, baseFile.Filename.Replace('\\', '/'), istreamSize, 0, null, out writeStream);
}
// Copy the input stream to the output
@@ -555,7 +518,7 @@ namespace SabreTools.Library.FileTypes
writeStream.Flush();
}
- zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(rom.CRC));
+ zipFile.ZipFileCloseWriteStream(baseFile.CRC);
}
// Otherwise, copy the file from the old archive
@@ -604,26 +567,20 @@ namespace SabreTools.Library.FileTypes
return true;
}
- ///
- /// Write a set of input files to a torrent7z archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFiles)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
// If either list of roms is null or empty, return
- if (inputFiles == null || roms == null || inputFiles.Count == 0 || roms.Count == 0)
+ if (inputFiles == null || baseFiles == null || inputFiles.Count == 0 || baseFiles.Count == 0)
{
return success;
}
// If the number of inputs is less than the number of available roms, return
- if (inputFiles.Count < roms.Count)
+ if (inputFiles.Count < baseFiles.Count)
{
return success;
}
@@ -638,7 +595,7 @@ namespace SabreTools.Library.FileTypes
}
// Get the output archive name from the first rebuild rom
- string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".7z") ? string.Empty : ".7z"));
+ string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".7z") ? string.Empty : ".7z"));
// Set internal variables
Stream writeStream = null;
@@ -663,7 +620,7 @@ namespace SabreTools.Library.FileTypes
Dictionary inputIndexMap = new Dictionary();
for (int i = 0; i < inputFiles.Count; i++)
{
- inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), i);
+ inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), i);
}
// Sort the keys in TZIP order
@@ -681,14 +638,14 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length);
DateTime dt = DateTime.Now;
- if (UseDates && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[index].Date) && DateTime.TryParse(baseFiles[index].Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
- zipFile.ZipFileOpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, false, baseFiles[index].Filename.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
}
else
{
- zipFile.ZipFileOpenWriteStream(false, true, roms[index].Name.Replace('\\', '/'), istreamSize, 0, null, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, true, baseFiles[index].Filename.Replace('\\', '/'), istreamSize, 0, null, out writeStream);
}
// Copy the input stream to the output
@@ -701,7 +658,7 @@ namespace SabreTools.Library.FileTypes
}
freadStream.Dispose();
- zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(roms[index].CRC));
+ zipFile.ZipFileCloseWriteStream(baseFiles[index].CRC);
}
}
@@ -722,12 +679,12 @@ namespace SabreTools.Library.FileTypes
}
// If the old one contains the new file, then just skip out
- if (oldZipFileContents.Contains(roms[i].Name.Replace('\\', '/')))
+ if (oldZipFileContents.Contains(baseFiles[i].Filename.Replace('\\', '/')))
{
continue;
}
- inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), -(i + 1));
+ inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), -(i + 1));
}
// Then add all of the old entries to it too
@@ -764,14 +721,14 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length);
DateTime dt = DateTime.Now;
- if (UseDates && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[-index - 1].Date) && DateTime.TryParse(baseFiles[-index - 1].Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
- zipFile.ZipFileOpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, false, baseFiles[-index - 1].Filename.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
}
else
{
- zipFile.ZipFileOpenWriteStream(false, true, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, 0, null, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, true, baseFiles[-index - 1].Filename.Replace('\\', '/'), istreamSize, 0, null, out writeStream);
}
// Copy the input stream to the output
@@ -783,7 +740,7 @@ namespace SabreTools.Library.FileTypes
writeStream.Flush();
}
freadStream.Dispose();
- zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(roms[-index - 1].CRC));
+ zipFile.ZipFileCloseWriteStream(baseFiles[-index - 1].CRC);
}
// Otherwise, copy the file from the old archive
diff --git a/SabreTools.Library/FileTypes/TapeArchive.cs b/SabreTools.Library/FileTypes/TapeArchive.cs
index a4164608..dc2f3361 100644
--- a/SabreTools.Library/FileTypes/TapeArchive.cs
+++ b/SabreTools.Library/FileTypes/TapeArchive.cs
@@ -4,8 +4,6 @@ using System.IO;
using System.Linq;
using SabreTools.Data;
-using SabreTools.IO;
-using SabreTools.Library.DatItems;
using SabreTools.Library.Tools;
using Compress.ZipFile;
using SharpCompress.Archives;
@@ -17,7 +15,7 @@ using SharpCompress.Writers;
namespace SabreTools.Library.FileTypes
{
///
- /// Represents a Torrent7zip archive for reading and writing
+ /// Represents a Tape archive for reading and writing
///
/// TODO: Don't try to read entries to MemoryStream during write
public class TapeArchive : BaseArchive
@@ -25,7 +23,7 @@ namespace SabreTools.Library.FileTypes
#region Constructors
///
- /// Create a new TorrentTarArchive with no base file
+ /// Create a new Tape archive with no base file
///
public TapeArchive()
: base()
@@ -34,7 +32,7 @@ namespace SabreTools.Library.FileTypes
}
///
- /// Create a new TorrentTarArchive from the given file
+ /// Create a new Tape archive from the given file
///
/// Name of the file to use as an archive
/// True for opening file as read, false for opening file as write
@@ -49,11 +47,7 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -91,12 +85,7 @@ namespace SabreTools.Library.FileTypes
return encounteredErrors;
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
@@ -137,12 +126,7 @@ namespace SabreTools.Library.FileTypes
return realEntry;
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
@@ -176,10 +160,7 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
List found = new List();
@@ -227,11 +208,7 @@ namespace SabreTools.Library.FileTypes
return found;
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
List empties = new List();
@@ -267,9 +244,7 @@ namespace SabreTools.Library.FileTypes
return empties;
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
throw new NotImplementedException();
@@ -279,33 +254,21 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a tape archive
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile)
{
// Get the file stream for the file and write out
- return Write(File.OpenRead(inputFile), outDir, rom);
+ return Write(File.OpenRead(inputFile), outDir, baseFile);
}
- ///
- /// Write an input stream to a tape archive
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
// If either input is null or empty, return
- if (inputStream == null || rom == null || rom.Name == null)
+ if (inputStream == null || baseFile == null || baseFile.Filename == null)
return success;
// If the stream is not readable, return
@@ -313,7 +276,7 @@ namespace SabreTools.Library.FileTypes
return success;
// Get the output archive name from the first rebuild rom
- string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name) + (rom.Machine.Name.EndsWith(".tar") ? string.Empty : ".tar"));
+ string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".tar") ? string.Empty : ".tar"));
// Set internal variables
TarArchive oldTarFile = TarArchive.Create();
@@ -330,12 +293,12 @@ namespace SabreTools.Library.FileTypes
{
// Get temporary date-time if possible
DateTime? usableDate = null;
- if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out DateTime dt))
usableDate = dt;
// Copy the input stream to the output
inputStream.Seek(0, SeekOrigin.Begin);
- tarFile.AddEntry(rom.Name, inputStream, size: rom.Size ?? 0, modified: usableDate);
+ tarFile.AddEntry(baseFile.Filename, inputStream, size: baseFile.Size ?? 0, modified: usableDate);
}
// Otherwise, sort the input files and write out in the correct order
@@ -351,8 +314,8 @@ namespace SabreTools.Library.FileTypes
Dictionary inputIndexMap = new Dictionary();
// If the old one doesn't contain the new file, then add it
- if (!entries.Contains(rom.Name.Replace('\\', '/')))
- inputIndexMap.Add(rom.Name.Replace('\\', '/'), -1);
+ if (!entries.Contains(baseFile.Filename.Replace('\\', '/')))
+ inputIndexMap.Add(baseFile.Filename.Replace('\\', '/'), -1);
// Then add all of the old entries to it too
for (int i = 0; i < entries.Count; i++)
@@ -379,7 +342,7 @@ namespace SabreTools.Library.FileTypes
// Get temporary date-time if possible
DateTime? usableDate = null;
- if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out DateTime dt))
usableDate = dt;
// If we have the input file, add it now
@@ -387,7 +350,7 @@ namespace SabreTools.Library.FileTypes
{
// Copy the input file to the output
inputStream.Seek(0, SeekOrigin.Begin);
- tarFile.AddEntry(rom.Name, inputStream, size: rom.Size ?? 0, modified: usableDate);
+ tarFile.AddEntry(baseFile.Filename, inputStream, size: baseFile.Size ?? 0, modified: usableDate);
}
// Otherwise, copy the file from the old archive
@@ -429,26 +392,20 @@ namespace SabreTools.Library.FileTypes
return success;
}
- ///
- /// Write a set of input files to a tape archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFiles)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
// If either list of roms is null or empty, return
- if (inputFiles == null || roms == null || inputFiles.Count == 0 || roms.Count == 0)
+ if (inputFiles == null || baseFiles == null || inputFiles.Count == 0 || baseFiles.Count == 0)
{
return success;
}
// If the number of inputs is less than the number of available roms, return
- if (inputFiles.Count < roms.Count)
+ if (inputFiles.Count < baseFiles.Count)
{
return success;
}
@@ -463,7 +420,7 @@ namespace SabreTools.Library.FileTypes
}
// Get the output archive name from the first rebuild rom
- string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".tar") ? string.Empty : ".tar"));
+ string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".tar") ? string.Empty : ".tar"));
// Set internal variables
TarArchive oldTarFile = TarArchive.Create();
@@ -484,7 +441,7 @@ namespace SabreTools.Library.FileTypes
Dictionary inputIndexMap = new Dictionary();
for (int i = 0; i < inputFiles.Count; i++)
{
- inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), i);
+ inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), i);
}
// Sort the keys in TZIP order
@@ -499,11 +456,11 @@ namespace SabreTools.Library.FileTypes
// Get temporary date-time if possible
DateTime? usableDate = null;
- if (UseDates && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out DateTime dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[index].Date) && DateTime.TryParse(baseFiles[index].Date.Replace('\\', '/'), out DateTime dt))
usableDate = dt;
// Copy the input stream to the output
- tarFile.AddEntry(roms[index].Name, File.OpenRead(inputFiles[index]), size: roms[index].Size ?? 0, modified: usableDate);
+ tarFile.AddEntry(baseFiles[index].Filename, File.OpenRead(inputFiles[index]), size: baseFiles[index].Size ?? 0, modified: usableDate);
}
}
@@ -521,12 +478,12 @@ namespace SabreTools.Library.FileTypes
for (int i = 0; i < inputFiles.Count; i++)
{
// If the old one contains the new file, then just skip out
- if (entries.Contains(roms[i].Name.Replace('\\', '/')))
+ if (entries.Contains(baseFiles[i].Filename.Replace('\\', '/')))
{
continue;
}
- inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), -(i + 1));
+ inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), -(i + 1));
}
// Then add all of the old entries to it too
@@ -557,11 +514,11 @@ namespace SabreTools.Library.FileTypes
{
// Get temporary date-time if possible
DateTime? usableDate = null;
- if (UseDates && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out DateTime dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[-index - 1].Date) && DateTime.TryParse(baseFiles[-index - 1].Date.Replace('\\', '/'), out DateTime dt))
usableDate = dt;
// Copy the input file to the output
- tarFile.AddEntry(roms[-index - 1].Name, File.OpenRead(inputFiles[-index - 1]), size: roms[-index - 1].Size ?? 0, modified: usableDate);
+ tarFile.AddEntry(baseFiles[-index - 1].Filename, File.OpenRead(inputFiles[-index - 1]), size: baseFiles[-index - 1].Size ?? 0, modified: usableDate);
}
// Otherwise, copy the file from the old archive
diff --git a/SabreTools.Library/FileTypes/XZArchive.cs b/SabreTools.Library/FileTypes/XZArchive.cs
index 29b308aa..d24ef798 100644
--- a/SabreTools.Library/FileTypes/XZArchive.cs
+++ b/SabreTools.Library/FileTypes/XZArchive.cs
@@ -5,9 +5,6 @@ using System.Text.RegularExpressions;
using SabreTools.Data;
using SabreTools.IO;
-using SabreTools.Library.DatFiles;
-using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
using SabreTools.Library.Tools;
using SharpCompress.Compressors.Xz;
@@ -54,11 +51,7 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -98,12 +91,7 @@ namespace SabreTools.Library.FileTypes
return encounteredErrors;
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
@@ -144,12 +132,7 @@ namespace SabreTools.Library.FileTypes
return realEntry;
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
@@ -188,10 +171,7 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
if (_children == null || _children.Count == 0)
@@ -249,20 +229,14 @@ namespace SabreTools.Library.FileTypes
return _children;
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
// XZ files don't contain directories
return new List();
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
// Check for the file existing first
@@ -315,15 +289,8 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrent XZ file
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile)
{
// Check that the input file exists
if (!File.Exists(inputFile))
@@ -335,17 +302,11 @@ namespace SabreTools.Library.FileTypes
inputFile = Path.GetFullPath(inputFile);
// Get the file stream for the file and write out
- return Write(File.OpenRead(inputFile), outDir, rom);
+ return Write(File.OpenRead(inputFile), outDir, baseFile);
}
- ///
- /// Write an input file to a torrent XZ archive
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
bool success = false;
@@ -360,10 +321,10 @@ namespace SabreTools.Library.FileTypes
outDir = Path.GetFullPath(outDir);
// Now get the Rom info for the file so we have hashes and size
- rom = new Rom(GetInfo(inputStream, keepReadOpen: true));
+ baseFile = GetInfo(inputStream, keepReadOpen: true);
// Get the output file name
- string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(rom.SHA1, Depth));
+ string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(Utilities.ByteArrayToString(baseFile.SHA1), Depth));
outfile = outfile.Replace(".gz", ".xz");
// Check to see if the folder needs to be created
@@ -384,14 +345,8 @@ namespace SabreTools.Library.FileTypes
return true;
}
- ///
- /// Write a set of input files to a torrent XZ archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFiles)
{
throw new NotImplementedException();
}
diff --git a/SabreTools.Library/FileTypes/ZPAQArchive.cs b/SabreTools.Library/FileTypes/ZPAQArchive.cs
index 63b18dbc..009131d9 100644
--- a/SabreTools.Library/FileTypes/ZPAQArchive.cs
+++ b/SabreTools.Library/FileTypes/ZPAQArchive.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using SabreTools.Data;
-using SabreTools.Library.DatItems;
namespace SabreTools.Library.FileTypes
{
@@ -39,33 +38,19 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
throw new NotImplementedException();
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
throw new NotImplementedException();
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
throw new NotImplementedException();
@@ -75,28 +60,19 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
throw new NotImplementedException();
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
throw new NotImplementedException();
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
throw new NotImplementedException();
@@ -106,40 +82,20 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrent ZPAQ file
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile)
{
throw new NotImplementedException();
}
- ///
- /// Write an input stream to a torrent ZPAQ file
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
throw new NotImplementedException();
}
- ///
- /// Write a set of input files to a torrent ZPAQ archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFiles)
{
throw new NotImplementedException();
}
diff --git a/SabreTools.Library/FileTypes/ZipArchive.cs b/SabreTools.Library/FileTypes/ZipArchive.cs
index 4b654e01..002c274f 100644
--- a/SabreTools.Library/FileTypes/ZipArchive.cs
+++ b/SabreTools.Library/FileTypes/ZipArchive.cs
@@ -4,8 +4,6 @@ using System.IO;
using System.Linq;
using SabreTools.Data;
-using SabreTools.IO;
-using SabreTools.Library.DatItems;
using SabreTools.Library.Tools;
using Compress;
using Compress.ZipFile;
@@ -45,11 +43,7 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -136,12 +130,7 @@ namespace SabreTools.Library.FileTypes
return encounteredErrors;
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
@@ -182,12 +171,7 @@ namespace SabreTools.Library.FileTypes
return realEntry;
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
@@ -256,10 +240,7 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
List found = new List();
@@ -331,11 +312,7 @@ namespace SabreTools.Library.FileTypes
return found;
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
List empties = new List();
@@ -383,9 +360,7 @@ namespace SabreTools.Library.FileTypes
return empties;
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
ZipFile zf = new ZipFile();
@@ -402,33 +377,21 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrentzip archive
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile)
{
// Get the file stream for the file and write out
- return Write(File.OpenRead(inputFile), outDir, rom);
+ return Write(File.OpenRead(inputFile), outDir, baseFile);
}
- ///
- /// Write an input stream to a torrentzip archive
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
// If either input is null or empty, return
- if (inputStream == null || rom == null || rom.Name == null)
+ if (inputStream == null || baseFile == null || baseFile.Filename == null)
return success;
// If the stream is not readable, return
@@ -439,7 +402,7 @@ namespace SabreTools.Library.FileTypes
inputStream.Seek(0, SeekOrigin.Begin);
// Get the output archive name from the first rebuild rom
- string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name) + (rom.Machine.Name.EndsWith(".zip") ? string.Empty : ".zip"));
+ string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".zip") ? string.Empty : ".zip"));
// Set internal variables
Stream writeStream = null;
@@ -463,14 +426,14 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now;
- if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
- zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, false, baseFile.Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
}
else
{
- zipFile.ZipFileOpenWriteStream(false, true, rom.Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, null, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, true, baseFile.Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, null, out writeStream);
}
// Copy the input stream to the output
@@ -482,7 +445,7 @@ namespace SabreTools.Library.FileTypes
writeStream.Flush();
}
- zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(rom.CRC));
+ zipFile.ZipFileCloseWriteStream(baseFile.CRC);
}
// Otherwise, sort the input files and write out in the correct order
@@ -500,8 +463,8 @@ namespace SabreTools.Library.FileTypes
}
// If the old one doesn't contain the new file, then add it
- if (!oldZipFileContents.Contains(rom.Name.Replace('\\', '/')))
- inputIndexMap.Add(rom.Name.Replace('\\', '/'), -1);
+ if (!oldZipFileContents.Contains(baseFile.Filename.Replace('\\', '/')))
+ inputIndexMap.Add(baseFile.Filename.Replace('\\', '/'), -1);
// Then add all of the old entries to it too
for (int i = 0; i < oldZipFile.LocalFilesCount(); i++)
@@ -536,14 +499,14 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now;
- if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
- zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, false, baseFile.Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
}
else
{
- zipFile.ZipFileOpenWriteStream(false, true, rom.Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, null, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, true, baseFile.Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, null, out writeStream);
}
// Copy the input stream to the output
@@ -555,7 +518,7 @@ namespace SabreTools.Library.FileTypes
writeStream.Flush();
}
- zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(rom.CRC));
+ zipFile.ZipFileCloseWriteStream(baseFile.CRC);
}
// Otherwise, copy the file from the old archive
@@ -605,26 +568,20 @@ namespace SabreTools.Library.FileTypes
return true;
}
- ///
- /// Write a set of input files to a torrentzip archive (assuming the same output archive name)
- ///
- /// Input filenames to be moved
- /// Output directory to build to
- /// List of Rom representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFiles)
{
bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
// If either list of roms is null or empty, return
- if (inputFiles == null || roms == null || inputFiles.Count == 0 || roms.Count == 0)
+ if (inputFiles == null || baseFiles == null || inputFiles.Count == 0 || baseFiles.Count == 0)
{
return success;
}
// If the number of inputs is less than the number of available roms, return
- if (inputFiles.Count < roms.Count)
+ if (inputFiles.Count < baseFiles.Count)
{
return success;
}
@@ -639,7 +596,7 @@ namespace SabreTools.Library.FileTypes
}
// Get the output archive name from the first rebuild rom
- string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".zip") ? string.Empty : ".zip"));
+ string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".zip") ? string.Empty : ".zip"));
// Set internal variables
Stream writeStream = null;
@@ -664,7 +621,7 @@ namespace SabreTools.Library.FileTypes
Dictionary inputIndexMap = new Dictionary();
for (int i = 0; i < inputFiles.Count; i++)
{
- inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), i);
+ inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), i);
}
// Sort the keys in TZIP order
@@ -682,14 +639,14 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length);
DateTime dt = DateTime.Now;
- if (UseDates && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[index].Date) && DateTime.TryParse(baseFiles[index].Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
- zipFile.ZipFileOpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, false, baseFiles[index].Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
}
else
{
- zipFile.ZipFileOpenWriteStream(false, true, roms[index].Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, null, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, true, baseFiles[index].Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, null, out writeStream);
}
// Copy the input stream to the output
@@ -702,7 +659,7 @@ namespace SabreTools.Library.FileTypes
}
freadStream.Dispose();
- zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(roms[index].CRC));
+ zipFile.ZipFileCloseWriteStream(baseFiles[index].CRC);
}
}
@@ -723,12 +680,12 @@ namespace SabreTools.Library.FileTypes
}
// If the old one contains the new file, then just skip out
- if (oldZipFileContents.Contains(roms[i].Name.Replace('\\', '/')))
+ if (oldZipFileContents.Contains(baseFiles[i].Filename.Replace('\\', '/')))
{
continue;
}
- inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), -(i + 1));
+ inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), -(i + 1));
}
// Then add all of the old entries to it too
@@ -765,14 +722,14 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length);
DateTime dt = DateTime.Now;
- if (UseDates && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt))
+ if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[-index - 1].Date) && DateTime.TryParse(baseFiles[-index - 1].Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
- zipFile.ZipFileOpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, false, baseFiles[-index - 1].Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
}
else
{
- zipFile.ZipFileOpenWriteStream(false, true, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, null, out writeStream);
+ zipFile.ZipFileOpenWriteStream(false, true, baseFiles[-index - 1].Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, null, out writeStream);
}
// Copy the input stream to the output
@@ -784,7 +741,7 @@ namespace SabreTools.Library.FileTypes
writeStream.Flush();
}
freadStream.Dispose();
- zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(roms[-index - 1].CRC));
+ zipFile.ZipFileCloseWriteStream(baseFiles[-index - 1].CRC);
}
// Otherwise, copy the file from the old archive
diff --git a/SabreTools.Library/FileTypes/ZstdArchive.cs b/SabreTools.Library/FileTypes/ZstdArchive.cs
index 3ebd5214..0ccbddbe 100644
--- a/SabreTools.Library/FileTypes/ZstdArchive.cs
+++ b/SabreTools.Library/FileTypes/ZstdArchive.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using SabreTools.Data;
-using SabreTools.Library.DatItems;
namespace SabreTools.Library.FileTypes
{
@@ -39,33 +38,19 @@ namespace SabreTools.Library.FileTypes
#region Extraction
- ///
- /// Attempt to extract a file as an archive
- ///
- /// Output directory for archive extraction
- /// True if the extraction was a success, false otherwise
+ ///
public override bool CopyAll(string outDir)
{
throw new NotImplementedException();
}
- ///
- /// Attempt to extract a file from an archive
- ///
- /// Name of the entry to be extracted
- /// Output directory for archive extraction
- /// Name of the extracted file, null on error
+ ///
public override string CopyToFile(string entryName, string outDir)
{
throw new NotImplementedException();
}
- ///
- /// Attempt to extract a stream from an archive
- ///
- /// Name of the entry to be extracted
- /// Output representing the entry name that was found
- /// MemoryStream representing the entry, null on error
+ ///
public override (MemoryStream, string) CopyToStream(string entryName)
{
throw new NotImplementedException();
@@ -75,28 +60,19 @@ namespace SabreTools.Library.FileTypes
#region Information
- ///
- /// Generate a list of DatItem objects from the header values in an archive
- ///
- /// List of DatItem objects representing the found data
+ ///
public override List GetChildren()
{
throw new NotImplementedException();
}
- ///
- /// Generate a list of empty folders in an archive
- ///
- /// Input file to get data from
- /// List of empty folders in the archive
+ ///
public override List GetEmptyFolders()
{
throw new NotImplementedException();
}
- ///
- /// Check whether the input file is a standardized format
- ///
+ ///
public override bool IsTorrent()
{
throw new NotImplementedException();
@@ -106,40 +82,20 @@ namespace SabreTools.Library.FileTypes
#region Writing
- ///
- /// Write an input file to a torrent Zstd file
- ///
- /// Input filename to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(string inputFile, string outDir, Rom rom)
+ ///
+ public override bool Write(string inputFile, string outDir, BaseFile baseFile)
{
throw new NotImplementedException();
}
- ///
- /// Write an input stream to a torrent Zstd file
- ///
- /// Input stream to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the write was a success, false otherwise
- /// This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.
- public override bool Write(Stream inputStream, string outDir, Rom rom)
+ ///
+ public override bool Write(Stream inputStream, string outDir, BaseFile baseFile)
{
throw new NotImplementedException();
}
- ///
- /// Write a set of input files to a torrent Zstd archive (assuming the same output archive name)
- ///
- /// Input files to be moved
- /// Output directory to build to
- /// DatItem representing the new information
- /// True if the archive was written properly, false otherwise
- public override bool Write(List inputFiles, string outDir, List roms)
+ ///
+ public override bool Write(List inputFiles, string outDir, List baseFiles)
{
throw new NotImplementedException();
}
diff --git a/SabreTools.Library/Filtering/Cleaner.cs b/SabreTools.Library/Filtering/Cleaner.cs
index b2884712..cd12abb5 100644
--- a/SabreTools.Library/Filtering/Cleaner.cs
+++ b/SabreTools.Library/Filtering/Cleaner.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
-using SabreTools.Library.DatFiles;
-using SabreTools.Library.DatItems;
+using SabreTools.Data;
namespace SabreTools.Library.Filtering
{
@@ -20,7 +19,6 @@ namespace SabreTools.Library.Filtering
///
public DedupeType DedupeRoms { get; set; }
-
///
/// Set Machine Description from Machine Name
///
diff --git a/SabreTools.Library/Filtering/ExtraIniItem.cs b/SabreTools.Library/Filtering/ExtraIniItem.cs
index ee3a0208..7b9070a4 100644
--- a/SabreTools.Library/Filtering/ExtraIniItem.cs
+++ b/SabreTools.Library/Filtering/ExtraIniItem.cs
@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
+using SabreTools.Data;
using SabreTools.IO;
using SabreTools.Logging;
-using SabreTools.Library.DatItems;
-using SabreTools.Library.IO;
namespace SabreTools.Library.Filtering
{
diff --git a/SabreTools.Library/Filtering/Filter.cs b/SabreTools.Library/Filtering/Filter.cs
index ab1bba1b..26ab1ab7 100644
--- a/SabreTools.Library/Filtering/Filter.cs
+++ b/SabreTools.Library/Filtering/Filter.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
+using SabreTools.Data;
using SabreTools.Logging;
using SabreTools.Library.DatItems;
using SabreTools.Library.Tools;
diff --git a/SabreTools.Library/Reports/BaseReport.cs b/SabreTools.Library/Reports/BaseReport.cs
index 8a38a3d0..944d96d8 100644
--- a/SabreTools.Library/Reports/BaseReport.cs
+++ b/SabreTools.Library/Reports/BaseReport.cs
@@ -1,7 +1,6 @@
using System;
using System.IO;
-using SabreTools.IO;
using SabreTools.Library.DatFiles;
namespace SabreTools.Library.Reports
@@ -139,5 +138,62 @@ namespace SabreTools.Library.Reports
/// Write out the footer to the stream, if any exists
///
public abstract void WriteFooter();
+
+ ///
+ /// Returns the human-readable file size for an arbitrary, 64-bit file size
+ /// The default format is "0.### XB", e.g. "4.2 KB" or "1.434 GB"
+ ///
+ ///
+ /// Human-readable file size
+ /// http://www.somacon.com/p576.php
+ protected static string GetBytesReadable(long input)
+ {
+ // Get absolute value
+ long absolute_i = (input < 0 ? -input : input);
+
+ // Determine the suffix and readable value
+ string suffix;
+ double readable;
+ if (absolute_i >= 0x1000000000000000) // Exabyte
+ {
+ suffix = "EB";
+ readable = (input >> 50);
+ }
+ else if (absolute_i >= 0x4000000000000) // Petabyte
+ {
+ suffix = "PB";
+ readable = (input >> 40);
+ }
+ else if (absolute_i >= 0x10000000000) // Terabyte
+ {
+ suffix = "TB";
+ readable = (input >> 30);
+ }
+ else if (absolute_i >= 0x40000000) // Gigabyte
+ {
+ suffix = "GB";
+ readable = (input >> 20);
+ }
+ else if (absolute_i >= 0x100000) // Megabyte
+ {
+ suffix = "MB";
+ readable = (input >> 10);
+ }
+ else if (absolute_i >= 0x400) // Kilobyte
+ {
+ suffix = "KB";
+ readable = input;
+ }
+ else
+ {
+ return input.ToString("0 B"); // Byte
+ }
+
+ // Divide by 1024 to get fractional value
+ readable /= 1024;
+
+ // Return formatted number with suffix
+ return readable.ToString("0.### ") + suffix;
+ }
}
}
diff --git a/SabreTools.Library/Reports/Html.cs b/SabreTools.Library/Reports/Html.cs
index e31a55d6..27c61fd5 100644
--- a/SabreTools.Library/Reports/Html.cs
+++ b/SabreTools.Library/Reports/Html.cs
@@ -43,7 +43,7 @@ namespace SabreTools.Library.Reports
string line = "\t\t\t