mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Perform mass cleanup
This is cleanup based on both new .NET functionality (in 6 and 7) as well as a ton of simplifications and things that were missed that were caught due to the cleanup.
This commit is contained in:
@@ -162,7 +162,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override (MemoryStream, string) CopyToStream(string entryName)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
MemoryStream ms = new();
|
||||
string realEntry;
|
||||
|
||||
try
|
||||
@@ -221,14 +221,14 @@ namespace SabreTools.FileTypes.Archives
|
||||
try
|
||||
{
|
||||
// Create a blank item for the entry
|
||||
BaseFile gzipEntryRom = new BaseFile();
|
||||
BaseFile gzipEntryRom = new();
|
||||
|
||||
// Perform a quickscan, if flagged to
|
||||
if (this.AvailableHashes == Hash.CRC)
|
||||
{
|
||||
gzipEntryRom.Filename = gamename;
|
||||
|
||||
using BinaryReader br = new BinaryReader(File.OpenRead(this.Filename));
|
||||
using BinaryReader br = new(File.OpenRead(this.Filename));
|
||||
br.BaseStream.Seek(-8, SeekOrigin.End);
|
||||
gzipEntryRom.CRC = br.ReadBytesBigEndian(4);
|
||||
gzipEntryRom.Size = br.ReadInt32BigEndian();
|
||||
@@ -300,7 +300,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
}
|
||||
|
||||
// Get the Romba-specific header data
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(this.Filename));
|
||||
BinaryReader br = new(File.OpenRead(this.Filename));
|
||||
byte[] header = br.ReadBytes(12); // Get preamble header for checking
|
||||
br.ReadBytes(16); // headermd5
|
||||
br.ReadBytes(4); // headercrc
|
||||
@@ -365,7 +365,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
byte[] headermd5; // MD5
|
||||
byte[] headercrc; // CRC
|
||||
ulong headersz; // Int64 size
|
||||
BinaryReader br = new BinaryReader(File.OpenRead(this.Filename));
|
||||
BinaryReader br = new(File.OpenRead(this.Filename));
|
||||
header = br.ReadBytes(12);
|
||||
headermd5 = br.ReadBytes(16);
|
||||
headercrc = br.ReadBytes(4);
|
||||
@@ -391,7 +391,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
// Now convert the data and get the right position
|
||||
long extractedsize = (long)headersz;
|
||||
|
||||
BaseFile baseFile = new BaseFile
|
||||
BaseFile baseFile = new()
|
||||
{
|
||||
Filename = Path.GetFileNameWithoutExtension(this.Filename).ToLowerInvariant(),
|
||||
Size = extractedsize,
|
||||
@@ -457,7 +457,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
FileStream outputStream = File.Create(outfile);
|
||||
|
||||
// Open the output file for writing
|
||||
BinaryWriter sw = new BinaryWriter(outputStream);
|
||||
BinaryWriter sw = new(outputStream);
|
||||
|
||||
// Write standard header and TGZ info
|
||||
byte[] data = TorrentGZHeader
|
||||
@@ -468,7 +468,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
sw.Write((ulong)(baseFile.Size ?? 0)); // Long size (Unsigned, Mirrored)
|
||||
|
||||
// Now create a deflatestream from the input file
|
||||
ZlibBaseStream ds = new ZlibBaseStream(outputStream, CompressionMode.Compress, CompressionLevel.BestCompression, ZlibStreamFlavor.DEFLATE, true);
|
||||
ZlibBaseStream ds = new(outputStream, CompressionMode.Compress, CompressionLevel.BestCompression, ZlibStreamFlavor.DEFLATE, true);
|
||||
|
||||
// Copy the input stream to the output
|
||||
byte[] ibuffer = new byte[_bufferSize];
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override (MemoryStream, string) CopyToStream(string entryName)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
MemoryStream ms = new();
|
||||
string realEntry = null;
|
||||
|
||||
try
|
||||
@@ -158,7 +158,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override List<BaseFile> GetChildren()
|
||||
{
|
||||
List<BaseFile> found = new List<BaseFile>();
|
||||
List<BaseFile> found = new();
|
||||
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
||||
|
||||
try
|
||||
@@ -167,7 +167,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
foreach (RarArchiveEntry entry in ra.Entries.Where(e => e != null && !e.IsDirectory))
|
||||
{
|
||||
// Create a blank item for the entry
|
||||
BaseFile rarEntryRom = new BaseFile();
|
||||
BaseFile rarEntryRom = new();
|
||||
|
||||
// Perform a quickscan, if flagged to
|
||||
if (this.AvailableHashes == Hash.CRC)
|
||||
@@ -204,7 +204,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetEmptyFolders()
|
||||
{
|
||||
List<string> empties = new List<string>();
|
||||
List<string> empties = new();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
Directory.CreateDirectory(outDir);
|
||||
|
||||
// Extract all files to the temp directory
|
||||
SevenZ zf = new SevenZ();
|
||||
SevenZ zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
@@ -189,12 +189,12 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override (MemoryStream, string) CopyToStream(string entryName)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
MemoryStream ms = new();
|
||||
string realEntry = null;
|
||||
|
||||
try
|
||||
{
|
||||
SevenZ zf = new SevenZ();
|
||||
SevenZ zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
@@ -258,12 +258,12 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override List<BaseFile> GetChildren()
|
||||
{
|
||||
List<BaseFile> found = new List<BaseFile>();
|
||||
List<BaseFile> found = new();
|
||||
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
||||
|
||||
try
|
||||
{
|
||||
SevenZ zf = new SevenZ();
|
||||
SevenZ zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
@@ -293,7 +293,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
}
|
||||
|
||||
// Create a blank item for the entry
|
||||
BaseFile zipEntryRom = new BaseFile();
|
||||
BaseFile zipEntryRom = new();
|
||||
|
||||
// Perform a quickscan, if flagged to
|
||||
if (this.AvailableHashes == Hash.CRC)
|
||||
@@ -329,18 +329,18 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetEmptyFolders()
|
||||
{
|
||||
List<string> empties = new List<string>();
|
||||
List<string> empties = new();
|
||||
|
||||
try
|
||||
{
|
||||
SevenZ zf = new SevenZ();
|
||||
SevenZ zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
throw new Exception(ZipUtils.ZipErrorMessageText(zr));
|
||||
}
|
||||
|
||||
List<(string, bool)> zipEntries = new List<(string, bool)>();
|
||||
List<(string, bool)> zipEntries = new();
|
||||
for (int i = 0; i < zf.LocalFilesCount(); i++)
|
||||
{
|
||||
zipEntries.Add((zf.Filename(i), zf.IsDirectory(i)));
|
||||
@@ -377,7 +377,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override bool IsTorrent()
|
||||
{
|
||||
SevenZ zf = new SevenZ();
|
||||
SevenZ zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
@@ -420,8 +420,8 @@ namespace SabreTools.FileTypes.Archives
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
SevenZ oldZipFile = new SevenZ();
|
||||
SevenZ zipFile = new SevenZ();
|
||||
SevenZ oldZipFile = new();
|
||||
SevenZ zipFile = new();
|
||||
ZipReturn zipReturn = ZipReturn.ZipGood;
|
||||
|
||||
try
|
||||
@@ -443,7 +443,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out dt))
|
||||
{
|
||||
long msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, false, baseFile.Filename.Replace('\\', '/'), istreamSize, 0, out writeStream, ts);
|
||||
}
|
||||
else
|
||||
@@ -470,7 +470,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
oldZipFile.ZipFileOpen(archiveFileName, -1, true);
|
||||
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
var oldZipFileContents = new List<string>();
|
||||
for (int i = 0; i < oldZipFile.LocalFilesCount(); i++)
|
||||
{
|
||||
@@ -519,7 +519,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out dt))
|
||||
{
|
||||
long msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, false, baseFile.Filename.Replace('\\', '/'), istreamSize, 0, out writeStream, ts);
|
||||
}
|
||||
else
|
||||
@@ -617,8 +617,8 @@ namespace SabreTools.FileTypes.Archives
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
SevenZ oldZipFile = new SevenZ();
|
||||
SevenZ zipFile = new SevenZ();
|
||||
SevenZ oldZipFile = new();
|
||||
SevenZ zipFile = new();
|
||||
ZipReturn zipReturn = ZipReturn.ZipGood;
|
||||
|
||||
try
|
||||
@@ -635,7 +635,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
zipReturn = zipFile.ZipFileCreate(tempFile);
|
||||
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
for (int i = 0; i < inputFiles.Count; i++)
|
||||
{
|
||||
inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), i);
|
||||
@@ -659,7 +659,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[index].Date) && DateTime.TryParse(baseFiles[index].Date.Replace('\\', '/'), out dt))
|
||||
{
|
||||
long msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, false, baseFiles[index].Filename.Replace('\\', '/'), istreamSize, 0, out writeStream, ts);
|
||||
}
|
||||
else
|
||||
@@ -688,7 +688,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
oldZipFile.ZipFileOpen(archiveFileName, -1, true);
|
||||
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
for (int i = 0; i < inputFiles.Count; i++)
|
||||
{
|
||||
var oldZipFileContents = new List<string>();
|
||||
@@ -743,7 +743,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[-index - 1].Date) && DateTime.TryParse(baseFiles[-index - 1].Date.Replace('\\', '/'), out dt))
|
||||
{
|
||||
long msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, false, baseFiles[-index - 1].Filename.Replace('\\', '/'), istreamSize, 0, out writeStream, ts);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override (MemoryStream, string) CopyToStream(string entryName)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
MemoryStream ms = new();
|
||||
string realEntry = null;
|
||||
|
||||
try
|
||||
@@ -163,7 +163,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override List<BaseFile> GetChildren()
|
||||
{
|
||||
List<BaseFile> found = new List<BaseFile>();
|
||||
List<BaseFile> found = new();
|
||||
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
||||
|
||||
try
|
||||
@@ -172,7 +172,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
foreach (TarArchiveEntry entry in ta.Entries.Where(e => e != null && !e.IsDirectory))
|
||||
{
|
||||
// Create a blank item for the entry
|
||||
BaseFile tarEntryRom = new BaseFile();
|
||||
BaseFile tarEntryRom = new();
|
||||
|
||||
// Perform a quickscan, if flagged to
|
||||
if (this.AvailableHashes == Hash.CRC)
|
||||
@@ -209,7 +209,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetEmptyFolders()
|
||||
{
|
||||
List<string> empties = new List<string>();
|
||||
List<string> empties = new();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -309,7 +309,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
List<string> entries = oldTarFile.Entries.Select(i => i.Key).ToList();
|
||||
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
|
||||
// If the old one doesn't contain the new file, then add it
|
||||
if (!entries.Contains(baseFile.Filename.Replace('\\', '/')))
|
||||
@@ -356,7 +356,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
{
|
||||
// Get the stream from the original archive
|
||||
TarArchiveEntry tae = oldTarFile.Entries.ElementAt(index);
|
||||
MemoryStream entry = new MemoryStream();
|
||||
MemoryStream entry = new();
|
||||
tae.OpenEntryStream().CopyTo(entry);
|
||||
|
||||
// Copy the input stream to the output
|
||||
@@ -436,7 +436,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (!File.Exists(archiveFileName))
|
||||
{
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
for (int i = 0; i < inputFiles.Count; i++)
|
||||
{
|
||||
inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), i);
|
||||
@@ -472,7 +472,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
List<string> entries = oldTarFile.Entries.Select(i => i.Key).ToList();
|
||||
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
for (int i = 0; i < inputFiles.Count; i++)
|
||||
{
|
||||
// If the old one contains the new file, then just skip out
|
||||
@@ -524,7 +524,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
{
|
||||
// Get the stream from the original archive
|
||||
TarArchiveEntry tae = oldTarFile.Entries.ElementAt(index);
|
||||
MemoryStream entry = new MemoryStream();
|
||||
MemoryStream entry = new();
|
||||
tae.OpenEntryStream().CopyTo(entry);
|
||||
|
||||
// Copy the input stream to the output
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override (MemoryStream, string) CopyToStream(string entryName)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
MemoryStream ms = new();
|
||||
string realEntry;
|
||||
|
||||
try
|
||||
@@ -205,14 +205,14 @@ namespace SabreTools.FileTypes.Archives
|
||||
try
|
||||
{
|
||||
// Create a blank item for the entry
|
||||
BaseFile xzEntryRom = new BaseFile();
|
||||
BaseFile xzEntryRom = new();
|
||||
|
||||
// Perform a quickscan, if flagged to
|
||||
if (this.AvailableHashes == Hash.CRC)
|
||||
{
|
||||
xzEntryRom.Filename = gamename;
|
||||
|
||||
using BinaryReader br = new BinaryReader(File.OpenRead(this.Filename));
|
||||
using BinaryReader br = new(File.OpenRead(this.Filename));
|
||||
br.BaseStream.Seek(-8, SeekOrigin.End);
|
||||
xzEntryRom.CRC = br.ReadBytesBigEndian(4);
|
||||
xzEntryRom.Size = br.ReadInt32BigEndian();
|
||||
@@ -286,7 +286,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
return null;
|
||||
}
|
||||
|
||||
BaseFile baseFile = new BaseFile
|
||||
BaseFile baseFile = new()
|
||||
{
|
||||
Filename = Path.GetFileNameWithoutExtension(this.Filename).ToLowerInvariant(),
|
||||
SHA1 = Utilities.StringToByteArray(Path.GetFileNameWithoutExtension(this.Filename)),
|
||||
@@ -347,7 +347,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (!File.Exists(outfile))
|
||||
{
|
||||
// Compress the input stream
|
||||
XZStream outputStream = new XZStream(File.Create(outfile));
|
||||
XZStream outputStream = new(File.Create(outfile));
|
||||
inputStream.CopyTo(outputStream);
|
||||
|
||||
// Dispose of everything
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
Directory.CreateDirectory(outDir);
|
||||
|
||||
// Extract all files to the temp directory
|
||||
Zip zf = new Zip();
|
||||
Zip zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
@@ -200,12 +200,12 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override (MemoryStream, string) CopyToStream(string entryName)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
MemoryStream ms = new();
|
||||
string realEntry = null;
|
||||
|
||||
try
|
||||
{
|
||||
Zip zf = new Zip();
|
||||
Zip zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
@@ -269,12 +269,12 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override List<BaseFile> GetChildren()
|
||||
{
|
||||
List<BaseFile> found = new List<BaseFile>();
|
||||
List<BaseFile> found = new();
|
||||
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
||||
|
||||
try
|
||||
{
|
||||
Zip zf = new Zip();
|
||||
Zip zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
@@ -304,7 +304,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
}
|
||||
|
||||
// Create a blank item for the entry
|
||||
BaseFile zipEntryRom = new BaseFile();
|
||||
BaseFile zipEntryRom = new();
|
||||
|
||||
// Perform a quickscan, if flagged to
|
||||
if (this.AvailableHashes == Hash.CRC)
|
||||
@@ -341,18 +341,18 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetEmptyFolders()
|
||||
{
|
||||
List<string> empties = new List<string>();
|
||||
List<string> empties = new();
|
||||
|
||||
try
|
||||
{
|
||||
Zip zf = new Zip();
|
||||
Zip zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
throw new Exception(ZipUtils.ZipErrorMessageText(zr));
|
||||
}
|
||||
|
||||
List<(string, bool)> zipEntries = new List<(string, bool)>();
|
||||
List<(string, bool)> zipEntries = new();
|
||||
for (int i = 0; i < zf.LocalFilesCount(); i++)
|
||||
{
|
||||
zipEntries.Add((zf.Filename(i), zf.IsDirectory(i)));
|
||||
@@ -389,7 +389,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
/// <inheritdoc/>
|
||||
public override bool IsTorrent()
|
||||
{
|
||||
Zip zf = new Zip();
|
||||
Zip zf = new();
|
||||
ZipReturn zr = zf.ZipFileOpen(this.Filename, -1, true);
|
||||
if (zr != ZipReturn.ZipGood)
|
||||
{
|
||||
@@ -432,8 +432,8 @@ namespace SabreTools.FileTypes.Archives
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
Zip oldZipFile = new Zip();
|
||||
Zip zipFile = new Zip();
|
||||
Zip oldZipFile = new();
|
||||
Zip zipFile = new();
|
||||
ZipReturn zipReturn = ZipReturn.ZipGood;
|
||||
|
||||
try
|
||||
@@ -455,7 +455,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out dt))
|
||||
{
|
||||
long msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, false, baseFile.Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, out writeStream, ts);
|
||||
}
|
||||
else
|
||||
@@ -482,7 +482,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
oldZipFile.ZipFileOpen(archiveFileName, -1, true);
|
||||
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
var oldZipFileContents = new List<string>();
|
||||
for (int i = 0; i < oldZipFile.LocalFilesCount(); i++)
|
||||
{
|
||||
@@ -529,7 +529,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (UseDates && !string.IsNullOrWhiteSpace(baseFile.Date) && DateTime.TryParse(baseFile.Date.Replace('\\', '/'), out dt))
|
||||
{
|
||||
long msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, false, baseFile.Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, out writeStream, ts);
|
||||
}
|
||||
else
|
||||
@@ -555,7 +555,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
// Instantiate the streams
|
||||
oldZipFile.ZipFileOpenReadStream(index, false, out Stream zreadStream, out ulong istreamSize, out ushort icompressionMethod);
|
||||
long msDosDateTime = oldZipFile.LastModified(index);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, true, oldZipFile.Filename(index), istreamSize, (ushort)CompressionMethod.Deflated, out writeStream, ts);
|
||||
|
||||
// Copy the input stream to the output
|
||||
@@ -629,8 +629,8 @@ namespace SabreTools.FileTypes.Archives
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
Zip oldZipFile = new Zip();
|
||||
Zip zipFile = new Zip();
|
||||
Zip oldZipFile = new();
|
||||
Zip zipFile = new();
|
||||
ZipReturn zipReturn = ZipReturn.ZipGood;
|
||||
|
||||
try
|
||||
@@ -647,7 +647,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
zipReturn = zipFile.ZipFileCreate(tempFile);
|
||||
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
for (int i = 0; i < inputFiles.Count; i++)
|
||||
{
|
||||
inputIndexMap.Add(baseFiles[i].Filename.Replace('\\', '/'), i);
|
||||
@@ -671,7 +671,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[index].Date) && DateTime.TryParse(baseFiles[index].Date.Replace('\\', '/'), out dt))
|
||||
{
|
||||
long msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, false, baseFiles[index].Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, out writeStream, ts);
|
||||
}
|
||||
else
|
||||
@@ -700,7 +700,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
oldZipFile.ZipFileOpen(archiveFileName, -1, true);
|
||||
|
||||
// Map all inputs to index
|
||||
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
|
||||
Dictionary<string, int> inputIndexMap = new();
|
||||
for (int i = 0; i < inputFiles.Count; i++)
|
||||
{
|
||||
var oldZipFileContents = new List<string>();
|
||||
@@ -755,7 +755,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
if (UseDates && !string.IsNullOrWhiteSpace(baseFiles[-index - 1].Date) && DateTime.TryParse(baseFiles[-index - 1].Date.Replace('\\', '/'), out dt))
|
||||
{
|
||||
long msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, false, baseFiles[-index - 1].Filename.Replace('\\', '/'), istreamSize, (ushort)CompressionMethod.Deflated, out writeStream, ts);
|
||||
}
|
||||
else
|
||||
@@ -781,7 +781,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
// Instantiate the streams
|
||||
oldZipFile.ZipFileOpenReadStream(index, false, out Stream zreadStream, out ulong istreamSize, out ushort icompressionMethod);
|
||||
long msDosDateTime = oldZipFile.LastModified(index);
|
||||
TimeStamps ts = new TimeStamps { ModTime = msDosDateTime };
|
||||
TimeStamps ts = new() { ModTime = msDosDateTime };
|
||||
zipFile.ZipFileOpenWriteStream(false, true, oldZipFile.Filename(index), istreamSize, (ushort)CompressionMethod.Deflated, out writeStream, ts);
|
||||
|
||||
// Copy the input stream to the output
|
||||
|
||||
Reference in New Issue
Block a user