-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathEmbeddedAssetHelper.cs
More file actions
30 lines (28 loc) · 1006 Bytes
/
Copy pathEmbeddedAssetHelper.cs
File metadata and controls
30 lines (28 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.IO;
using System.Linq;
using System.Reflection;
using System;
namespace Jellyfin.Plugin.JMSFusion
{
internal static class EmbeddedAssetHelper
{
internal static bool Exists(string resourceName)
{
var asm = typeof(JMSFusionPlugin).Assembly;
return asm.GetManifestResourceNames()
.Any(n => n.EndsWith(resourceName, StringComparison.OrdinalIgnoreCase));
}
internal static byte[]? TryRead(string resourceName)
{
var asm = typeof(JMSFusionPlugin).Assembly;
var full = asm.GetManifestResourceNames()
.FirstOrDefault(n => n.EndsWith(resourceName, StringComparison.OrdinalIgnoreCase));
if (full == null) return null;
using var s = asm.GetManifestResourceStream(full);
if (s == null) return null;
using var ms = new MemoryStream();
s.CopyTo(ms);
return ms.ToArray();
}
}
}