From 8994cf6f4c8acb54e5b68dfa0e33a38305a3d3fc Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 17 May 2016 16:53:02 -0700 Subject: [PATCH] More SuperDAT improvments --- DATFromDir/DATFromDir.cs | 30 +++++++++++++++++------------- SabreHelper/RomManipulation.cs | 11 ++++++++--- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/DATFromDir/DATFromDir.cs b/DATFromDir/DATFromDir.cs index 3158c9d2..c5dbcdac 100644 --- a/DATFromDir/DATFromDir.cs +++ b/DATFromDir/DATFromDir.cs @@ -221,8 +221,6 @@ namespace SabreTools foreach (string path in _inputs) { // Set local paths and vars - _tempDir = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "temp" + DateTime.Now.ToString("yyyyMMddHHmmss") + Path.DirectorySeparatorChar; - _basePath = (File.Exists(path) ? path : path + Path.DirectorySeparatorChar); _basePath = Path.GetFullPath(_basePath); @@ -245,9 +243,13 @@ namespace SabreTools string basePathBackup = _basePath; foreach (string item in Directory.EnumerateDirectories(_basePath)) { - _basePath = (File.Exists(item) ? item : item + Path.DirectorySeparatorChar); - _basePath = Path.GetFullPath(_basePath); - + // If we're not in SuperDAT mode, then reset the base path + if (!_superDat) + { + _basePath = (File.Exists(item) ? item : item + Path.DirectorySeparatorChar); + _basePath = Path.GetFullPath(_basePath); + } + foreach (string subitem in Directory.EnumerateFiles(_basePath, "*", SearchOption.AllDirectories)) { ProcessFile(subitem); @@ -334,9 +336,9 @@ namespace SabreTools /// Filename of the item to be checked private void ProcessFile(string item) { - // Create the temporary output directory - DirectoryInfo di = Directory.CreateDirectory(_tempDir); + Console.WriteLine("basepath: " + _basePath); + // Create the temporary output directory bool encounteredErrors = true; if (!_archivesAsFiles) { @@ -348,6 +350,8 @@ namespace SabreTools if (at == ArchiveType.Zip || at == ArchiveType.SevenZip || at == ArchiveType.Rar) { + _tempDir = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "temp" + DateTime.Now.ToString("yyyyMMddHHmmss") + Path.DirectorySeparatorChar; + DirectoryInfo di = Directory.CreateDirectory(_tempDir); IReader reader = archive.ExtractAllEntries(); reader.WriteAllToDirectory(_tempDir, ExtractOptions.ExtractFullPath); encounteredErrors = false; @@ -435,6 +439,12 @@ namespace SabreTools _logger.User("File added: " + entry + Environment.NewLine); } + + // Delete the temp directory + if (Directory.Exists(_tempDir)) + { + Directory.Delete(_tempDir, true); + } } // Otherwise, just get the info on the file itself else if (!Directory.Exists(item) && File.Exists(item)) @@ -516,12 +526,6 @@ namespace SabreTools _logger.Error(ex.ToString()); } } - - // Delete the temp directory - if (Directory.Exists(_tempDir)) - { - di.Delete(true); - } } } } diff --git a/SabreHelper/RomManipulation.cs b/SabreHelper/RomManipulation.cs index d746c39b..1a6b6e91 100644 --- a/SabreHelper/RomManipulation.cs +++ b/SabreHelper/RomManipulation.cs @@ -142,9 +142,9 @@ namespace SabreTools.Helper switch (headreader.Name) { case "name": - string readname = headreader.ReadElementContentAsString(); ; - datdata.Name = (datdata.Name == "" ? readname : ""); - superdat = superdat || readname.Contains(" - SuperDAT"); + content = headreader.ReadElementContentAsString(); ; + datdata.Name = (datdata.Name == "" ? content : datdata.Name); + superdat = superdat || content.Contains(" - SuperDAT"); break; case "description": content = headreader.ReadElementContentAsString(); @@ -182,6 +182,11 @@ namespace SabreTools.Helper content = headreader.ReadElementContentAsString(); datdata.Comment = (datdata.Comment == "" ? content : datdata.Comment); break; + case "type": + content = headreader.ReadElementContentAsString(); + datdata.Type = (datdata.Type == "" ? content : datdata.Type); + superdat = superdat || content.Contains("SuperDAT"); + break; case "clrmamepro": if (headreader.GetAttribute("forcemerging") != null) {