BaseApplicationPaths.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.IO;
  3. using MediaBrowser.Common.Configuration;
  4. namespace Emby.Server.Implementations.AppBase
  5. {
  6. /// <summary>
  7. /// Provides a base class to hold common application paths used by both the UI and Server.
  8. /// This can be subclassed to add application-specific paths.
  9. /// </summary>
  10. public abstract class BaseApplicationPaths : IApplicationPaths
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
  14. /// </summary>
  15. /// <param name="programDataPath">The program data path.</param>
  16. /// <param name="logDirectoryPath">The log directory path.</param>
  17. /// <param name="configurationDirectoryPath">The configuration directory path.</param>
  18. /// <param name="cacheDirectoryPath">The cache directory path.</param>
  19. /// <param name="webDirectoryPath">The web directory path.</param>
  20. protected BaseApplicationPaths(
  21. string programDataPath,
  22. string logDirectoryPath,
  23. string configurationDirectoryPath,
  24. string cacheDirectoryPath,
  25. string webDirectoryPath)
  26. {
  27. ProgramDataPath = programDataPath;
  28. LogDirectoryPath = logDirectoryPath;
  29. ConfigurationDirectoryPath = configurationDirectoryPath;
  30. CachePath = cacheDirectoryPath;
  31. WebPath = webDirectoryPath;
  32. DataPath = Directory.CreateDirectory(Path.Combine(ProgramDataPath, "data")).FullName;
  33. }
  34. /// <inheritdoc/>
  35. public string ProgramDataPath { get; }
  36. /// <inheritdoc/>
  37. public string WebPath { get; }
  38. /// <inheritdoc/>
  39. public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
  40. /// <inheritdoc/>
  41. public string DataPath { get; }
  42. /// <inheritdoc />
  43. public string VirtualDataPath => "%AppDataPath%";
  44. /// <inheritdoc/>
  45. public string ImageCachePath => Path.Combine(CachePath, "images");
  46. /// <inheritdoc/>
  47. public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
  48. /// <inheritdoc/>
  49. public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
  50. /// <inheritdoc/>
  51. public string LogDirectoryPath { get; }
  52. /// <inheritdoc/>
  53. public string ConfigurationDirectoryPath { get; }
  54. /// <inheritdoc/>
  55. public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
  56. /// <inheritdoc/>
  57. public string CachePath { get; set; }
  58. /// <inheritdoc/>
  59. public string TempDirectory => Path.Join(Path.GetTempPath(), "jellyfin");
  60. /// <inheritdoc />
  61. public string TrickplayPath => Path.Combine(DataPath, "trickplay");
  62. }
  63. }