Fix rebuild, extract depth to proper places

This commit is contained in:
Matt Nadareski
2020-09-18 15:01:03 -07:00
parent 9c671b488d
commit c533a29bd7
14 changed files with 408 additions and 415 deletions

View File

@@ -2438,9 +2438,8 @@ namespace SabreTools.Library.DatFiles
if (fileinfo == null) if (fileinfo == null)
continue; continue;
// If we have partial, just ensure we are sorted correctly // Ensure we are sorted correctly (some other calls can change this)
if (outputFormat == OutputFormat.Folder && Header.ForcePacking == PackingFlag.Partial) Items.BucketBy(Field.DatItem_SHA1, DedupeType.None);
Items.BucketBy(Field.DatItem_SHA1, DedupeType.None);
// If there are no items in the hash, we continue // If there are no items in the hash, we continue
if (Items[hash] == null || Items[hash].Count == 0) if (Items[hash] == null || Items[hash].Count == 0)
@@ -2798,9 +2797,17 @@ namespace SabreTools.Library.DatFiles
// Get the output archive, if possible // Get the output archive, if possible
Folder outputArchive = Folder.Create(outputFormat); Folder outputArchive = Folder.Create(outputFormat);
if (outputArchive is BaseArchive baseArchive && date)
baseArchive.UseDates = date;
// Set the depth fields where appropriate
if (outputArchive is GZipArchive gzipArchive)
gzipArchive.Depth = Header.OutputDepot.Depth;
else if (outputArchive is XZArchive xzArchive)
xzArchive.Depth = Header.OutputDepot.Depth;
// Now rebuild to the output file // Now rebuild to the output file
outputArchive.Write(fileStream, outDir, item as Rom, date: date, depth: Header.OutputDepot.Depth); outputArchive.Write(fileStream, outDir, item as Rom);
} }
// Close the input stream // Close the input stream
@@ -2865,10 +2872,18 @@ namespace SabreTools.Library.DatFiles
// Get the output archive, if possible // Get the output archive, if possible
Folder outputArchive = Folder.Create(outputFormat); Folder outputArchive = Folder.Create(outputFormat);
if (outputArchive is BaseArchive baseArchive && date)
baseArchive.UseDates = date;
// Set the depth fields where appropriate
if (outputArchive is GZipArchive gzipArchive)
gzipArchive.Depth = Header.OutputDepot.Depth;
else if (outputArchive is XZArchive xzArchive)
xzArchive.Depth = Header.OutputDepot.Depth;
// Now rebuild to the output file // Now rebuild to the output file
eitherSuccess |= outputArchive.Write(transformStream, outDir, item as Rom, date: date, depth: Header.OutputDepot.Depth); eitherSuccess |= outputArchive.Write(transformStream, outDir, item as Rom);
eitherSuccess |= outputArchive.Write(fileStream, outDir, datItem as Rom, date: date, depth: Header.OutputDepot.Depth); eitherSuccess |= outputArchive.Write(fileStream, outDir, datItem as Rom);
// Now add the success of either rebuild // Now add the success of either rebuild
rebuilt &= eitherSuccess; rebuilt &= eitherSuccess;

View File

