mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Add pathway to correctly handle stream-based imports which are not zip archives
This commit is contained in:
@ -9,6 +9,34 @@ namespace osu.Game.Utils
|
||||
{
|
||||
public static class ZipUtils
|
||||
{
|
||||
public static bool IsZipArchive(Stream stream)
|
||||
{
|
||||
try
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
using (var arc = ZipArchive.Open(stream))
|
||||
{
|
||||
foreach (var entry in arc.Entries)
|
||||
{
|
||||
using (entry.OpenEntryStream())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsZipArchive(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
|
Reference in New Issue
Block a user