Give ArchiveReader a filename

This commit is contained in:
Dean Herbert 2018-02-15 10:20:23 +09:00
parent e0d28564d0
commit d8f84fcca3
6 changed files with 16 additions and 5 deletions

View File

@ -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);
}
}

View File

@ -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;

View File

@ -17,6 +17,16 @@ namespace osu.Game.Beatmaps.IO
public abstract void Dispose();
/// <summary>
/// The name of this archive (usually the containing filename).
/// </summary>
public readonly string Name;
protected ArchiveReader(string name)
{
Name = name;
}
public abstract IEnumerable<string> Filenames { get; }
public virtual byte[] Get(string name)

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}
}