mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 11:14:23 +00:00
Update Hashing to 1.4.2
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
|
||||
@@ -24,12 +24,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.1" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.2" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.5.8" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.1" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.2" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.6.2" />
|
||||
<PackageReference Include="SabreTools.Matching" Version="1.5.1" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.5.8" />
|
||||
|
||||
@@ -37,11 +37,11 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.1" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.2" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.6.2" />
|
||||
<PackageReference Include="SabreTools.Matching" Version="1.5.1" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.5.8" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.8.4" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.8.6" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
|
||||
@@ -12,7 +12,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
var gz = new gZip();
|
||||
ZipReturn ret = gz.ZipFileOpen(Filename);
|
||||
ret = gz.ZipFileOpenReadStream(0, out Stream? gzstream, out ulong streamSize);
|
||||
gzipEntryRom = FileTypeTool.GetInfo(gzstream, (long)streamSize, _hashTypes);
|
||||
gzipEntryRom = FileTypeTool.GetInfo(gzstream, _hashTypes);
|
||||
gzipEntryRom.Filename = gz.GetLocalFile(0).Filename;
|
||||
gzipEntryRom.Parent = gamename;
|
||||
gzipEntryRom.Date = (gz.TimeStamp > 0 ? gz.TimeStamp.ToString() : null);
|
||||
@@ -438,7 +438,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
outDir = Path.GetFullPath(outDir);
|
||||
|
||||
// If the base file is null, get the hash information
|
||||
baseFile ??= FileTypeTool.GetInfo(stream, -1, _hashTypes, keepReadOpen: true);
|
||||
baseFile ??= FileTypeTool.GetInfo(stream, _hashTypes, keepReadOpen: true);
|
||||
|
||||
// Get the output file name
|
||||
string outfile = Path.Combine(outDir, Utilities.GetDepotPath(baseFile.SHA1, Depth) ?? string.Empty);
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
else
|
||||
{
|
||||
using Stream entryStream = entry.OpenEntryStream();
|
||||
rarEntryRom = FileTypeTool.GetInfo(entryStream, entry.Size, _hashTypes);
|
||||
rarEntryRom = FileTypeTool.GetInfo(entryStream, _hashTypes);
|
||||
}
|
||||
|
||||
// Fill in common details and add to the list
|
||||
|
||||
@@ -283,7 +283,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
else
|
||||
{
|
||||
zipEntryRom = FileTypeTool.GetInfo(readStream,
|
||||
(long)zf.GetLocalFile(i).UncompressedSize,
|
||||
_hashTypes,
|
||||
keepReadOpen: true);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
else
|
||||
{
|
||||
using Stream entryStream = entry.OpenEntryStream();
|
||||
tarEntryRom = FileTypeTool.GetInfo(entryStream, entry.Size, _hashTypes);
|
||||
tarEntryRom = FileTypeTool.GetInfo(entryStream, _hashTypes);
|
||||
}
|
||||
|
||||
// Fill in common details and add to the list
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
else
|
||||
{
|
||||
var xzStream = new XZStream(File.Open(Filename!, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
|
||||
xzEntryRom = FileTypeTool.GetInfo(xzStream, size: -1, _hashTypes);
|
||||
xzEntryRom = FileTypeTool.GetInfo(xzStream, _hashTypes);
|
||||
xzEntryRom.Filename = gamename;
|
||||
xzStream.Dispose();
|
||||
}
|
||||
@@ -332,7 +332,7 @@ namespace SabreTools.FileTypes.Archives
|
||||
outDir = Path.GetFullPath(outDir);
|
||||
|
||||
// If the base file is null, get the hash information
|
||||
baseFile ??= FileTypeTool.GetInfo(stream, -1, _hashTypes, keepReadOpen: true);
|
||||
baseFile ??= FileTypeTool.GetInfo(stream, _hashTypes, keepReadOpen: true);
|
||||
|
||||
// Get the output file name
|
||||
string outfile = Path.Combine(outDir, Core.Tools.Utilities.GetDepotPath(baseFile.SHA1, Depth)!);
|
||||
|
||||
@@ -362,7 +362,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
else
|
||||
{
|
||||
zipEntryRom = FileTypeTool.GetInfo(readStream,
|
||||
(long)localFile.UncompressedSize,
|
||||
_hashTypes,
|
||||
keepReadOpen: true);
|
||||
}
|
||||
@@ -419,7 +418,6 @@ namespace SabreTools.FileTypes.Archives
|
||||
else
|
||||
{
|
||||
zipEntryRom = FileTypeTool.GetInfo(readStream,
|
||||
localFile.Length,
|
||||
_hashTypes,
|
||||
keepReadOpen: false);
|
||||
}
|
||||
|
||||
@@ -64,21 +64,10 @@ namespace SabreTools.FileTypes
|
||||
/// Retrieve file information for a single stream
|
||||
/// </summary>
|
||||
/// <param name="input">Stream to get information from</param>
|
||||
/// <param name="size">Size of the input stream</param>
|
||||
/// <param name="hashes">Hashes to include in the information</param>
|
||||
/// <returns>Populated BaseFile object if success, null on error</returns>
|
||||
public static BaseFile GetInfo(Stream? input, long size, HashType[] hashes)
|
||||
=> GetInfo(input, size, hashes, keepReadOpen: false);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve file information for a single stream
|
||||
/// </summary>
|
||||
/// <param name="input">Stream to get information from</param>
|
||||
/// <param name="hashes">Hashes to include in the information</param>
|
||||
/// <param name="keepReadOpen">Indicates if the underlying read stream should be kept open</param>
|
||||
/// <returns>Populated BaseFile object if success, null on error</returns>
|
||||
public static BaseFile GetInfo(Stream? input, HashType[] hashes, bool keepReadOpen)
|
||||
=> GetInfo(input, size: -1, hashes, keepReadOpen);
|
||||
public static BaseFile GetInfo(Stream? input, HashType[] hashes)
|
||||
=> GetInfo(input, hashes, keepReadOpen: false);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve file information for a single file
|
||||
@@ -88,7 +77,7 @@ namespace SabreTools.FileTypes
|
||||
/// <param name="hashes">Hashes to include in the information</param>
|
||||
/// <param name="keepReadOpen">Indicates if the underlying read stream should be kept open</param>
|
||||
/// <returns>Populated BaseFile object if success, empty one on error</returns>
|
||||
public static BaseFile GetInfo(Stream? input, long size, HashType[] hashes, bool keepReadOpen)
|
||||
public static BaseFile GetInfo(Stream? input, HashType[] hashes, bool keepReadOpen)
|
||||
{
|
||||
// If we have no stream
|
||||
if (input == null)
|
||||
@@ -96,20 +85,8 @@ namespace SabreTools.FileTypes
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
// If we want to automatically set the size
|
||||
if (size == -1)
|
||||
size = input.Length;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Don't set the length if the stream doesn't support it
|
||||
}
|
||||
|
||||
// TODO: Replace this with size variant when added
|
||||
// Run the hashing on the input stream
|
||||
var hashDict = HashTool.GetStreamHashes(input, hashes);
|
||||
var hashDict = HashTool.GetStreamHashesAndSize(input, hashes, out long size);
|
||||
if (hashDict == null)
|
||||
return new BaseFile();
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.1" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.2" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.6.2" />
|
||||
<PackageReference Include="SabreTools.Matching" Version="1.5.1" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.8.4" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.8.6" />
|
||||
<PackageReference Include="SabreTools.Skippers" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.5.8" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.8.4" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.8.6" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
Reference in New Issue
Block a user