@@ -39,6 +39,11 @@ namespace SabreTools.Library.DatFiles
/// </summary> /// </summary>
private ConcurrentDictionary<string, List<DatItem>> items; private ConcurrentDictionary<string, List<DatItem>> items;
/// <summary>
/// Lock for statistics calculation
/// </summary>
private object statsLock = new object();
#endregion #endregion
#region Publically available fields #region Publically available fields
@@ -149,7 +154,7 @@ namespace SabreTools.Library.DatFiles
/// <summary> /// <summary>
/// Number of Disk items /// Number of Disk items
/// </summary> /// </summary>
[JsonIgnore] [JsonIgnore, XmlIgnore]
public long DiskCount { get; private set; } = 0; public long DiskCount { get; private set; } = 0;
/// <summary> /// <summary>
@@ -515,18 +520,22 @@ namespace SabreTools.Library.DatFiles
/// <param name="key">Key in the dictionary to remove</param> /// <param name="key">Key in the dictionary to remove</param>
public bool Remove(string key) public bool Remove(string key)
{ {
// If the key doesn't exist, return // Explicit lock for some weird corner cases
if (!ContainsKey(key)) lock (key)
return false;
// Remove the statistics first
foreach (DatItem item in items[key])
{ {
RemoveItemStatistics(item); // If the key doesn't exist, return
} if (!ContainsKey(key))
return false;
// Remove the key from the dictionary // Remove the statistics first
return items.TryRemove(key, out _); foreach (DatItem item in items[key])
{
RemoveItemStatistics(item);
}
// Remove the key from the dictionary
return items.TryRemove(key, out _);
}
} }
/// <summary> /// <summary>
@@ -536,14 +545,18 @@ namespace SabreTools.Library.DatFiles
/// <param name="value">Value to remove from the dictionary</param> /// <param name="value">Value to remove from the dictionary</param>
public bool Remove(string key, DatItem value) public bool Remove(string key, DatItem value)
{ {
// If the key and value doesn't exist, return // Explicit lock for some weird corner cases
if (!Contains(key, value)) lock (key)
return false; {
// If the key and value doesn't exist, return
if (!Contains(key, value))
return false;
// Remove the statistics first // Remove the statistics first
RemoveItemStatistics(value); RemoveItemStatistics(value);
return items[key].Remove(value); return items[key].Remove(value);
}
} }
/// <summary> /// <summary>
@@ -582,139 +595,142 @@ namespace SabreTools.Library.DatFiles
/// <param name="item">Item to add info from</param> /// <param name="item">Item to add info from</param>
private void AddItemStatistics(DatItem item) private void AddItemStatistics(DatItem item)
{ {
// No matter what the item is, we increment the count lock (statsLock)
TotalCount++;
// Increment removal count
if (item.Remove)
RemovedCount++;
// Now we do different things for each item type
switch (item.ItemType)
{ {
case ItemType.Adjuster: // No matter what the item is, we increment the count
AdjusterCount++; TotalCount++;
break;
case ItemType.Analog:
AnalogCount++;
break;
case ItemType.Archive:
ArchiveCount++;
break;
case ItemType.BiosSet:
BiosSetCount++;
break;
case ItemType.Chip:
ChipCount++;
break;
case ItemType.Condition:
ConditionCount++;
break;
case ItemType.Configuration:
ConfigurationCount++;
break;
case ItemType.DataArea:
DataAreaCount++;
break;
case ItemType.Device:
DeviceCount++;
break;
case ItemType.DeviceReference:
DeviceReferenceCount++;
break;
case ItemType.DipSwitch:
DipSwitchCount++;
break;
case ItemType.Disk:
DiskCount++;
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
{
MD5Count += (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
}
BaddumpCount += ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0); // Increment removal count
GoodCount += ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0); if (item.Remove)
NodumpCount += ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0); RemovedCount++;
VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break; // Now we do different things for each item type
case ItemType.DiskArea: switch (item.ItemType)
DiskAreaCount++; {
break; case ItemType.Adjuster:
case ItemType.Display: AdjusterCount++;
DisplayCount++; break;
break; case ItemType.Analog:
case ItemType.Driver: AnalogCount++;
DriverCount++; break;
break; case ItemType.Archive:
case ItemType.Feature: ArchiveCount++;
FeatureCount++; break;
break; case ItemType.BiosSet:
case ItemType.Info: BiosSetCount++;
InfoCount++; break;
break; case ItemType.Chip:
case ItemType.Input: ChipCount++;
InputCount++; break;
break; case ItemType.Condition:
case ItemType.Media: ConditionCount++;
MediaCount++; break;
MD5Count += (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1); case ItemType.Configuration:
SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1); ConfigurationCount++;
SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1); break;
SpamSumCount += (string.IsNullOrWhiteSpace((item as Media).SpamSum) ? 0 : 1); case ItemType.DataArea:
break; DataAreaCount++;
case ItemType.Part: break;
PartCount++; case ItemType.Device:
break; DeviceCount++;
case ItemType.PartFeature: break;
PartFeatureCount++; case ItemType.DeviceReference:
break; DeviceReferenceCount++;
case ItemType.Port: break;
PortCount++; case ItemType.DipSwitch:
break; DipSwitchCount++;
case ItemType.RamOption: break;
RamOptionCount++; case ItemType.Disk:
break; DiskCount++;
case ItemType.Release: if ((item as Disk).ItemStatus != ItemStatus.Nodump)
ReleaseCount++; {
break; MD5Count += (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
case ItemType.Rom: SHA1Count += (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
RomCount++; }
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
{ BaddumpCount += ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0);
TotalSize += (item as Rom).Size ?? 0; GoodCount += ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0);
CRCCount += (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1); NodumpCount += ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
MD5Count += (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1); VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break;
case ItemType.DiskArea:
DiskAreaCount++;
break;
case ItemType.Display:
DisplayCount++;
break;
case ItemType.Driver:
DriverCount++;
break;
case ItemType.Feature:
FeatureCount++;
break;
case ItemType.Info:
InfoCount++;
break;
case ItemType.Input:
InputCount++;
break;
case ItemType.Media:
MediaCount++;
MD5Count += (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
SpamSumCount += (string.IsNullOrWhiteSpace((item as Media).SpamSum) ? 0 : 1);
break;
case ItemType.Part:
PartCount++;
break;
case ItemType.PartFeature:
PartFeatureCount++;
break;
case ItemType.Port:
PortCount++;
break;
case ItemType.RamOption:
RamOptionCount++;
break;
case ItemType.Release:
ReleaseCount++;
break;
case ItemType.Rom:
RomCount++;
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
{
TotalSize += (item as Rom).Size ?? 0;
CRCCount += (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1);
MD5Count += (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1);
#if NET_FRAMEWORK #if NET_FRAMEWORK
RIPEMD160Count += (string.IsNullOrWhiteSpace((item as Rom).RIPEMD160) ? 0 : 1); RIPEMD160Count += (string.IsNullOrWhiteSpace((item as Rom).RIPEMD160) ? 0 : 1);
#endif #endif
SHA1Count += (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1); SHA1Count += (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1);
SHA256Count += (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1); SHA256Count += (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1);
SHA384Count += (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1); SHA384Count += (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1);
SHA512Count += (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1); SHA512Count += (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1);
SpamSumCount += (string.IsNullOrWhiteSpace((item as Rom).SpamSum) ? 0 : 1); SpamSumCount += (string.IsNullOrWhiteSpace((item as Rom).SpamSum) ? 0 : 1);
} }
BaddumpCount += ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount += ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0);
GoodCount += ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0); GoodCount += ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0);
NodumpCount += ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0); NodumpCount += ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0);
VerifiedCount += ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0); VerifiedCount += ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
break; break;
case ItemType.Sample: case ItemType.Sample:
SampleCount++; SampleCount++;
break; break;
case ItemType.SharedFeature: case ItemType.SharedFeature:
SharedFeatureCount++; SharedFeatureCount++;
break; break;
case ItemType.Slot: case ItemType.Slot:
SlotCount++; SlotCount++;
break; break;
case ItemType.SoftwareList: case ItemType.SoftwareList:
SoftwareListCount++; SoftwareListCount++;
break; break;
case ItemType.Sound: case ItemType.Sound:
SoundCount++; SoundCount++;
break; break;
}
} }
} }
@@ -749,6 +765,7 @@ namespace SabreTools.Library.DatFiles
SHA256Count += stats.SHA256Count; SHA256Count += stats.SHA256Count;
SHA384Count += stats.SHA384Count; SHA384Count += stats.SHA384Count;
SHA512Count += stats.SHA512Count; SHA512Count += stats.SHA512Count;
SpamSumCount += stats.SpamSumCount;
// Individual status counts // Individual status counts
BaddumpCount += stats.BaddumpCount; BaddumpCount += stats.BaddumpCount;
@@ -779,137 +796,140 @@ namespace SabreTools.Library.DatFiles
if (item == null) if (item == null)
return; return;
// No matter what the item is, we decrease the count lock (statsLock)
TotalCount--;
// Decrement removal count
if (item.Remove)
RemovedCount--;
// Now we do different things for each item type
switch (item.ItemType)
{ {
case ItemType.Adjuster: // No matter what the item is, we decrease the count
AdjusterCount--; TotalCount--;
break;
case ItemType.Analog:
AnalogCount--;
break;
case ItemType.Archive:
ArchiveCount--;
break;
case ItemType.BiosSet:
BiosSetCount--;
break;
case ItemType.Chip:
ChipCount--;
break;
case ItemType.Condition:
ConditionCount--;
break;
case ItemType.Configuration:
ConfigurationCount--;
break;
case ItemType.DataArea:
DataAreaCount--;
break;
case ItemType.Device:
DeviceCount--;
break;
case ItemType.DeviceReference:
DeviceReferenceCount--;
break;
case ItemType.DipSwitch:
DipSwitchCount--;
break;
case ItemType.Disk:
DiskCount--;
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
{
MD5Count -= (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
}
BaddumpCount -= ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0); // Decrement removal count
GoodCount -= ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0); if (item.Remove)
NodumpCount -= ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0); RemovedCount--;
VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break; // Now we do different things for each item type
case ItemType.DiskArea: switch (item.ItemType)
DiskAreaCount--; {
break; case ItemType.Adjuster:
case ItemType.Display: AdjusterCount--;
DisplayCount--; break;
break; case ItemType.Analog:
case ItemType.Driver: AnalogCount--;
DriverCount--; break;
break; case ItemType.Archive:
case ItemType.Feature: ArchiveCount--;
FeatureCount--; break;
break; case ItemType.BiosSet:
case ItemType.Info: BiosSetCount--;
InfoCount--; break;
break; case ItemType.Chip:
case ItemType.Input: ChipCount--;
InputCount--; break;
break; case ItemType.Condition:
case ItemType.Media: ConditionCount--;
MediaCount--; break;
MD5Count -= (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1); case ItemType.Configuration:
SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1); ConfigurationCount--;
SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1); break;
break; case ItemType.DataArea:
case ItemType.Part: DataAreaCount--;
PartCount--; break;
break; case ItemType.Device:
case ItemType.PartFeature: DeviceCount--;
PartFeatureCount--; break;
break; case ItemType.DeviceReference:
case ItemType.Port: DeviceReferenceCount--;
PortCount--; break;
break; case ItemType.DipSwitch:
case ItemType.RamOption: DipSwitchCount--;
RamOptionCount--; break;
break; case ItemType.Disk:
case ItemType.Release: DiskCount--;
ReleaseCount--; if ((item as Disk).ItemStatus != ItemStatus.Nodump)
break; {
case ItemType.Rom: MD5Count -= (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
RomCount--; SHA1Count -= (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
if ((item as Rom).ItemStatus != ItemStatus.Nodump) }
{
TotalSize -= (item as Rom).Size ?? 0; BaddumpCount -= ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0);
CRCCount -= (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1); GoodCount -= ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0);
MD5Count -= (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1); NodumpCount -= ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break;
case ItemType.DiskArea:
DiskAreaCount--;
break;
case ItemType.Display:
DisplayCount--;
break;
case ItemType.Driver:
DriverCount--;
break;
case ItemType.Feature:
FeatureCount--;
break;
case ItemType.Info:
InfoCount--;
break;
case ItemType.Input:
InputCount--;
break;
case ItemType.Media:
MediaCount--;
MD5Count -= (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
break;
case ItemType.Part:
PartCount--;
break;
case ItemType.PartFeature:
PartFeatureCount--;
break;
case ItemType.Port:
PortCount--;
break;
case ItemType.RamOption:
RamOptionCount--;
break;
case ItemType.Release:
ReleaseCount--;
break;
case ItemType.Rom:
RomCount--;
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
{
TotalSize -= (item as Rom).Size ?? 0;
CRCCount -= (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1);
MD5Count -= (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1);
#if NET_FRAMEWORK #if NET_FRAMEWORK
RIPEMD160Count -= (string.IsNullOrWhiteSpace((item as Rom).RIPEMD160) ? 0 : 1); RIPEMD160Count -= (string.IsNullOrWhiteSpace((item as Rom).RIPEMD160) ? 0 : 1);
#endif #endif
SHA1Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1); SHA1Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1);
SHA256Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1); SHA256Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1);
SHA384Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1); SHA384Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1);
SHA512Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1); SHA512Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1);
} }
BaddumpCount -= ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount -= ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0);
GoodCount -= ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0); GoodCount -= ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0);
NodumpCount -= ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0); NodumpCount -= ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0);
VerifiedCount -= ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0); VerifiedCount -= ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
break; break;
case ItemType.Sample: case ItemType.Sample:
SampleCount--; SampleCount--;
break; break;
case ItemType.SharedFeature: case ItemType.SharedFeature:
SharedFeatureCount--; SharedFeatureCount--;
break; break;
case ItemType.Slot: case ItemType.Slot:
SlotCount--; SlotCount--;
break; break;
case ItemType.SoftwareList: case ItemType.SoftwareList:
SoftwareListCount--; SoftwareListCount--;
break; break;
case ItemType.Sound: case ItemType.Sound:
SoundCount--; SoundCount--;
break; break;
}
} }
} }
@@ -1226,6 +1246,7 @@ namespace SabreTools.Library.DatFiles
SHA256Count = 0; SHA256Count = 0;
SHA384Count = 0; SHA384Count = 0;
SHA512Count = 0; SHA512Count = 0;
SpamSumCount = 0;
BaddumpCount = 0; BaddumpCount = 0;
GoodCount = 0; GoodCount = 0;

