1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Rename ArchiveReader implementations to read better

This commit is contained in:
Dean Herbert 2023-09-14 13:36:07 +09:00
parent 0657b55196
commit 541cd972e1
6 changed files with 14 additions and 14 deletions

View File

@ -319,7 +319,7 @@ namespace osu.Game.Beatmaps
{
DateTimeOffset dateAdded = DateTimeOffset.UtcNow;
if (reader is LegacyDirectoryArchiveReader legacyReader)
if (reader is DirectoryArchiveReader legacyReader)
{
var beatmaps = reader.Filenames.Where(f => f.EndsWith(".osu", StringComparison.OrdinalIgnoreCase));

View File

@ -58,7 +58,7 @@ namespace osu.Game.Database
}
// This isn't used in any current path. May need to reconsider for performance reasons (ie. if we don't expect the incoming stream to be copied out).
return new LegacyByteArrayReader(Stream.ReadAllBytesToArray(), Path);
return new ByteArrayArchiveReader(Stream.ReadAllBytesToArray(), Path);
}
/// <summary>
@ -80,9 +80,9 @@ namespace osu.Game.Database
if (ZipUtils.IsZipArchive(path))
return new ZipArchiveReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read), System.IO.Path.GetFileName(path));
if (Directory.Exists(path))
return new LegacyDirectoryArchiveReader(path);
return new DirectoryArchiveReader(path);
if (File.Exists(path))
return new LegacyFileArchiveReader(path);
return new SingleFileArchiveReader(path);
throw new InvalidFormatException($"{path} is not a valid archive");
}

View File

@ -9,11 +9,11 @@ namespace osu.Game.IO.Archives
/// <summary>
/// Allows reading a single file from the provided byte array.
/// </summary>
public class LegacyByteArrayReader : ArchiveReader
public class ByteArrayArchiveReader : ArchiveReader
{
private readonly byte[] content;
public LegacyByteArrayReader(byte[] content, string filename)
public ByteArrayArchiveReader(byte[] content, string filename)
: base(filename)
{
this.content = content;

View File

@ -8,13 +8,13 @@ using System.Linq;
namespace osu.Game.IO.Archives
{
/// <summary>
/// Reads an archive from a directory on disk.
/// Reads an archive directly from a directory on disk.
/// </summary>
public class LegacyDirectoryArchiveReader : ArchiveReader
public class DirectoryArchiveReader : ArchiveReader
{
private readonly string path;
public LegacyDirectoryArchiveReader(string path)
public DirectoryArchiveReader(string path)
: base(Path.GetFileName(path))
{
// re-get full path to standardise with Directory.GetFiles return values below.

View File

@ -7,14 +7,14 @@ using System.IO;
namespace osu.Game.IO.Archives
{
/// <summary>
/// Reads a file on disk as an archive.
/// Reads a single file on disk as an archive.
/// Note: In this case, the file is not an extractable archive, use <see cref="ZipArchiveReader"/> instead.
/// </summary>
public class LegacyFileArchiveReader : ArchiveReader
public class SingleFileArchiveReader : ArchiveReader
{
private readonly string path;
public LegacyFileArchiveReader(string path)
public SingleFileArchiveReader(string path)
: base(Path.GetFileName(path))
{
// re-get full path to standardise

View File

@ -1144,14 +1144,14 @@ namespace osu.Game.Screens.Play
if (DrawableRuleset.ReplayScore != null)
return Task.CompletedTask;
LegacyByteArrayReader replayReader = null;
ByteArrayArchiveReader replayReader = null;
if (score.ScoreInfo.Ruleset.IsLegacyRuleset())
{
using (var stream = new MemoryStream())
{
new LegacyScoreEncoder(score, GameplayState.Beatmap).Encode(stream);
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
replayReader = new ByteArrayArchiveReader(stream.ToArray(), "replay.osr");
}
}