mirror of
https://github.com/ppy/osu
synced 2025-01-03 04:42:10 +00:00
Give ArchiveReader a filename
This commit is contained in:
parent
e0d28564d0
commit
d8f84fcca3
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user