View File

@@ -9,11 +9,25 @@ namespace SabreTools.Library.FileTypes
{ {
public abstract class BaseArchive : Folder public abstract class BaseArchive : Folder
{ {
#region Fields
/// <summary>
/// Determines if archives pull information from headers alone
/// </summary>
public bool QuickScan { get; set; } = false;
/// <summary>
/// Determines if dates are read or written
/// </summary>
public bool UseDates { get; set; } = false;
#endregion
#region Protected instance variables #region Protected instance variables
protected bool QuickScan { get; set; } = false; /// <summary>
/// Buffer size used by archives
// Buffer size used by archives /// </summary>
protected const int _bufferSize = 4096 * 128; protected const int _bufferSize = 4096 * 128;
#endregion #endregion
@@ -42,8 +56,9 @@ namespace SabreTools.Library.FileTypes
/// </summary> /// </summary>
/// <param name="input">Name of the file to create the archive from</param> /// <param name="input">Name of the file to create the archive from</param>
/// <param name="quickScan">True to use archive header values, false otherwise</param> /// <param name="quickScan">True to use archive header values, false otherwise</param>
/// <param name="useDates">True to use dates for read and write, false otherwise</param>
/// <returns>Archive object representing the inputs</returns> /// <returns>Archive object representing the inputs</returns>
public static BaseArchive Create(string input, bool quickScan = false) public static BaseArchive Create(string input, bool quickScan = false, bool useDates = false)
{ {
BaseArchive archive = null; BaseArchive archive = null;
@@ -178,10 +193,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override abstract bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4); public override abstract bool Write(string inputFile, string outDir, Rom rom);
/// <summary> /// <summary>
/// Write an input stream to an archive /// Write an input stream to an archive
@@ -189,10 +202,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override abstract bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4); public override abstract bool Write(Stream inputStream, string outDir, Rom rom);
/// <summary> /// <summary>
/// Write a set of input files to an archive (assuming the same output archive name) /// Write a set of input files to an archive (assuming the same output archive name)
@@ -200,10 +211,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override abstract bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false); public override abstract bool Write(List<string> inputFiles, string outDir, List<Rom> roms);
#endregion #endregion
} }

View File

@@ -298,14 +298,12 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public virtual bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public virtual bool Write(string inputFile, string outDir, Rom rom)
{ {
FileStream fs = FileExtensions.TryOpenRead(inputFile); FileStream fs = FileExtensions.TryOpenRead(inputFile);
return Write(fs, outDir, rom, date, depth); return Write(fs, outDir, rom);
} }
/// <summary> /// <summary>
@@ -314,11 +312,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public virtual bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public virtual bool Write(Stream inputStream, string outDir, Rom rom)
{ {
bool success = false; bool success = false;
@@ -367,8 +363,8 @@ namespace SabreTools.Library.FileTypes
if (rom.ItemType == ItemType.Rom) if (rom.ItemType == ItemType.Rom)
{ {
if (date && !string.IsNullOrWhiteSpace((rom as Rom).Date)) if (!string.IsNullOrWhiteSpace(rom.Date))
File.SetCreationTime(fileName, DateTime.Parse((rom as Rom).Date)); File.SetCreationTime(fileName, DateTime.Parse(rom.Date));
} }
success = true; success = true;
@@ -393,10 +389,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public virtual bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public virtual bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -19,6 +19,15 @@ namespace SabreTools.Library.FileTypes
/// </summary> /// </summary>
public class GZipArchive : BaseArchive public class GZipArchive : BaseArchive
{ {
#region Fields
/// <summary>
/// Positive value for depth of the output depot, defaults to 4
/// </summary>
public int Depth { get; set; } = 4;
#endregion
#region Constructors #region Constructors
/// <summary> /// <summary>
@@ -408,11 +417,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom = null, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom = null)
{ {
// Check that the input file exists // Check that the input file exists
if (!File.Exists(inputFile)) if (!File.Exists(inputFile))
@@ -424,7 +431,7 @@ namespace SabreTools.Library.FileTypes
inputFile = Path.GetFullPath(inputFile); inputFile = Path.GetFullPath(inputFile);
// Get the file stream for the file and write out // Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date, depth); return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom);
} }
/// <summary> /// <summary>
@@ -433,11 +440,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom = null, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom = null)
{ {
bool success = false; bool success = false;
@@ -455,7 +460,7 @@ namespace SabreTools.Library.FileTypes
rom = new Rom(inputStream.GetInfo(keepReadOpen: true)); rom = new Rom(inputStream.GetInfo(keepReadOpen: true));
// Get the output file name // Get the output file name
string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(rom.SHA1, depth)); string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(rom.SHA1, Depth));
// Check to see if the folder needs to be created // Check to see if the folder needs to be created
if (!Directory.Exists(Path.GetDirectoryName(outfile))) if (!Directory.Exists(Path.GetDirectoryName(outfile)))
@@ -510,10 +515,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -111,11 +111,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -126,11 +124,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -141,10 +137,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -111,11 +111,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -126,11 +124,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -141,10 +137,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -281,13 +281,11 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
// Get the file stream for the file and write out // Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date, depth); return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom);
} }
/// <summary> /// <summary>
@@ -296,10 +294,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -310,10 +306,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -411,13 +411,11 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
// Get the file stream for the file and write out // Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date: date); return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom);
} }
/// <summary> /// <summary>
@@ -426,10 +424,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
bool success = false; bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}"); string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
@@ -470,7 +466,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length); ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt)) if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream); zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
@@ -545,7 +541,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length); ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt)) if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream); zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
@@ -619,10 +615,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
bool success = false; bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}"); string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
@@ -692,7 +686,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length); ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt)) if (UseDates && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.ZipFileOpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream); zipFile.ZipFileOpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);
@@ -775,7 +769,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length); ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt)) if (UseDates && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.ZipFileOpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream); zipFile.ZipFileOpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, 0, msDosDateTime, out writeStream);

