ArchiveManager decoupling

This commit is contained in:
Alex Amadori
2017-03-07 00:10:33 +01:00
parent a297489151
commit aee7b05bae

View File

@ -3,6 +3,7 @@
using System; using System;
using System.IO; using System.IO;
using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Database; using osu.Game.Database;
@ -13,12 +14,15 @@ namespace osu.Game.Beatmaps.IO
public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path) public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path)
{ {
foreach (var reader in Readers) try
{ {
if (reader.Test(storage, path)) return (BeatmapArchiveReader)GetReader(storage, path);
return (BeatmapArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path)); }
catch (InvalidCastException e)
{
Logger.Error(e, "A tricky ArchiveReader instance passed the test to be a BeatmapArhiveReader, but it's really not");
throw e;
} }
throw new IOException(@"Unknown file format");
} }
/// <summary> /// <summary>