2021-11-25 15:36:30 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-11-25 15:36:30 +08:00
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
using osu.Game.Extensions;
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
|
|
|
public class LegacyScoreExporter : LegacyExporter<ScoreInfo>
|
|
|
|
{
|
|
|
|
protected override string FileExtension => ".osr";
|
|
|
|
|
2021-11-25 17:36:01 +08:00
|
|
|
public LegacyScoreExporter(Storage storage)
|
|
|
|
: base(storage)
|
2021-11-25 15:36:30 +08:00
|
|
|
{
|
2022-12-24 07:01:04 +08:00
|
|
|
}
|
|
|
|
|
2022-12-26 05:50:56 +08:00
|
|
|
protected override string GetFilename(ScoreInfo score)
|
2022-12-24 07:01:04 +08:00
|
|
|
{
|
2022-12-25 06:18:42 +08:00
|
|
|
string scoreString = score.GetDisplayString();
|
2023-01-10 08:02:31 +08:00
|
|
|
string filename = $"{scoreString} ({score.Date.LocalDateTime:yyyy-MM-dd_HH-mm})";
|
2022-12-26 05:50:56 +08:00
|
|
|
|
|
|
|
return filename;
|
2021-11-25 15:36:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void ExportModelTo(ScoreInfo model, Stream outputStream)
|
|
|
|
{
|
|
|
|
var file = model.Files.SingleOrDefault();
|
|
|
|
if (file == null)
|
|
|
|
return;
|
|
|
|
|
2021-12-06 21:47:00 +08:00
|
|
|
using (var inputStream = UserFileStorage.GetStream(file.File.GetStoragePath()))
|
2021-11-25 15:36:30 +08:00
|
|
|
inputStream.CopyTo(outputStream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|