2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.IO.Archives
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-11-28 14:13:27 +08:00
|
|
|
|
/// Reads an archive from a directory on disk.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// </summary>
|
2018-11-28 14:13:27 +08:00
|
|
|
|
public class LegacyDirectoryArchiveReader : ArchiveReader
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly string path;
|
|
|
|
|
|
2018-11-28 14:13:27 +08:00
|
|
|
|
public LegacyDirectoryArchiveReader(string path)
|
2018-06-05 10:28:51 +08:00
|
|
|
|
: base(Path.GetFileName(path))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-06-06 19:55:42 +08:00
|
|
|
|
// re-get full path to standardise with Directory.GetFiles return values below.
|
|
|
|
|
this.path = Path.GetFullPath(path);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Stream GetStream(string name) => File.OpenRead(Path.Combine(path, name));
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-05 10:28:51 +08:00
|
|
|
|
public override IEnumerable<string> Filenames => Directory.GetFiles(path, "*", SearchOption.AllDirectories).Select(f => f.Replace(path, string.Empty).Trim(Path.DirectorySeparatorChar)).ToArray();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|