MbLinkShortcutHandler.cs 954 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.IO;
  4. using MediaBrowser.Model.IO;
  5. namespace Emby.Server.Implementations.IO
  6. {
  7. public class MbLinkShortcutHandler : IShortcutHandler
  8. {
  9. public string Extension => ".mblink";
  10. public string? Resolve(string shortcutPath)
  11. {
  12. ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
  13. if (Path.GetExtension(shortcutPath.AsSpan()).Equals(".mblink", StringComparison.OrdinalIgnoreCase))
  14. {
  15. var path = File.ReadAllText(shortcutPath);
  16. return Path.TrimEndingDirectorySeparator(path);
  17. }
  18. return null;
  19. }
  20. public void Create(string shortcutPath, string targetPath)
  21. {
  22. ArgumentException.ThrowIfNullOrEmpty(shortcutPath);
  23. ArgumentException.ThrowIfNullOrEmpty(targetPath);
  24. File.WriteAllText(shortcutPath, targetPath);
  25. }
  26. }
  27. }