1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 06:22:56 +08:00

Merge pull request #31039 from frenzibyte/ios-temporary-export-storage

Use temporary storage for file exports on iOS
This commit is contained in:
Dean Herbert 2024-12-10 23:53:40 -08:00 committed by GitHub
commit 02c52e41bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 1 deletions

View File

@ -9,6 +9,7 @@ using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Platform;
using osu.Game.Extensions;
using osu.Game.IO;
using osu.Game.Overlays.Notifications;
using osu.Game.Utils;
using Realms;
@ -46,7 +47,7 @@ namespace osu.Game.Database
protected LegacyExporter(Storage storage)
{
exportStorage = storage.GetStorageForDirectory(@"exports");
exportStorage = (storage as OsuStorage)?.GetExportStorage() ?? storage.GetStorageForDirectory(@"exports");
UserFileStorage = storage.GetStorageForDirectory(@"files");
}

View File

@ -61,6 +61,11 @@ namespace osu.Game.IO
TryChangeToCustomStorage(out Error);
}
/// <summary>
/// Returns the <see cref="Storage"/> used for storing exported files.
/// </summary>
public virtual Storage GetExportStorage() => GetStorageForDirectory(@"exports");
/// <summary>
/// Resets the custom storage path, changing the target storage to the default location.
/// </summary>

View File

@ -5,6 +5,8 @@ using System;
using Foundation;
using Microsoft.Maui.Devices;
using osu.Framework.Graphics;
using osu.Framework.iOS;
using osu.Framework.Platform;
using osu.Game;
using osu.Game.Updater;
using osu.Game.Utils;
@ -19,6 +21,8 @@ namespace osu.iOS
protected override BatteryInfo CreateBatteryInfo() => new IOSBatteryInfo();
protected override Storage CreateStorage(GameHost host, Storage defaultStorage) => new OsuStorageIOS((IOSGameHost)host, defaultStorage);
protected override Edges SafeAreaOverrideEdges =>
// iOS shows a home indicator at the bottom, and adds a safe area to account for this.
// Because we have the home indicator (mostly) hidden we don't really care about drawing in this region.

23
osu.iOS/OsuStorageIOS.cs Normal file
View File

@ -0,0 +1,23 @@
// 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.
using System.IO;
using osu.Framework.iOS;
using osu.Framework.Platform;
using osu.Game.IO;
namespace osu.iOS
{
public class OsuStorageIOS : OsuStorage
{
private readonly IOSGameHost host;
public OsuStorageIOS(IOSGameHost host, Storage defaultStorage)
: base(host, defaultStorage)
{
this.host = host;
}
public override Storage GetExportStorage() => new IOSStorage(Path.GetTempPath(), host);
}
}