diff --git a/SabreTools.Helper/Tools/ArchiveTools.cs b/SabreTools.Helper/Tools/ArchiveTools.cs index 71014a98..34d5320f 100644 --- a/SabreTools.Helper/Tools/ArchiveTools.cs +++ b/SabreTools.Helper/Tools/ArchiveTools.cs @@ -50,31 +50,75 @@ namespace SabreTools.Helper.Tools /// Transfer a single file from one archive to another /// /// Input archive name + /// Input archive type /// Input entry name /// Output directory + /// Output archive type /// Output Rom information /// True if dates are preserved, false otherwise (default) /// True if the transfer was a success, false otherwise - public static bool Transfer(string inputArchive, string inputEntry, string outputDir, Rom outputEntry, bool date = false) + public static bool Transfer(string inputArchive, ArchiveType? inputType, string inputEntry, string outputDir, + ArchiveType? outputType, Rom outputEntry, bool date = false) { - // Verify inputs - // Create list versions - // return Transfer(multiple) - return false; + List inputEntries = new List() { inputEntry }; + List outputEntries = new List() { outputEntry }; + return Transfer(inputArchive, inputType, inputEntries, outputDir, outputType, outputEntries, date: date); } /// /// Transfer multiple files from one archive to another /// - /// Input archive names + /// Input archive name + /// Input archive type /// Input entry names /// Output directory + /// Output archive type /// Output Rom informations /// True if dates are preserved, false otherwise (default) /// True if the transfesr were a success, false otherwise - public static bool Transfer(List inputArchives, List inputEntries, string outputDir, List outputEntries, bool date = false) + public static bool Transfer(string inputArchive, ArchiveType? inputType, List inputEntries, string outputDir, + ArchiveType? outputType, List outputEntries, bool date = false) { - // Verify inputs + #region Verify inputs + + // If the input archive doesn't exist, return false + if (!File.Exists(inputArchive)) + { + return false; + } + + // If any input entry is blank, return false + foreach (string inputEntry in inputEntries) + { + if (String.IsNullOrEmpty(inputEntry)) + { + return false; + } + } + + // If any output entry is null or blank, return false + foreach (Rom outputEntry in outputEntries) + { + if (outputEntry == null || outputEntry.Name == null) + { + return false; + } + } + + // If the output directory is null, set the default + if (String.IsNullOrEmpty(outputDir)) + { + outputDir = "out"; + } + + // Verify that the output directory exists + if (!Directory.Exists(outputDir)) + { + Directory.CreateDirectory(outputDir); + } + + #endregion + // For each item, extract to stream, write to archive return false; }