osu/osu.Game/Utils/ZipUtils.cs

38 lines
894 B
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 09:19:50 +00:00
using System;
using System.IO;
2018-04-13 09:19:50 +00:00
using SharpCompress.Archives.Zip;
namespace osu.Game.Utils
{
public static class ZipUtils
{
public static bool IsZipArchive(string path)
{
if (!File.Exists(path))
return false;
2018-04-13 09:19:50 +00:00
try
{
using (var arc = ZipArchive.Open(path))
{
foreach (var entry in arc.Entries)
{
using (entry.OpenEntryStream())
{
}
}
}
return true;
}
catch (Exception)
{
return false;
}
}
}
}