[DatFile, ArchiveTools] Fix sort using CHDs

This commit is contained in:
Matt Nadareski
2017-10-31 11:02:49 -07:00
parent 5aabaedfb0
commit a4bde9c0db
2 changed files with 20 additions and 17 deletions

View File

@@ -4389,7 +4389,7 @@ namespace SabreTools.Library.DatFiles
rebuilt = true;
// Now loop through the list and rebuild accordingly
foreach (Rom item in dupes)
foreach (DatItem item in dupes)
{
switch (outputFormat)
{
@@ -4397,10 +4397,10 @@ namespace SabreTools.Library.DatFiles
rebuilt &= ArchiveTools.WriteFile(fileStream, outDir, item, date: date, overwrite: true);
break;
case OutputFormat.TapeArchive:
rebuilt &= ArchiveTools.WriteTAR(fileStream, outDir, item, date: date);
rebuilt &= ArchiveTools.WriteTAR(fileStream, outDir, (Rom)item, date: date);
break;
case OutputFormat.Torrent7Zip:
rebuilt &= ArchiveTools.WriteTorrent7Zip(fileStream, outDir, item, date: date);
rebuilt &= ArchiveTools.WriteTorrent7Zip(fileStream, outDir, (Rom)item, date: date);
break;
case OutputFormat.TorrentGzip:
rebuilt &= ArchiveTools.WriteTorrentGZ(fileStream, outDir, romba);
@@ -4410,10 +4410,10 @@ namespace SabreTools.Library.DatFiles
case OutputFormat.TorrentRar:
break;
case OutputFormat.TorrentXZ:
rebuilt &= ArchiveTools.WriteTorrentXZ(fileStream, outDir, item, date: date);
rebuilt &= ArchiveTools.WriteTorrentXZ(fileStream, outDir, (Rom)item, date: date);
break;
case OutputFormat.TorrentZip:
rebuilt &= ArchiveTools.WriteTorrentZip(fileStream, outDir, item, date: date);
rebuilt &= ArchiveTools.WriteTorrentZip(fileStream, outDir, (Rom)item, date: date);
break;
}
}
@@ -4611,7 +4611,7 @@ namespace SabreTools.Library.DatFiles
rebuilt = true;
// Now loop through the list and rebuild accordingly
foreach (Rom item in dupes)
foreach (DatItem item in dupes)
{
// Create a headered item to use as well
datItem.CopyMachineInformation(item);
@@ -4623,14 +4623,14 @@ namespace SabreTools.Library.DatFiles
{
case OutputFormat.Folder:
eitherSuccess |= ArchiveTools.WriteFile(transformStream, outDir, item, date: date, overwrite: true);
eitherSuccess |= ArchiveTools.WriteFile(fileStream, outDir, (Rom)datItem, date: date, overwrite: true);
eitherSuccess |= ArchiveTools.WriteFile(fileStream, outDir, datItem, date: date, overwrite: true);
break;
case OutputFormat.TapeArchive:
eitherSuccess |= ArchiveTools.WriteTAR(transformStream, outDir, item, date: date);
eitherSuccess |= ArchiveTools.WriteTAR(transformStream, outDir, (Rom)item, date: date);
eitherSuccess |= ArchiveTools.WriteTAR(fileStream, outDir, (Rom)datItem, date: date);
break;
case OutputFormat.Torrent7Zip:
eitherSuccess |= ArchiveTools.WriteTorrent7Zip(transformStream, outDir, item, date: date);
eitherSuccess |= ArchiveTools.WriteTorrent7Zip(transformStream, outDir, (Rom)item, date: date);
eitherSuccess |= ArchiveTools.WriteTorrent7Zip(fileStream, outDir, (Rom)datItem, date: date);
break;
case OutputFormat.TorrentGzip:
@@ -4642,11 +4642,11 @@ namespace SabreTools.Library.DatFiles
case OutputFormat.TorrentRar:
break;
case OutputFormat.TorrentXZ:
eitherSuccess |= ArchiveTools.WriteTorrentXZ(transformStream, outDir, item, date: date);
eitherSuccess |= ArchiveTools.WriteTorrentXZ(transformStream, outDir, (Rom)item, date: date);
eitherSuccess |= ArchiveTools.WriteTorrentXZ(fileStream, outDir, (Rom)datItem, date: date);
break;
case OutputFormat.TorrentZip:
eitherSuccess |= ArchiveTools.WriteTorrentZip(transformStream, outDir, item, date: date);
eitherSuccess |= ArchiveTools.WriteTorrentZip(transformStream, outDir, (Rom)item, date: date);
eitherSuccess |= ArchiveTools.WriteTorrentZip(fileStream, outDir, (Rom)datItem, date: date);
break;
}

View File

@@ -1369,16 +1369,16 @@ namespace SabreTools.Library.Tools
/// </summary>
/// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param>
/// <param name="datItem">DatItem representing the new information</param>
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="overwrite">True if we should overwrite the file if it exists, false otherwise</param>
/// <returns>True if the file was written properly, false otherwise</returns>
public static bool WriteFile(Stream inputStream, string outDir, Rom rom, bool date = false, bool overwrite = false)
public static bool WriteFile(Stream inputStream, string outDir, DatItem datItem, bool date = false, bool overwrite = false)
{
bool success = false;
// If either input is null or empty, return
if (inputStream == null || rom == null || rom.Name == null)
if (inputStream == null || datItem == null || datItem.Name == null)
{
return success;
}
@@ -1393,7 +1393,7 @@ namespace SabreTools.Library.Tools
FileStream outputStream = null;
// Get the output folder name from the first rebuild rom
string fileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(rom.MachineName), Style.RemovePathUnsafeCharacters(rom.Name));
string fileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(datItem.MachineName), Style.RemovePathUnsafeCharacters(datItem.Name));
try
{
@@ -1424,9 +1424,12 @@ namespace SabreTools.Library.Tools
}
outputStream.Dispose();
if (date && !String.IsNullOrEmpty(rom.Date))
if (datItem.Type == ItemType.Rom)
{
File.SetCreationTime(fileName, DateTime.Parse(rom.Date));
if (date && !String.IsNullOrEmpty(((Rom)datItem).Date))
{
File.SetCreationTime(fileName, DateTime.Parse(((Rom)datItem).Date));
}
}
success = true;