2019-02-13 08:35:14 -07:00
|
|
|
using System;
|
2019-01-13 12:54:44 -07:00
|
|
|
using System.IO;
|
2016-10-28 22:40:15 -07:00
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
2017-02-20 13:50:58 -07:00
|
|
|
namespace Emby.Server.Implementations.AppBase
|
2016-10-28 22:40:15 -07: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
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
|
|
|
|
/// </summary>
|
2019-01-05 11:12:05 -07:00
|
|
|
protected BaseApplicationPaths(
|
|
|
|
string programDataPath,
|
2019-02-13 08:35:14 -07:00
|
|
|
string logDirectoryPath,
|
|
|
|
string configurationDirectoryPath,
|
2019-03-10 13:17:48 -07:00
|
|
|
string cacheDirectoryPath,
|
|
|
|
string webDirectoryPath)
|
2016-10-28 22:40:15 -07:00
|
|
|
{
|
|
|
|
ProgramDataPath = programDataPath;
|
2019-01-01 13:34:12 -07:00
|
|
|
LogDirectoryPath = logDirectoryPath;
|
2019-01-05 11:12:05 -07:00
|
|
|
ConfigurationDirectoryPath = configurationDirectoryPath;
|
2019-01-28 09:52:56 -07:00
|
|
|
CachePath = cacheDirectoryPath;
|
2019-03-10 13:17:48 -07:00
|
|
|
WebPath = webDirectoryPath;
|
2019-02-13 08:35:14 -07:00
|
|
|
|
|
|
|
DataPath = Path.Combine(ProgramDataPath, "data");
|
2016-10-28 22:40:15 -07:00
|
|
|
}
|
|
|
|
|
2019-02-13 08:35:14 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the path to the program data folder
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The program data path.</value>
|
2016-10-28 22:40:15 -07:00
|
|
|
public string ProgramDataPath { get; private set; }
|
|
|
|
|
2019-03-10 14:04:18 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the path to the web resources folder
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The web resources path.</value>
|
|
|
|
public string WebPath { get; set; }
|
|
|
|
|
2016-10-28 22:40:15 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the path to the system folder
|
|
|
|
/// </summary>
|
2019-02-13 08:35:14 -07:00
|
|
|
public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
|
2016-10-28 22:40:15 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the folder path to the data directory
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The data directory.</value>
|
2019-02-13 08:35:14 -07:00
|
|
|
private string _dataPath;
|
2016-10-28 22:40:15 -07:00
|
|
|
public string DataPath
|
|
|
|
{
|
2019-02-13 08:35:14 -07:00
|
|
|
get => _dataPath;
|
|
|
|
private set => _dataPath = Directory.CreateDirectory(value).FullName;
|
2016-10-28 22:40:15 -07:00
|
|
|
}
|
|
|
|
|
2019-02-13 08:35:14 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the magic strings used for virtual path manipulation.
|
|
|
|
/// </summary>
|
|
|
|
public string VirtualDataPath { get; } = "%AppDataPath%";
|
2018-09-12 10:26:21 -07:00
|
|
|
|
2016-10-28 22:40:15 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the image cache path.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The image cache path.</value>
|
2019-01-06 13:50:43 -07:00
|
|
|
public string ImageCachePath => Path.Combine(CachePath, "images");
|
2016-10-28 22:40:15 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the path to the plugin directory
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The plugins path.</value>
|
2019-01-06 13:50:43 -07:00
|
|
|
public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
|
2016-10-28 22:40:15 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the path to the plugin configurations directory
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The plugin configurations path.</value>
|
2019-01-06 13:50:43 -07:00
|
|
|
public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
|
2016-10-28 22:40:15 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the path to the log directory
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The log directory path.</value>
|
2019-02-13 08:35:14 -07:00
|
|
|
public string LogDirectoryPath { get; private set; }
|
2019-01-05 11:12:05 -07:00
|
|
|
|
2016-10-28 22:40:15 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the path to the application configuration root directory
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The configuration directory path.</value>
|
2019-02-13 08:35:14 -07:00
|
|
|
public string ConfigurationDirectoryPath { get; private set; }
|
2016-10-28 22:40:15 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the path to the system configuration file
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The system configuration file path.</value>
|
2019-01-06 13:50:43 -07:00
|
|
|
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
|
2016-10-28 22:40:15 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the folder path to the cache directory
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The cache directory.</value>
|
2019-02-13 08:35:14 -07:00
|
|
|
public string CachePath { get; set; }
|
2016-10-28 22:40:15 -07:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the folder path to the temp directory within the cache folder
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The temp directory.</value>
|
2019-01-06 13:50:43 -07:00
|
|
|
public string TempDirectory => Path.Combine(CachePath, "temp");
|
2016-10-28 22:40:15 -07:00
|
|
|
}
|
|
|
|
}
|