2019-11-01 13:38:54 -04:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 14:54:44 -05:00
|
|
|
using System;
|
2015-10-04 00:23:11 -04:00
|
|
|
using System.IO;
|
2016-10-25 15:02:04 -04:00
|
|
|
using MediaBrowser.Model.IO;
|
2015-10-04 00:23:11 -04:00
|
|
|
|
2016-11-11 02:24:36 -05:00
|
|
|
namespace Emby.Server.Implementations.IO
|
2015-10-04 00:23:11 -04:00
|
|
|
{
|
|
|
|
public class MbLinkShortcutHandler : IShortcutHandler
|
|
|
|
{
|
2019-01-06 15:50:43 -05:00
|
|
|
public string Extension => ".mblink";
|
2015-10-04 00:23:11 -04:00
|
|
|
|
2021-05-20 15:28:18 -04:00
|
|
|
public string? Resolve(string shortcutPath)
|
2015-10-04 00:23:11 -04:00
|
|
|
{
|
2022-10-13 13:08:00 -04:00
|
|
|
ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
|
2015-10-04 00:23:11 -04:00
|
|
|
|
2023-09-13 11:30:50 -04:00
|
|
|
if (Path.GetExtension(shortcutPath.AsSpan()).Equals(".mblink", StringComparison.OrdinalIgnoreCase))
|
2015-10-04 00:23:11 -04:00
|
|
|
{
|
2019-01-26 17:09:07 -05:00
|
|
|
var path = File.ReadAllText(shortcutPath);
|
2015-10-04 00:23:11 -04:00
|
|
|
|
2023-09-13 11:30:50 -04:00
|
|
|
return Path.TrimEndingDirectorySeparator(path);
|
2015-10-04 00:23:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Create(string shortcutPath, string targetPath)
|
|
|
|
{
|
2022-10-13 13:08:00 -04:00
|
|
|
ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
|
|
|
|
ArgumentException.ThrowIfNullOrEmpty(targetPath);
|
2015-10-04 00:23:11 -04:00
|
|
|
|
2019-01-26 17:09:07 -05:00
|
|
|
File.WriteAllText(shortcutPath, targetPath);
|
2015-10-04 00:23:11 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|