jellyfin/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs

112 lines
4.1 KiB
C#
Raw Normal View History

using System;
using System.IO;
2016-10-29 07:40:15 +02:00
using MediaBrowser.Common.Configuration;
2017-02-20 21:50:58 +01:00
namespace Emby.Server.Implementations.AppBase
2016-10-29 07:40:15 +02:00
{
/// <summary>
2020-03-15 12:59:34 +01:00
/// Provides a base class to hold common application paths used by both the UI and Server.
2016-10-29 07:40:15 +02:00
/// This can be subclassed to add application-specific paths.
/// </summary>
public abstract class BaseApplicationPaths : IApplicationPaths
{
2019-08-09 23:50:40 +02:00
private string _dataPath;
2016-10-29 07:40:15 +02:00
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
/// </summary>
/// <param name="programDataPath">The program data path.</param>
/// <param name="logDirectoryPath">The log directory path.</param>
/// <param name="configurationDirectoryPath">The configuration directory path.</param>
/// <param name="cacheDirectoryPath">The cache directory path.</param>
/// <param name="webDirectoryPath">The web directory path.</param>
2019-01-05 19:12:05 +01:00
protected BaseApplicationPaths(
string programDataPath,
string logDirectoryPath,
string configurationDirectoryPath,
string cacheDirectoryPath,
string webDirectoryPath)
2016-10-29 07:40:15 +02:00
{
ProgramDataPath = programDataPath;
2019-01-01 21:34:12 +01:00
LogDirectoryPath = logDirectoryPath;
2019-01-05 19:12:05 +01:00
ConfigurationDirectoryPath = configurationDirectoryPath;
2019-01-28 17:52:56 +01:00
CachePath = cacheDirectoryPath;
WebPath = webDirectoryPath;
_dataPath = Directory.CreateDirectory(Path.Combine(ProgramDataPath, "data")).FullName;
2016-10-29 07:40:15 +02:00
}
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the path to the program data folder.
/// </summary>
/// <value>The program data path.</value>
2019-08-09 23:50:40 +02:00
public string ProgramDataPath { get; }
2016-10-29 07:40:15 +02:00
/// <inheritdoc/>
2019-08-09 23:50:40 +02:00
public string WebPath { get; }
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the path to the system folder.
2016-10-29 07:40:15 +02:00
/// </summary>
2019-08-09 23:50:40 +02:00
/// <value>The path to the system folder.</value>
public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the folder path to the data directory.
2016-10-29 07:40:15 +02:00
/// </summary>
/// <value>The data directory.</value>
public string DataPath => _dataPath;
2016-10-29 07:40:15 +02:00
/// <inheritdoc />
2020-10-17 16:01:36 +02:00
public string VirtualDataPath => "%AppDataPath%";
2018-09-12 19:26:21 +02:00
2016-10-29 07:40:15 +02:00
/// <summary>
/// Gets the image cache path.
/// </summary>
/// <value>The image cache path.</value>
public string ImageCachePath => Path.Combine(CachePath, "images");
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the path to the plugin directory.
2016-10-29 07:40:15 +02:00
/// </summary>
/// <value>The plugins path.</value>
public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the path to the plugin configurations directory.
2016-10-29 07:40:15 +02:00
/// </summary>
/// <value>The plugin configurations path.</value>
public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the path to the log directory.
2016-10-29 07:40:15 +02:00
/// </summary>
/// <value>The log directory path.</value>
2019-08-09 23:50:40 +02:00
public string LogDirectoryPath { get; }
2019-01-05 19:12:05 +01:00
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the path to the application configuration root directory.
2016-10-29 07:40:15 +02:00
/// </summary>
/// <value>The configuration directory path.</value>
2019-08-09 23:50:40 +02:00
public string ConfigurationDirectoryPath { get; }
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the path to the system configuration file.
2016-10-29 07:40:15 +02:00
/// </summary>
/// <value>The system configuration file path.</value>
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets or sets the folder path to the cache directory.
2016-10-29 07:40:15 +02:00
/// </summary>
/// <value>The cache directory.</value>
public string CachePath { get; set; }
2016-10-29 07:40:15 +02:00
/// <summary>
2019-08-09 23:50:40 +02:00
/// Gets the folder path to the temp directory within the cache folder.
2016-10-29 07:40:15 +02:00
/// </summary>
/// <value>The temp directory.</value>
public string TempDirectory => Path.Combine(CachePath, "temp");
2016-10-29 07:40:15 +02:00
}
}