| | 1 | | using System; |
| | 2 | | using System.IO; |
| | 3 | | using MediaBrowser.Common.Configuration; |
| | 4 | |
|
| | 5 | | namespace Emby.Server.Implementations.AppBase |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// Provides a base class to hold common application paths used by both the UI and Server. |
| | 9 | | /// This can be subclassed to add application-specific paths. |
| | 10 | | /// </summary> |
| | 11 | | public abstract class BaseApplicationPaths : IApplicationPaths |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class. |
| | 15 | | /// </summary> |
| | 16 | | /// <param name="programDataPath">The program data path.</param> |
| | 17 | | /// <param name="logDirectoryPath">The log directory path.</param> |
| | 18 | | /// <param name="configurationDirectoryPath">The configuration directory path.</param> |
| | 19 | | /// <param name="cacheDirectoryPath">The cache directory path.</param> |
| | 20 | | /// <param name="webDirectoryPath">The web directory path.</param> |
| | 21 | | protected BaseApplicationPaths( |
| | 22 | | string programDataPath, |
| | 23 | | string logDirectoryPath, |
| | 24 | | string configurationDirectoryPath, |
| | 25 | | string cacheDirectoryPath, |
| | 26 | | string webDirectoryPath) |
| | 27 | | { |
| | 28 | | ProgramDataPath = programDataPath; |
| | 29 | | LogDirectoryPath = logDirectoryPath; |
| | 30 | | ConfigurationDirectoryPath = configurationDirectoryPath; |
| 22 | 31 | | CachePath = cacheDirectoryPath; |
| | 32 | | WebPath = webDirectoryPath; |
| | 33 | |
|
| 22 | 34 | | DataPath = Directory.CreateDirectory(Path.Combine(ProgramDataPath, "data")).FullName; |
| 22 | 35 | | } |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Gets the path to the program data folder. |
| | 39 | | /// </summary> |
| | 40 | | /// <value>The program data path.</value> |
| | 41 | | public string ProgramDataPath { get; } |
| | 42 | |
|
| | 43 | | /// <inheritdoc/> |
| | 44 | | public string WebPath { get; } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Gets the path to the system folder. |
| | 48 | | /// </summary> |
| | 49 | | /// <value>The path to the system folder.</value> |
| | 50 | | public string ProgramSystemPath { get; } = AppContext.BaseDirectory; |
| | 51 | |
|
| | 52 | | /// <summary> |
| | 53 | | /// Gets the folder path to the data directory. |
| | 54 | | /// </summary> |
| | 55 | | /// <value>The data directory.</value> |
| | 56 | | public string DataPath { get; } |
| | 57 | |
|
| | 58 | | /// <inheritdoc /> |
| 145 | 59 | | public string VirtualDataPath => "%AppDataPath%"; |
| | 60 | |
|
| | 61 | | /// <summary> |
| | 62 | | /// Gets the image cache path. |
| | 63 | | /// </summary> |
| | 64 | | /// <value>The image cache path.</value> |
| 0 | 65 | | public string ImageCachePath => Path.Combine(CachePath, "images"); |
| | 66 | |
|
| | 67 | | /// <summary> |
| | 68 | | /// Gets the path to the plugin directory. |
| | 69 | | /// </summary> |
| | 70 | | /// <value>The plugins path.</value> |
| 308 | 71 | | public string PluginsPath => Path.Combine(ProgramDataPath, "plugins"); |
| | 72 | |
|
| | 73 | | /// <summary> |
| | 74 | | /// Gets the path to the plugin configurations directory. |
| | 75 | | /// </summary> |
| | 76 | | /// <value>The plugin configurations path.</value> |
| 132 | 77 | | public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations"); |
| | 78 | |
|
| | 79 | | /// <summary> |
| | 80 | | /// Gets the path to the log directory. |
| | 81 | | /// </summary> |
| | 82 | | /// <value>The log directory path.</value> |
| | 83 | | public string LogDirectoryPath { get; } |
| | 84 | |
|
| | 85 | | /// <summary> |
| | 86 | | /// Gets the path to the application configuration root directory. |
| | 87 | | /// </summary> |
| | 88 | | /// <value>The configuration directory path.</value> |
| | 89 | | public string ConfigurationDirectoryPath { get; } |
| | 90 | |
|
| | 91 | | /// <summary> |
| | 92 | | /// Gets the path to the system configuration file. |
| | 93 | | /// </summary> |
| | 94 | | /// <value>The system configuration file path.</value> |
| 62 | 95 | | public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml"); |
| | 96 | |
|
| | 97 | | /// <summary> |
| | 98 | | /// Gets or sets the folder path to the cache directory. |
| | 99 | | /// </summary> |
| | 100 | | /// <value>The cache directory.</value> |
| | 101 | | public string CachePath { get; set; } |
| | 102 | |
|
| | 103 | | /// <summary> |
| | 104 | | /// Gets the folder path to the temp directory within the cache folder. |
| | 105 | | /// </summary> |
| | 106 | | /// <value>The temp directory.</value> |
| 68 | 107 | | public string TempDirectory => Path.Join(Path.GetTempPath(), "jellyfin"); |
| | 108 | | } |
| | 109 | | } |