Fix Sort multiple outputs

This commit is contained in:
Matt Nadareski
2020-08-28 21:38:27 -07:00
parent e76d19033f
commit 5fb140f406
7 changed files with 9 additions and 73 deletions

View File

@@ -443,15 +443,11 @@ namespace SabreTools.Library.FileTypes
// If either input is null or empty, return
if (inputStream == null || rom == null || rom.Name == null)
{
return success;
}
// If the stream is not readable, return
if (!inputStream.CanRead)
{
return success;
}
// Seek to the beginning of the stream
inputStream.Seek(0, SeekOrigin.Begin);
@@ -469,9 +465,7 @@ namespace SabreTools.Library.FileTypes
{
// If the full output path doesn't exist, create it
if (!Directory.Exists(Path.GetDirectoryName(archiveFileName)))
{
Directory.CreateDirectory(Path.GetDirectoryName(archiveFileName));
}
// If the archive doesn't exist, create it and put the single file
if (!File.Exists(archiveFileName))
@@ -501,7 +495,7 @@ namespace SabreTools.Library.FileTypes
writeStream.Write(ibuffer, 0, ilen);
writeStream.Flush();
}
inputStream.Dispose();
zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(rom.CRC));
}
@@ -521,9 +515,7 @@ 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);
}
// Then add all of the old entries to it too
for (int i = 0; i < oldZipFile.LocalFilesCount(); i++)
@@ -577,7 +569,6 @@ namespace SabreTools.Library.FileTypes
writeStream.Flush();
}
inputStream.Dispose();
zipFile.ZipFileCloseWriteStream(Utilities.StringToByteArray(rom.CRC));
}
@@ -617,14 +608,12 @@ namespace SabreTools.Library.FileTypes
}
finally
{
inputStream?.Dispose();
}
// If the old file exists, delete it and replace
if (File.Exists(archiveFileName))
{
FileExtensions.TryDelete(archiveFileName);
}
File.Move(tempFile, archiveFileName);
return true;