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