jellyfin-server/Emby.Naming/Video/StubResolver.cs
Bond_009 5a8e972952 Enable TreatWarningsAsErrors for some projects
Analyzers are only run in debug build, so setting TreatWarningsAsErrors
for release build will catch the compiler warnings until we resolve all
analyzer warnings.
2019-12-13 20:11:37 +01:00

48 lines
1.2 KiB
C#

#pragma warning disable CS1591
#pragma warning disable SA1600
using System;
using System.IO;
using System.Linq;
using Emby.Naming.Common;
namespace Emby.Naming.Video
{
public static class StubResolver
{
public static StubResult ResolveFile(string path, NamingOptions options)
{
if (path == null)
{
return default(StubResult);
}
var extension = Path.GetExtension(path);
if (!options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
{
return default(StubResult);
}
var result = new StubResult()
{
IsStub = true
};
path = Path.GetFileNameWithoutExtension(path);
var token = Path.GetExtension(path).TrimStart('.');
foreach (var rule in options.StubTypes)
{
if (string.Equals(rule.Token, token, StringComparison.OrdinalIgnoreCase))
{
result.StubType = rule.StubType;
break;
}
}
return result;
}
}
}