2017-11-02 00:29:20 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
using System.IO;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
using System.Text.RegularExpressions;
|
2024-03-04 23:56:05 -05:00
|
|
|
|
using SabreTools.Hashing;
|
2024-07-19 15:47:47 -04:00
|
|
|
|
using SabreTools.IO.Extensions;
|
2024-10-24 00:46:28 -04:00
|
|
|
|
#if NET462_OR_GREATER || NETCOREAPP
|
2020-07-15 09:41:59 -07:00
|
|
|
|
using SharpCompress.Compressors.Xz;
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#endif
|
2017-11-02 00:29:20 -07:00
|
|
|
|
|
2020-12-10 22:31:23 -08:00
|
|
|
|
namespace SabreTools.FileTypes.Archives
|
2017-11-02 00:29:20 -07:00
|
|
|
|
{
|
2019-02-08 20:51:44 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents a TorrentXZ archive for reading and writing
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class XZArchive : BaseArchive
|
|
|
|
|
|
{
|
2020-12-09 14:45:11 -08:00
|
|
|
|
/* (Torrent)XZ Header Format
|
|
|
|
|
|
https://tukaani.org/xz/xz-file-format.txt
|
|
|
|
|
|
|
|
|
|
|
|
00-05 Identification (0xFD, '7', 'z', 'X', 'Z', 0x00) XzSignature
|
|
|
|
|
|
06 Flags (0x01 - CRC32, 0x04 - CRC64, 0x0A - SHA-256)
|
|
|
|
|
|
07-0A Flags CRC32 (uint, little-endian)
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2020-09-18 15:01:03 -07:00
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Positive value for depth of the output depot, defaults to 4
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int Depth { get; set; } = 4;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2019-02-08 20:51:44 -08:00
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a new TorrentGZipArchive with no base file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public XZArchive()
|
|
|
|
|
|
: base()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a new TorrentGZipArchive from the given file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filename">Name of the file to use as an archive</param>
|
|
|
|
|
|
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
|
|
|
|
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
|
|
|
|
|
public XZArchive(string filename, bool getHashes = false)
|
|
|
|
|
|
: base(filename, getHashes)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Extraction
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2019-02-08 20:51:44 -08:00
|
|
|
|
public override bool CopyAll(string outDir)
|
|
|
|
|
|
{
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#if NET462_OR_GREATER || NETCOREAPP
|
2019-02-08 20:51:44 -08:00
|
|
|
|
bool encounteredErrors = true;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// Create the temp directory
|
|
|
|
|
|
Directory.CreateDirectory(outDir);
|
|
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Decompress the _filename stream
|
2024-02-28 19:19:50 -05:00
|
|
|
|
FileStream outstream = File.Create(Path.Combine(outDir, Path.GetFileNameWithoutExtension(this.Filename)!));
|
|
|
|
|
|
var xz = new XZStream(File.OpenRead(this.Filename!));
|
2020-07-15 09:41:59 -07:00
|
|
|
|
xz.CopyTo(outstream);
|
|
|
|
|
|
|
|
|
|
|
|
// Dispose of the streams
|
|
|
|
|
|
outstream.Dispose();
|
|
|
|
|
|
xz.Dispose();
|
|
|
|
|
|
|
2019-02-08 20:51:44 -08:00
|
|
|
|
encounteredErrors = false;
|
|
|
|
|
|
}
|
2020-09-15 12:12:13 -07:00
|
|
|
|
catch (EndOfStreamException ex)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
|
|
|
|
|
// Catch this but don't count it as an error because SharpCompress is unsafe
|
2020-10-07 15:42:30 -07:00
|
|
|
|
logger.Verbose(ex);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
2020-09-15 12:12:13 -07:00
|
|
|
|
catch (InvalidOperationException ex)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
2020-10-07 15:42:30 -07:00
|
|
|
|
logger.Warning(ex);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
encounteredErrors = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2020-10-07 15:42:30 -07:00
|
|
|
|
logger.Error(ex);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
encounteredErrors = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return encounteredErrors;
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#else
|
|
|
|
|
|
// TODO: Support XZ archives in old .NET
|
|
|
|
|
|
return true;
|
|
|
|
|
|
#endif
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public override string? CopyToFile(string entryName, string outDir)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
|
|
|
|
|
// Try to extract a stream using the given information
|
2024-07-17 14:46:14 -04:00
|
|
|
|
(Stream? stream, string? realEntry) = GetEntryStream(entryName);
|
2024-07-17 15:19:15 -04:00
|
|
|
|
if (stream == null || realEntry == null)
|
|
|
|
|
|
return null;
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2024-07-15 21:34:17 -04:00
|
|
|
|
// If the stream and the entry name are both non-null, we write to file
|
2024-07-17 15:19:15 -04:00
|
|
|
|
realEntry = Path.Combine(outDir, realEntry);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2024-07-17 15:19:15 -04:00
|
|
|
|
// Create the output subfolder now
|
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(realEntry)!);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2024-07-17 15:19:15 -04:00
|
|
|
|
// Now open and write the file if possible
|
|
|
|
|
|
FileStream fs = File.Create(realEntry);
|
|
|
|
|
|
if (fs != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (stream.CanSeek)
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
|
|
|
|
|
|
byte[] zbuffer = new byte[_bufferSize];
|
|
|
|
|
|
int zlen;
|
|
|
|
|
|
while ((zlen = stream.Read(zbuffer, 0, _bufferSize)) > 0)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
2024-07-17 15:19:15 -04:00
|
|
|
|
fs.Write(zbuffer, 0, zlen);
|
|
|
|
|
|
fs.Flush();
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
2024-07-17 15:19:15 -04:00
|
|
|
|
|
|
|
|
|
|
stream?.Dispose();
|
|
|
|
|
|
fs?.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
stream?.Dispose();
|
|
|
|
|
|
fs?.Dispose();
|
|
|
|
|
|
realEntry = null;
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return realEntry;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-07-15 21:37:38 -04:00
|
|
|
|
public override (Stream?, string?) GetEntryStream(string entryName)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#if NET462_OR_GREATER || NETCOREAPP
|
2024-07-16 14:58:04 -04:00
|
|
|
|
// If we have an invalid file
|
|
|
|
|
|
if (this.Filename == null)
|
|
|
|
|
|
return (null, null);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2024-07-16 14:58:04 -04:00
|
|
|
|
// Open the entry stream
|
|
|
|
|
|
string realEntry = Path.GetFileNameWithoutExtension(this.Filename);
|
|
|
|
|
|
var stream = new XZStream(File.OpenRead(this.Filename));
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2024-07-16 14:58:04 -04:00
|
|
|
|
// Return the stream
|
|
|
|
|
|
return (stream, realEntry);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2020-10-07 15:42:30 -07:00
|
|
|
|
logger.Error(ex);
|
2024-07-16 14:58:04 -04:00
|
|
|
|
return (null, null);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#else
|
|
|
|
|
|
// TODO: Support XZ archives in old .NET
|
|
|
|
|
|
return (null, null);
|
|
|
|
|
|
#endif
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Information
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public override List<BaseFile>? GetChildren()
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
2024-07-17 15:19:15 -04:00
|
|
|
|
// If we have children cached already
|
|
|
|
|
|
if (_children != null && _children.Count > 0)
|
|
|
|
|
|
return _children;
|
|
|
|
|
|
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#if NET462_OR_GREATER || NETCOREAPP
|
2024-07-17 15:19:15 -04:00
|
|
|
|
_children = [];
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2024-07-17 15:19:15 -04:00
|
|
|
|
string? gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
|
|
|
|
|
BaseFile? possibleTxz = GetTorrentXZFileInfo();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2024-07-17 15:19:15 -04:00
|
|
|
|
// If it was, then add it to the outputs and continue
|
|
|
|
|
|
if (possibleTxz != null && possibleTxz.Filename != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_children.Add(possibleTxz);
|
|
|
|
|
|
return _children;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// Create a blank item for the entry
|
|
|
|
|
|
BaseFile xzEntryRom = new();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2024-07-17 15:19:15 -04:00
|
|
|
|
// Perform a quickscan, if flagged to
|
|
|
|
|
|
if (this.AvailableHashTypes.Length == 1 && this.AvailableHashTypes[0] == HashType.CRC32)
|
2020-07-15 09:41:59 -07:00
|
|
|
|
{
|
2024-07-17 15:19:15 -04:00
|
|
|
|
xzEntryRom.Filename = gamename;
|
|
|
|
|
|
|
|
|
|
|
|
using BinaryReader br = new(File.OpenRead(this.Filename!));
|
|
|
|
|
|
br.BaseStream.Seek(-8, SeekOrigin.End);
|
|
|
|
|
|
xzEntryRom.CRC = br.ReadBytesBigEndian(4);
|
|
|
|
|
|
xzEntryRom.Size = br.ReadInt32BigEndian();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
}
|
2024-07-17 15:19:15 -04:00
|
|
|
|
// Otherwise, use the stream directly
|
2020-07-15 09:41:59 -07:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-07-17 15:19:15 -04:00
|
|
|
|
var xzStream = new XZStream(File.OpenRead(this.Filename!));
|
|
|
|
|
|
xzEntryRom = GetInfo(xzStream, hashes: this.AvailableHashTypes);
|
|
|
|
|
|
xzEntryRom.Filename = gamename;
|
|
|
|
|
|
xzStream.Dispose();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
}
|
2024-07-17 15:19:15 -04:00
|
|
|
|
|
2024-07-19 15:14:30 -04:00
|
|
|
|
// Fill in common details and add to the list
|
2024-07-17 15:19:15 -04:00
|
|
|
|
xzEntryRom.Parent = gamename;
|
|
|
|
|
|
_children.Add(xzEntryRom);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
logger.Error(ex);
|
|
|
|
|
|
return null;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return _children;
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#else
|
|
|
|
|
|
// TODO: Support XZ archives in old .NET
|
|
|
|
|
|
return [];
|
|
|
|
|
|
#endif
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2019-02-08 20:51:44 -08:00
|
|
|
|
public override List<string> GetEmptyFolders()
|
|
|
|
|
|
{
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// XZ files don't contain directories
|
2024-02-28 19:19:50 -05:00
|
|
|
|
return [];
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2019-02-08 20:51:44 -08:00
|
|
|
|
public override bool IsTorrent()
|
|
|
|
|
|
{
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Check for the file existing first
|
2024-04-24 16:08:17 -04:00
|
|
|
|
if (this.Filename == null || !File.Exists(this.Filename))
|
2020-07-15 09:41:59 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
string datum = Path.GetFileName(this.Filename).ToLowerInvariant();
|
|
|
|
|
|
|
|
|
|
|
|
// Check if the name is the right length
|
2020-08-31 23:01:51 -07:00
|
|
|
|
if (!Regex.IsMatch(datum, @"^[0-9a-f]{" + Constants.SHA1Length + @"}\.xz"))
|
2020-07-15 09:41:59 -07:00
|
|
|
|
{
|
2020-10-07 15:42:30 -07:00
|
|
|
|
logger.Warning($"Non SHA-1 filename found, skipping: '{Path.GetFullPath(this.Filename)}'");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Retrieve file information for a single torrent XZ file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>Populated DatItem object if success, empty one on error</returns>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public BaseFile? GetTorrentXZFileInfo()
|
2020-07-15 09:41:59 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Check for the file existing first
|
2024-04-24 16:08:17 -04:00
|
|
|
|
if (this.Filename == null || !File.Exists(this.Filename))
|
2020-07-15 09:41:59 -07:00
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
string datum = Path.GetFileName(this.Filename).ToLowerInvariant();
|
|
|
|
|
|
|
|
|
|
|
|
// Check if the name is the right length
|
2020-08-31 23:01:51 -07:00
|
|
|
|
if (!Regex.IsMatch(datum, @"^[0-9a-f]{" + Constants.SHA1Length + @"}\.xz"))
|
2020-07-15 09:41:59 -07:00
|
|
|
|
{
|
2020-10-07 15:42:30 -07:00
|
|
|
|
logger.Warning($"Non SHA-1 filename found, skipping: '{Path.GetFullPath(this.Filename)}'");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
BaseFile baseFile = new()
|
2020-07-15 09:41:59 -07:00
|
|
|
|
{
|
|
|
|
|
|
Filename = Path.GetFileNameWithoutExtension(this.Filename).ToLowerInvariant(),
|
2024-12-06 13:20:36 -05:00
|
|
|
|
SHA1 = Path.GetFileNameWithoutExtension(this.Filename).FromHexString(),
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
Parent = Path.GetFileNameWithoutExtension(this.Filename).ToLowerInvariant(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return baseFile;
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Writing
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public override bool Write(string inputFile, string outDir, BaseFile? baseFile)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Check that the input file exists
|
|
|
|
|
|
if (!File.Exists(inputFile))
|
|
|
|
|
|
{
|
2020-10-07 15:42:30 -07:00
|
|
|
|
logger.Warning($"File '{inputFile}' does not exist!");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inputFile = Path.GetFullPath(inputFile);
|
|
|
|
|
|
|
2019-02-08 20:51:44 -08:00
|
|
|
|
// Get the file stream for the file and write out
|
2020-12-08 11:09:05 -08:00
|
|
|
|
return Write(File.OpenRead(inputFile), outDir, baseFile);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public override bool Write(Stream? inputStream, string outDir, BaseFile? baseFile)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#if NET462_OR_GREATER || NETCOREAPP
|
2019-02-08 20:51:44 -08:00
|
|
|
|
bool success = false;
|
|
|
|
|
|
|
|
|
|
|
|
// If the stream is not readable, return
|
2024-02-28 19:19:50 -05:00
|
|
|
|
if (inputStream == null || !inputStream.CanRead)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
return success;
|
|
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Make sure the output directory exists
|
|
|
|
|
|
if (!Directory.Exists(outDir))
|
|
|
|
|
|
Directory.CreateDirectory(outDir);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
outDir = Path.GetFullPath(outDir);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Now get the Rom info for the file so we have hashes and size
|
2020-12-08 11:09:05 -08:00
|
|
|
|
baseFile = GetInfo(inputStream, keepReadOpen: true);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Get the output file name
|
2024-10-30 13:39:35 -04:00
|
|
|
|
string outfile = Path.Combine(outDir, Core.Tools.Utilities.GetDepotPath(baseFile.SHA1, Depth)!);
|
2020-08-18 23:39:13 -07:00
|
|
|
|
outfile = outfile.Replace(".gz", ".xz");
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2020-08-18 23:39:13 -07:00
|
|
|
|
// Check to see if the folder needs to be created
|
|
|
|
|
|
if (!Directory.Exists(Path.GetDirectoryName(outfile)))
|
2024-02-28 19:19:50 -05:00
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(outfile)!);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// If the output file exists, don't try to write again
|
|
|
|
|
|
if (!File.Exists(outfile))
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Compress the input stream
|
2023-04-19 16:39:58 -04:00
|
|
|
|
XZStream outputStream = new(File.Create(outfile));
|
2020-07-15 09:41:59 -07:00
|
|
|
|
inputStream.CopyTo(outputStream);
|
2019-02-08 20:51:44 -08:00
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Dispose of everything
|
|
|
|
|
|
outputStream.Dispose();
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
2024-02-28 21:59:13 -05:00
|
|
|
|
#else
|
|
|
|
|
|
// TODO: Support XZ archives in old .NET
|
|
|
|
|
|
return false;
|
|
|
|
|
|
#endif
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-08 11:09:05 -08:00
|
|
|
|
/// <inheritdoc/>
|
2024-02-28 19:19:50 -05:00
|
|
|
|
public override bool Write(List<string> inputFiles, string outDir, List<BaseFile>? baseFiles)
|
2019-02-08 20:51:44 -08:00
|
|
|
|
{
|
2020-07-15 09:41:59 -07:00
|
|
|
|
throw new NotImplementedException();
|
2019-02-08 20:51:44 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
2017-11-02 00:29:20 -07:00
|
|
|
|
}
|