1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 00:53:22 +08:00

Merge pull request #2736 from peppy/fix-import-path-failures

Fix beatmaps with subfolders importing incorrectly on windows
This commit is contained in:
Dan Balasescu 2018-06-06 22:43:29 +09:00 committed by GitHub
commit 618446af7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using osu.Framework.IO.File;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.IO; using osu.Game.IO;
@ -364,7 +365,7 @@ namespace osu.Game.Database
using (Stream s = reader.GetStream(file)) using (Stream s = reader.GetStream(file))
fileInfos.Add(new TFileModel fileInfos.Add(new TFileModel
{ {
Filename = file, Filename = FileSafety.PathSanitise(file),
FileInfo = files.Add(s) FileInfo = files.Add(s)
}); });

View File

@ -4,7 +4,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using osu.Framework.IO.File;
namespace osu.Game.IO.Archives namespace osu.Game.IO.Archives
{ {
@ -15,19 +14,20 @@ namespace osu.Game.IO.Archives
{ {
private readonly string path; private readonly string path;
public LegacyFilesystemReader(string path) : base(Path.GetFileName(path)) public LegacyFilesystemReader(string path)
: base(Path.GetFileName(path))
{ {
this.path = path; // re-get full path to standardise with Directory.GetFiles return values below.
this.path = Path.GetFullPath(path);
} }
public override Stream GetStream(string name) => File.OpenRead(Path.Combine(path, name)); public override Stream GetStream(string name) => File.OpenRead(Path.Combine(path, name));
public override void Dispose() public override void Dispose()
{ {
// no-op
} }
public override IEnumerable<string> Filenames => Directory.GetFiles(path, "*", SearchOption.AllDirectories).Select(f => FileSafety.GetRelativePath(f, path)).ToArray(); public override IEnumerable<string> Filenames => Directory.GetFiles(path, "*", SearchOption.AllDirectories).Select(f => f.Replace(path, string.Empty).Trim(Path.DirectorySeparatorChar)).ToArray();
public override Stream GetUnderlyingStream() => null; public override Stream GetUnderlyingStream() => null;
} }