diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs
index 0b876ed171..ee58d934a4 100644
--- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs
+++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs
@@ -110,7 +110,7 @@ namespace osu.Desktop.VisualTests.Tests
Beatmap = beatmap;
}
- protected override BeatmapArchiveReader GetReader() => null;
+ protected override ArchiveReader GetReader() => null;
}
}
}
diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs
index 19aa9ca4a6..0ef448cafe 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 : BeatmapArchiveReader
+ public class LegacyFilesystemReader : ArchiveReader
{
public static void Register() => AddReader((storage, path) => Directory.Exists(path));
diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs
index 478919272e..27f58c27e1 100644
--- a/osu.Desktop/OsuGameDesktop.cs
+++ b/osu.Desktop/OsuGameDesktop.cs
@@ -12,7 +12,6 @@ using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using osu.Game.Screens.Menu;
-using osu.Game.Beatmaps.IO;
namespace osu.Desktop
{
@@ -58,7 +57,7 @@ namespace osu.Desktop
var dropData = (object[])e.Data.GetData(DataFormats.FileDrop);
var filePaths = dropData.Select(f => f.ToString()).ToArray();
- if (filePaths.All(f => Path.GetExtension(f) == BeatmapArchiveReader.OSZ_EXTENSION))
+ if (filePaths.All(f => Path.GetExtension(f) == @".osz"))
Task.Run(() => BeatmapDatabase.Import(filePaths));
else if (filePaths.All(f => Path.GetExtension(f) == @".osr"))
Task.Run(() =>
@@ -68,7 +67,7 @@ namespace osu.Desktop
});
}
- private static readonly string[] allowed_extensions = { BeatmapArchiveReader.OSZ_EXTENSION, @".osr" };
+ private static readonly string[] allowed_extensions = { @".osz", @".osr" };
private void dragEnter(DragEventArgs e)
{
diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
index a6ab6a989b..ae936f3f49 100644
--- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
+++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs
@@ -17,7 +17,6 @@ using osu.Game.Modes.Catch;
using osu.Game.Modes.Mania;
using osu.Game.Modes.Osu;
using osu.Game.Modes.Taiko;
-using osu.Game.Beatmaps.IO;
namespace osu.Game.Tests.Beatmaps.IO
{
@@ -107,7 +106,7 @@ namespace osu.Game.Tests.Beatmaps.IO
private string prepareTempCopy(string path)
{
- var temp = Path.GetTempPath() + Guid.NewGuid() + BeatmapArchiveReader.OSZ_EXTENSION;
+ var temp = Path.GetTempFileName();
return new FileInfo(path).CopyTo(temp, true).FullName;
}
diff --git a/osu.Game/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs
similarity index 65%
rename from osu.Game/IO/ArchiveReader.cs
rename to osu.Game/Beatmaps/IO/ArchiveReader.cs
index 8eaecdeabc..bbf4de20f5 100644
--- a/osu.Game/IO/ArchiveReader.cs
+++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs
@@ -6,22 +6,23 @@ using System.Collections.Generic;
using System.IO;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
+using osu.Game.Database;
-namespace osu.Game.IO
+namespace osu.Game.Beatmaps.IO
{
public abstract class ArchiveReader : IDisposable, IResourceStore
{
- protected class Reader
+ private class Reader
{
public Func Test { get; set; }
public Type Type { get; set; }
}
- protected static List Readers { get; } = new List();
+ private 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));
@@ -31,9 +32,24 @@ namespace osu.Game.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
deleted file mode 100644
index 0fab05df49..0000000000
--- a/osu.Game/Beatmaps/IO/BeatmapArchiveReader.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2007-2017 ppy Pty Ltd .
-// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
-
-using System;
-using osu.Framework.Logging;
-using osu.Framework.Platform;
-using osu.Game.Database;
-using osu.Game.IO;
-
-namespace osu.Game.Beatmaps.IO
-{
- public abstract class BeatmapArchiveReader : ArchiveReader
- {
- public const string OSZ_EXTENSION = @".osz";
-
- public static BeatmapArchiveReader GetBeatmapArchiveReader(Storage storage, string path)
- {
- try
- {
- return (BeatmapArchiveReader)GetReader(storage, path);
- }
- catch (InvalidCastException e)
- {
- Logger.Error(e, "A tricky " + $@"{nameof(ArchiveReader)}" + " instance passed the test to be a " + $@"{nameof(BeatmapArchiveReader)}" + ", but it's really not");
- throw;
- }
- }
-
- ///
- /// 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 8c3e4d702c..8a1d071cfc 100644
--- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs
+++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs
@@ -9,14 +9,14 @@ using osu.Game.Database;
namespace osu.Game.Beatmaps.IO
{
- public sealed class OszArchiveReader : BeatmapArchiveReader
+ public sealed class OszArchiveReader : ArchiveReader
{
public static void Register()
{
AddReader((storage, path) =>
{
using (var stream = storage.GetStream(path))
- return Path.GetExtension(path) == OSZ_EXTENSION && ZipFile.IsZipFile(stream, false);
+ return ZipFile.IsZipFile(stream, false);
});
OsuLegacyDecoder.Register();
}
diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs
index 545fc9f398..1d4047ea45 100644
--- a/osu.Game/Beatmaps/WorkingBeatmap.cs
+++ b/osu.Game/Beatmaps/WorkingBeatmap.cs
@@ -32,7 +32,7 @@ namespace osu.Game.Beatmaps
public readonly bool WithStoryboard;
- protected abstract BeatmapArchiveReader GetReader();
+ protected abstract ArchiveReader GetReader();
protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false)
{
@@ -100,7 +100,7 @@ namespace osu.Game.Beatmaps
set { lock (beatmapLock) beatmap = value; }
}
- private BeatmapArchiveReader trackReader;
+ private ArchiveReader 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 a9fe30a5e9..871251b882 100644
--- a/osu.Game/Database/BeatmapDatabase.cs
+++ b/osu.Game/Database/BeatmapDatabase.cs
@@ -177,7 +177,7 @@ namespace osu.Game.Database
BeatmapMetadata metadata;
- using (var reader = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path))
+ using (var reader = ArchiveReader.GetReader(storage, path))
metadata = reader.ReadMetadata();
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
@@ -186,7 +186,7 @@ namespace osu.Game.Database
{
hash = input.GetMd5Hash();
input.Seek(0, SeekOrigin.Begin);
- path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash + BeatmapArchiveReader.OSZ_EXTENSION);
+ path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash);
if (!storage.Exists(path))
using (var output = storage.GetStream(path, FileAccess.Write))
input.CopyTo(output);
@@ -216,7 +216,7 @@ namespace osu.Game.Database
Metadata = metadata
};
- using (var archive = BeatmapArchiveReader.GetBeatmapArchiveReader(storage, path))
+ using (var archive = ArchiveReader.GetReader(storage, path))
{
string[] mapNames = archive.BeatmapFilenames;
foreach (var name in mapNames)
@@ -268,12 +268,12 @@ namespace osu.Game.Database
BeatmapSetRemoved?.Invoke(beatmapSet);
}
- public BeatmapArchiveReader GetReader(BeatmapSetInfo beatmapSet)
+ public ArchiveReader GetReader(BeatmapSetInfo beatmapSet)
{
if (string.IsNullOrEmpty(beatmapSet.Path))
return null;
- return BeatmapArchiveReader.GetBeatmapArchiveReader(storage, beatmapSet.Path);
+ return ArchiveReader.GetReader(storage, beatmapSet.Path);
}
public BeatmapSetInfo GetBeatmapSet(int id)
@@ -354,7 +354,7 @@ namespace osu.Game.Database
this.database = database;
}
- protected override BeatmapArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo);
+ protected override ArchiveReader GetReader() => database?.GetReader(BeatmapSetInfo);
}
}
}
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index 6c060328a4..4a8f41b1ac 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -238,7 +238,7 @@
-
+
@@ -326,7 +326,6 @@
-