2021-11-25 07:36:30 +00: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-11-18 16:02:35 +00:00
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
2023-02-17 12:52:10 +00:00
|
|
|
using System.Threading;
|
2021-11-25 07:36:30 +00:00
|
|
|
using osu.Framework.Platform;
|
2022-11-18 16:02:35 +00:00
|
|
|
using osu.Game.Extensions;
|
2022-12-11 09:30:24 +00:00
|
|
|
using osu.Game.Overlays.Notifications;
|
2021-11-25 07:36:30 +00:00
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
2023-05-05 07:19:09 +00:00
|
|
|
public class LegacyScoreExporter : LegacyExporter<ScoreInfo>
|
2021-11-25 07:36:30 +00:00
|
|
|
{
|
2023-04-09 06:43:18 +00:00
|
|
|
public LegacyScoreExporter(Storage storage)
|
|
|
|
: base(storage)
|
2021-11-25 07:36:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-25 21:50:56 +00:00
|
|
|
protected override string GetFilename(ScoreInfo score)
|
2022-12-23 23:01:04 +00:00
|
|
|
{
|
2022-12-24 22:18:42 +00:00
|
|
|
string scoreString = score.GetDisplayString();
|
2023-01-10 00:02:31 +00:00
|
|
|
string filename = $"{scoreString} ({score.Date.LocalDateTime:yyyy-MM-dd_HH-mm})";
|
2022-12-25 21:50:56 +00:00
|
|
|
|
|
|
|
return filename;
|
2021-11-25 07:36:30 +00:00
|
|
|
}
|
|
|
|
|
2023-05-06 17:42:28 +00:00
|
|
|
protected override string FileExtension => @".osr";
|
2022-11-21 09:58:01 +00:00
|
|
|
|
2023-05-06 15:24:30 +00:00
|
|
|
public override void ExportToStream(ScoreInfo model, Stream outputStream, ProgressNotification? notification, CancellationToken cancellationToken = default)
|
2022-11-18 16:02:35 +00:00
|
|
|
{
|
2022-11-27 00:58:54 +00:00
|
|
|
var file = model.Files.SingleOrDefault();
|
|
|
|
if (file == null)
|
|
|
|
return;
|
2022-11-21 09:58:01 +00:00
|
|
|
|
2022-11-27 00:58:54 +00:00
|
|
|
using (var inputStream = UserFileStorage.GetStream(file.File.GetStoragePath()))
|
2023-05-06 15:24:30 +00:00
|
|
|
inputStream.CopyTo(outputStream);
|
2022-11-18 16:02:35 +00:00
|
|
|
}
|
2021-11-25 07:36:30 +00:00
|
|
|
}
|
|
|
|
}
|