From d8f84fcca3a40ccbb652b7fa01145f877aec0ae1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 Feb 2018 10:20:23 +0900 Subject: [PATCH] Give ArchiveReader a filename --- osu.Game/Beatmaps/ArchiveModelImportManager.cs | 2 +- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- osu.Game/Beatmaps/IO/ArchiveReader.cs | 10 ++++++++++ osu.Game/Beatmaps/IO/LegacyFilesystemReader.cs | 2 +- osu.Game/Beatmaps/IO/OszArchiveReader.cs | 3 ++- osu.Game/Screens/Menu/Intro.cs | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/ArchiveModelImportManager.cs b/osu.Game/Beatmaps/ArchiveModelImportManager.cs index af0cdad0a3..beb5f47ad2 100644 --- a/osu.Game/Beatmaps/ArchiveModelImportManager.cs +++ b/osu.Game/Beatmaps/ArchiveModelImportManager.cs @@ -174,7 +174,7 @@ namespace osu.Game.Beatmaps private ArchiveReader getReaderFrom(string path) { if (ZipFile.IsZipFile(path)) - return new OszArchiveReader(Files.Storage.GetStream(path)); + return new OszArchiveReader(Files.Storage.GetStream(path), Path.GetFileName(path)); return new LegacyFilesystemReader(path); } } diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 0a7bf255c5..3821d16103 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -171,7 +171,7 @@ namespace osu.Game.Beatmaps { // This gets scheduled back to the update thread, but we want the import to run in the background. using (var stream = new MemoryStream(data)) - using (var archive = new OszArchiveReader(stream)) + using (var archive = new OszArchiveReader(stream, beatmapSetInfo.ToString())) Import(archive); downloadNotification.State = ProgressNotificationState.Completed; diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs index 453a03b882..7be03ffb1b 100644 --- a/osu.Game/Beatmaps/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -17,6 +17,16 @@ namespace osu.Game.Beatmaps.IO public abstract void Dispose(); + /// + /// The name of this archive (usually the containing filename). + /// + public readonly string Name; + + protected ArchiveReader(string name) + { + Name = name; + } + public abstract IEnumerable Filenames { get; } public virtual byte[] Get(string name) diff --git a/osu.Game/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Game/Beatmaps/IO/LegacyFilesystemReader.cs index 4a85f6f526..e0a54838e0 100644 --- a/osu.Game/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Game/Beatmaps/IO/LegacyFilesystemReader.cs @@ -15,7 +15,7 @@ namespace osu.Game.Beatmaps.IO { private readonly string path; - public LegacyFilesystemReader(string path) + public LegacyFilesystemReader(string path) : base(Path.GetFileName(path)) { this.path = path; } diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index e5c971889b..fbac5d79f3 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -13,7 +13,8 @@ namespace osu.Game.Beatmaps.IO private readonly Stream archiveStream; private readonly ZipFile archive; - public OszArchiveReader(Stream archiveStream) + public OszArchiveReader(Stream archiveStream, string name = null) + : base(name) { this.archiveStream = archiveStream; archive = ZipFile.Read(archiveStream); diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 10b08d704d..3298827d25 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Menu if (setInfo == null) { // we need to import the default menu background beatmap - setInfo = beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz"))); + setInfo = beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz"), "circles.osz")); setInfo.Protected = true; } }