Files
AR-Menu/Library/PackageCache/com.unity.sharp-zip-lib@6b61f82b0cb3/Tests/Runtime/Src/TestSupport/ZipTesting.cs
2025-11-30 08:35:03 +02:00

36 lines
1.1 KiB
C#

using Unity.SharpZipLib.Zip;
using System.IO;
namespace Unity.SharpZipLib.Tests.TestSupport
{
/// <summary>
/// Provides support for testing in memory zip archives.
/// </summary>
internal static class ZipTesting
{
/// <summary>
/// Tests the archive.
/// </summary>
/// <param name="data">The data.</param>
/// <returns></returns>
public static bool TestArchive(byte[] data)
{
return TestArchive(data, null);
}
/// <summary>
/// Tests the archive.
/// </summary>
/// <param name="data">The data.</param>
/// <param name="password">The password.</param>
/// <returns>true if archive tests ok; false otherwise.</returns>
public static bool TestArchive(byte[] data, string password)
{
using (MemoryStream ms = new MemoryStream(data))
using (ZipFile zipFile = new ZipFile(ms))
{
zipFile.Password = password;
return zipFile.TestArchive(true);
}
}
}
}