View File

@@ -286,13 +286,11 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
// Get the file stream for the file and write out // Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date: date); return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom);
} }
/// <summary> /// <summary>
@@ -301,10 +299,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
bool success = false; bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}"); string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
@@ -335,7 +331,7 @@ namespace SabreTools.Library.FileTypes
{ {
// Get temporary date-time if possible // Get temporary date-time if possible
DateTime? usableDate = null; DateTime? usableDate = null;
if (date && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt)) if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
usableDate = dt; usableDate = dt;
// Copy the input stream to the output // Copy the input stream to the output
@@ -384,7 +380,7 @@ namespace SabreTools.Library.FileTypes
// Get temporary date-time if possible // Get temporary date-time if possible
DateTime? usableDate = null; DateTime? usableDate = null;
if (date && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt)) if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
usableDate = dt; usableDate = dt;
// If we have the input file, add it now // If we have the input file, add it now
@@ -440,10 +436,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
bool success = false; bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}"); string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
@@ -506,10 +500,8 @@ namespace SabreTools.Library.FileTypes
// Get temporary date-time if possible // Get temporary date-time if possible
DateTime? usableDate = null; DateTime? usableDate = null;
if (date && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out DateTime dt)) if (UseDates && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out DateTime dt))
{
usableDate = dt; usableDate = dt;
}
// Copy the input stream to the output // Copy the input stream to the output
tarFile.AddEntry(roms[index].Name, FileExtensions.TryOpenRead(inputFiles[index]), size: roms[index].Size ?? 0, modified: usableDate); tarFile.AddEntry(roms[index].Name, FileExtensions.TryOpenRead(inputFiles[index]), size: roms[index].Size ?? 0, modified: usableDate);
@@ -566,10 +558,8 @@ namespace SabreTools.Library.FileTypes
{ {
// Get temporary date-time if possible // Get temporary date-time if possible
DateTime? usableDate = null; DateTime? usableDate = null;
if (date && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out DateTime dt)) if (UseDates && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out DateTime dt))
{
usableDate = dt; usableDate = dt;
}
// Copy the input file to the output // Copy the input file to the output
tarFile.AddEntry(roms[-index - 1].Name, FileExtensions.TryOpenRead(inputFiles[-index - 1]), size: roms[-index - 1].Size ?? 0, modified: usableDate); tarFile.AddEntry(roms[-index - 1].Name, FileExtensions.TryOpenRead(inputFiles[-index - 1]), size: roms[-index - 1].Size ?? 0, modified: usableDate);

