mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 11:27:24 +08:00
Share framework file-exclusion function
This commit is contained in:
parent
e4270dc57c
commit
35be8f9dfb
@ -1,30 +1,16 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
using SharpCompress.Archives.Zip;
|
using SharpCompress.Archives.Zip;
|
||||||
using SharpCompress.Common;
|
|
||||||
|
|
||||||
namespace osu.Game.IO.Archives
|
namespace osu.Game.IO.Archives
|
||||||
{
|
{
|
||||||
public sealed class ZipArchiveReader : ArchiveReader
|
public sealed class ZipArchiveReader : ArchiveReader
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// List of substrings that indicate a file should be ignored during the import process
|
|
||||||
/// (usually due to representing no useful data and being autogenerated by the OS).
|
|
||||||
/// </summary>
|
|
||||||
private static readonly string[] filename_ignore_list =
|
|
||||||
{
|
|
||||||
// Mac-specific
|
|
||||||
"__MACOSX",
|
|
||||||
".DS_Store",
|
|
||||||
// Windows-specific
|
|
||||||
"Thumbs.db"
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly Stream archiveStream;
|
private readonly Stream archiveStream;
|
||||||
private readonly ZipArchive archive;
|
private readonly ZipArchive archive;
|
||||||
|
|
||||||
@ -58,9 +44,7 @@ namespace osu.Game.IO.Archives
|
|||||||
archiveStream.Dispose();
|
archiveStream.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool canBeIgnored(IEntry entry) => filename_ignore_list.Any(ignoredName => entry.Key.IndexOf(ignoredName, StringComparison.OrdinalIgnoreCase) >= 0);
|
public override IEnumerable<string> Filenames => archive.Entries.Select(e => e.Key).ExcludeSystemFileNames();
|
||||||
|
|
||||||
public override IEnumerable<string> Filenames => archive.Entries.Where(e => !canBeIgnored(e)).Select(e => e.Key).ToArray();
|
|
||||||
|
|
||||||
public override Stream GetUnderlyingStream() => archiveStream;
|
public override Stream GetUnderlyingStream() => archiveStream;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user