1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Handle external files with File instead

This commit is contained in:
Paul Teng 2018-09-24 07:16:19 -04:00
parent 5e51a50658
commit 62df0ec7d4

View File

@ -3,6 +3,7 @@
using System; using System;
using System.IO; using System.IO;
using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
@ -49,8 +50,24 @@ namespace osu.Game.Rulesets.Scoring
public Score ReadReplayFile(string replayFilename) public Score ReadReplayFile(string replayFilename)
{ {
using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename))) Stream stream;
return new DatabasedLegacyScoreParser(rulesets, beatmaps).Parse(s); if (File.Exists(replayFilename))
{
// Handle replay with File since it is outside of storage
stream = File.OpenRead(replayFilename);
}
else if (storage.Exists(Path.Combine(replay_folder, replayFilename)))
{
stream = storage.GetStream(Path.Combine(replay_folder, replayFilename));
}
else
{
Logger.Log($"Replay file {replayFilename} cannot be found", LoggingTarget.Information, LogLevel.Error);
return null;
}
using (stream)
return new DatabasedLegacyScoreParser(rulesets, beatmaps).Parse(stream);
} }
} }
} }