diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 98d07aa0..b6db17c3 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -2369,9 +2369,12 @@ namespace SabreTools.Library.DatFiles outputFormat = OutputFormat.TorrentZip; break; case PackingFlag.Unzip: + case PackingFlag.Partial: outputFormat = OutputFormat.Folder; break; - // TODO: Check what output format would be for Partial and Flat + case PackingFlag.Flat: + outputFormat = OutputFormat.ParentFolder; + break; } } @@ -2388,6 +2391,7 @@ namespace SabreTools.Library.DatFiles switch (outputFormat) { case OutputFormat.Folder: + case OutputFormat.ParentFolder: format = "directory"; break; case OutputFormat.TapeArchive: @@ -2559,9 +2563,12 @@ namespace SabreTools.Library.DatFiles outputFormat = OutputFormat.TorrentZip; break; case PackingFlag.Unzip: + case PackingFlag.Partial: outputFormat = OutputFormat.Folder; break; - // TODO: Check what output format would be for Partial and Flat + case PackingFlag.Flat: + outputFormat = OutputFormat.ParentFolder; + break; } } @@ -2578,6 +2585,7 @@ namespace SabreTools.Library.DatFiles switch (outputFormat) { case OutputFormat.Folder: + case OutputFormat.ParentFolder: format = "directory"; break; case OutputFormat.TapeArchive: @@ -2855,7 +2863,7 @@ namespace SabreTools.Library.DatFiles } // Get a generic stream for the file - Stream fileStream = new MemoryStream(); + Stream fileStream = null; // If we have a zipfile, extract the stream to memory if (isZip != null) diff --git a/SabreTools.Library/FileTypes/Enums.cs b/SabreTools.Library/FileTypes/Enums.cs index 764f63c2..512d3f41 100644 --- a/SabreTools.Library/FileTypes/Enums.cs +++ b/SabreTools.Library/FileTypes/Enums.cs @@ -1283,6 +1283,7 @@ namespace SabreTools.Library.FileTypes { // Currently implemented Folder, + ParentFolder, TorrentZip, TorrentGzip, TorrentGzipRomba, diff --git a/SabreTools.Library/FileTypes/Folder.cs b/SabreTools.Library/FileTypes/Folder.cs index e6bd975d..cd7651b0 100644 --- a/SabreTools.Library/FileTypes/Folder.cs +++ b/SabreTools.Library/FileTypes/Folder.cs @@ -19,6 +19,11 @@ namespace SabreTools.Library.FileTypes #region Protected instance variables protected List _children; + + /// + /// Flag specific to Folder to omit Machine name from output path + /// + private bool writeToParent = false; #endregion @@ -27,10 +32,12 @@ namespace SabreTools.Library.FileTypes /// /// Create a new folder with no base file /// - public Folder() + /// True to write directly to parent, false otherwise + public Folder(bool writeToParent = false) : base() { this.Type = FileType.Folder; + this.writeToParent = writeToParent; } /// @@ -55,7 +62,10 @@ namespace SabreTools.Library.FileTypes switch (outputFormat) { case OutputFormat.Folder: - return new Folder(); + return new Folder(false); + + case OutputFormat.ParentFolder: + return new Folder(true); case OutputFormat.TapeArchive: return new TapeArchive(); @@ -332,7 +342,11 @@ namespace SabreTools.Library.FileTypes FileStream outputStream = null; // Get the output folder name from the first rebuild rom - string fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name), Sanitizer.RemovePathUnsafeCharacters(rom.Name)); + string fileName; + if (writeToParent) + fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Name)); + else + fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(rom.Machine.Name), Sanitizer.RemovePathUnsafeCharacters(rom.Name)); try {