View File

@@ -16,6 +16,15 @@ namespace SabreTools.Library.FileTypes
/// </summary> /// </summary>
public class XZArchive : BaseArchive public class XZArchive : BaseArchive
{ {
#region Fields
/// <summary>
/// Positive value for depth of the output depot, defaults to 4
/// </summary>
public int Depth { get; set; } = 4;
#endregion
#region Constructors #region Constructors
/// <summary> /// <summary>
@@ -309,11 +318,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
// Check that the input file exists // Check that the input file exists
if (!File.Exists(inputFile)) if (!File.Exists(inputFile))
@@ -325,7 +332,7 @@ namespace SabreTools.Library.FileTypes
inputFile = Path.GetFullPath(inputFile); inputFile = Path.GetFullPath(inputFile);
// Get the file stream for the file and write out // Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date, depth); return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom);
} }
/// <summary> /// <summary>
@@ -334,10 +341,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
bool success = false; bool success = false;
@@ -355,7 +360,7 @@ namespace SabreTools.Library.FileTypes
rom = new Rom(inputStream.GetInfo(keepReadOpen: true)); rom = new Rom(inputStream.GetInfo(keepReadOpen: true));
// Get the output file name // Get the output file name
string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(rom.SHA1, depth)); string outfile = Path.Combine(outDir, PathExtensions.GetDepotPath(rom.SHA1, Depth));
outfile = outfile.Replace(".gz", ".xz"); outfile = outfile.Replace(".gz", ".xz");
// Check to see if the folder needs to be created // Check to see if the folder needs to be created
@@ -382,10 +387,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -111,11 +111,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -126,11 +124,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -141,10 +137,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -416,13 +416,11 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
// Get the file stream for the file and write out // Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom, date: date); return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom);
} }
/// <summary> /// <summary>
@@ -431,10 +429,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input filename to be moved</param> /// <param name="inputStream">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
bool success = false; bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}"); string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
@@ -475,7 +471,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length); ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt)) if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream); zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
@@ -548,7 +544,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length); ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt)) if (UseDates && !string.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream); zipFile.ZipFileOpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
@@ -623,10 +619,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filenames to be moved</param> /// <param name="inputFile">Input filenames to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">List of Rom representing the new information</param> /// <param name="rom">List of Rom 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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
bool success = false; bool success = false;
string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}"); string tempFile = Path.Combine(outDir, $"tmp{Guid.NewGuid()}");
@@ -696,7 +690,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length); ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt)) if (UseDates && !string.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.ZipFileOpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream); zipFile.ZipFileOpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);
@@ -779,7 +773,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length); ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt)) if (UseDates && !string.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.ZipFileOpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream); zipFile.ZipFileOpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, msDosDateTime, out writeStream);

View File

@@ -111,11 +111,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFile">Input filename to be moved</param> /// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(string inputFile, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -126,11 +124,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputStream">Input stream to be moved</param> /// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="depth">Positive value for depth of the output depot, defaults to 4</param>
/// <returns>True if the write was a success, false otherwise</returns> /// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks> /// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public override bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, int depth = 4) public override bool Write(Stream inputStream, string outDir, Rom rom)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -141,10 +137,8 @@ namespace SabreTools.Library.FileTypes
/// <param name="inputFiles">Input files to be moved</param> /// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param> /// <param name="outDir">Output directory to build to</param>
/// <param name="rom">DatItem representing the new information</param> /// <param name="rom">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="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns> /// <returns>True if the archive was written properly, false otherwise</returns>
public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false) public override bool Write(List<string> inputFiles, string outDir, List<Rom> roms)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }