1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:52:55 +08:00
osu-lazer/osu.Game/Database/LegacyScoreExporter.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.3 KiB
C#
Raw Normal View History

// 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-11-19 00:02:35 +08:00
using System.IO;
using System.Linq;
using System.Threading;
using osu.Framework.Platform;
2022-11-19 00:02:35 +08:00
using osu.Game.Extensions;
using osu.Game.Overlays.Notifications;
using osu.Game.Scoring;
namespace osu.Game.Database
{
public class LegacyScoreExporter : LegacyExporter<ScoreInfo>
{
2023-04-09 14:43:18 +08:00
public LegacyScoreExporter(Storage storage)
: base(storage)
{
}
2022-12-26 05:50:56 +08:00
protected override string GetFilename(ScoreInfo score)
{
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;
}
protected override string FileExtension => @".osr";
public override void ExportToStream(ScoreInfo model, Stream outputStream, ProgressNotification? notification, CancellationToken cancellationToken = default)
2022-11-19 00:02:35 +08:00
{
var file = model.Files.SingleOrDefault();
if (file == null)
return;
using (var inputStream = UserFileStorage.GetStream(file.File.GetStoragePath()))
inputStream.CopyTo(outputStream);
2022-11-19 00:02:35 +08:00
}
}
}