1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 19:47:19 +08:00
osu-lazer/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs

44 lines
1.3 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-12-06 18:56:20 +09:00
using System.IO;
using System.Linq;
using osu.Game.Beatmaps.IO;
namespace osu.Desktop.Beatmaps.IO
{
/// <summary>
/// Reads an extracted legacy beatmap from disk.
/// </summary>
public class LegacyFilesystemReader : ArchiveReader
{
2016-11-16 10:53:10 +08:00
public static void Register() => AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path));
2016-11-15 02:08:02 +08:00
2017-05-08 18:56:04 +08:00
private readonly string basePath;
public LegacyFilesystemReader(string path)
{
basePath = path;
2017-03-07 10:59:19 +09:00
BeatmapFilenames = Directory.GetFiles(basePath, @"*.osu").Select(Path.GetFileName).ToArray();
if (BeatmapFilenames.Length == 0)
throw new FileNotFoundException(@"This directory contains no beatmaps");
2017-03-07 10:59:19 +09:00
StoryboardFilename = Directory.GetFiles(basePath, @"*.osb").Select(Path.GetFileName).FirstOrDefault();
}
2016-11-05 20:00:14 +09:00
public override Stream GetStream(string name)
{
2016-10-10 14:00:33 -04:00
return File.OpenRead(Path.Combine(basePath, name));
}
public override void Dispose()
{
// no-op
2016-10-18 13:35:01 -04:00
}
2017-05-23 16:26:51 +09:00
public override Stream GetUnderlyingStream() => null;
2016-10-18 13:35:01 -04:00
}
2016-11-15 02:08:02 +08:00
}