diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs
index b8bfb63a08..632a33f670 100644
--- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs
+++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs
@@ -13,7 +13,7 @@ namespace osu.Desktop.Beatmaps.IO
///
/// Reads an extracted legacy beatmap from disk.
///
- public class LegacyFilesystemReader : ArchiveReader
+ public class LegacyFilesystemReader : BeatmapArchiveReader
{
public static void Register() => AddReader((storage, path) => Directory.Exists(path));
diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs
index bbf4de20f5..ba84402782 100644
--- a/osu.Game/Beatmaps/IO/ArchiveReader.cs
+++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs
@@ -6,23 +6,22 @@ using System.Collections.Generic;
using System.IO;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
-using osu.Game.Database;
namespace osu.Game.Beatmaps.IO
{
public abstract class ArchiveReader : IDisposable, IResourceStore
{
- private class Reader
+ protected class Reader
{
public Func Test { get; set; }
public Type Type { get; set; }
}
- private static List readers { get; } = new List();
+ protected static List Readers { get; } = new List();
public static ArchiveReader GetReader(Storage storage, string path)
{
- foreach (var reader in readers)
+ foreach (var reader in Readers)
{
if (reader.Test(storage, path))
return (ArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path));
@@ -32,24 +31,9 @@ namespace osu.Game.Beatmaps.IO
protected static void AddReader(Func test) where T : ArchiveReader
{
- readers.Add(new Reader { Test = test, Type = typeof(T) });
+ Readers.Add(new Reader { Test = test, Type = typeof(T) });
}
- ///
- /// Reads the beatmap metadata from this archive.
- ///
- public abstract BeatmapMetadata ReadMetadata();
-
- ///
- /// Gets a list of beatmap file names.
- ///
- public string[] BeatmapFilenames { get; protected set; }
-
- ///
- /// The storyboard filename. Null if no storyboard is present.
- ///
- public string StoryboardFilename { get; protected set; }
-
///
/// Opens a stream for reading a specific file from this archive.
///
diff --git a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs
new file mode 100644
index 0000000000..8cff2c121f
--- /dev/null
+++ b/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs
@@ -0,0 +1,39 @@
+// Copyright (c) 2007-2017 ppy Pty Ltd .
+// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
+
+using System;
+using System.IO;
+using osu.Framework.Platform;
+using osu.Game.Database;
+
+namespace osu.Game.Beatmaps.IO
+{
+ public abstract class BeatmapArchiveReader : ArchiveReader
+ {
+
+ public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path)
+ {
+ foreach (var reader in Readers)
+ {
+ if (reader.Test(storage, path))
+ return (BeatmapArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path));
+ }
+ throw new IOException(@"Unknown file format");
+ }
+
+ ///
+ /// Reads the beatmap metadata from this archive.
+ ///
+ public abstract BeatmapMetadata ReadMetadata();
+
+ ///
+ /// Gets a list of beatmap file names.
+ ///
+ public string[] BeatmapFilenames { get; protected set; }
+
+ ///
+ /// The storyboard filename. Null if no storyboard is present.
+ ///
+ public string StoryboardFilename { get; protected set; }
+ }
+}
\ No newline at end of file
diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs
index 8a1d071cfc..802fe7784b 100644
--- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs
+++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs
@@ -9,7 +9,7 @@ using osu.Game.Database;
namespace osu.Game.Beatmaps.IO
{
- public sealed class OszArchiveReader : ArchiveReader
+ public sealed class OszArchiveReader : BeatmapArchiveReader
{
public static void Register()
{
diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs
index 9393c2b0e9..4254652765 100644
--- a/osu.Game/Beatmaps/WorkingBeatmap.cs
+++ b/osu.Game/Beatmaps/WorkingBeatmap.cs
@@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps
public readonly bool WithStoryboard;
- protected abstract ArchiveReader GetReader();
+ protected abstract BeatmapArchiveReader GetReader();
protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false)
{
@@ -87,7 +87,7 @@ namespace osu.Game.Beatmaps
set { lock (beatmapLock) beatmap = value; }
}
- private ArchiveReader trackReader;
+ private BeatmapArchiveReader trackReader;
private Track track;
private object trackLock = new object();
public Track Track
diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs
index 03f904b7e8..1be0757e00 100644
--- a/osu.Game/Database/BeatmapDatabase.cs
+++ b/osu.Game/Database/BeatmapDatabase.cs
@@ -176,7 +176,7 @@ namespace osu.Game.Database
BeatmapMetadata metadata;
- using (var reader = ArchiveReader.GetReader(storage, path))
+ using (var reader = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path))
metadata = reader.ReadMetadata();
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
@@ -216,7 +216,7 @@ namespace osu.Game.Database
Metadata = metadata
};
- using (var reader = ArchiveReader.GetReader(storage, path))
+ using (var reader = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path))
{
string[] mapNames = reader.BeatmapFilenames;
foreach (var name in mapNames)
@@ -261,12 +261,12 @@ namespace osu.Game.Database
BeatmapSetRemoved?.Invoke(beatmapSet);
}
- public ArchiveReader GetReader(BeatmapSetInfo beatmapSet)
+ public BeatmapArchiveReader GetReader(BeatmapSetInfo beatmapSet)
{
if (string.IsNullOrEmpty(beatmapSet.Path))
return null;
- return ArchiveReader.GetReader(storage, beatmapSet.Path);
+ return BeatmapArchiveReader.GetBeatmapArchiveReader(storage, beatmapSet.Path);
}
public BeatmapSetInfo GetBeatmapSet(int id)
@@ -348,7 +348,7 @@ namespace osu.Game.Database
this.database = database;
}
- protected override ArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo);
+ protected override BeatmapArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo);
}
}
}
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index f38c2f7ba0..10d82396a7 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -223,7 +223,7 @@
-
+
@@ -311,6 +311,7 @@
+