using System;
using System.IO;
using MediaBrowser.Common.Configuration;
namespace Emby.Server.Implementations.AppBase
{
///
/// 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.
///
public abstract class BaseApplicationPaths : IApplicationPaths
{
///
/// Initializes a new instance of the class.
///
protected BaseApplicationPaths(
string programDataPath,
string logDirectoryPath,
string configurationDirectoryPath,
string cacheDirectoryPath,
string webDirectoryPath)
{
ProgramDataPath = programDataPath;
LogDirectoryPath = logDirectoryPath;
ConfigurationDirectoryPath = configurationDirectoryPath;
CachePath = cacheDirectoryPath;
WebPath = webDirectoryPath;
DataPath = Path.Combine(ProgramDataPath, "data");
}
///
/// Gets the path to the program data folder
///
/// The program data path.
public string ProgramDataPath { get; private set; }
///
/// Gets the path to the web UI resources folder
///
/// The web UI resources path.
public string WebPath { get; set; }
///
/// Gets the path to the system folder
///
public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
///
/// Gets the folder path to the data directory
///
/// The data directory.
private string _dataPath;
public string DataPath
{
get => _dataPath;
private set => _dataPath = Directory.CreateDirectory(value).FullName;
}
///
/// Gets the magic strings used for virtual path manipulation.
///
public string VirtualDataPath { get; } = "%AppDataPath%";
///
/// Gets the image cache path.
///
/// The image cache path.
public string ImageCachePath => Path.Combine(CachePath, "images");
///
/// Gets the path to the plugin directory
///
/// The plugins path.
public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
///
/// Gets the path to the plugin configurations directory
///
/// The plugin configurations path.
public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
///
/// Gets the path to the log directory
///
/// The log directory path.
public string LogDirectoryPath { get; private set; }
///
/// Gets the path to the application configuration root directory
///
/// The configuration directory path.
public string ConfigurationDirectoryPath { get; private set; }
///
/// Gets the path to the system configuration file
///
/// The system configuration file path.
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
///
/// Gets the folder path to the cache directory
///
/// The cache directory.
public string CachePath { get; set; }
///
/// Gets the folder path to the temp directory within the cache folder
///
/// The temp directory.
public string TempDirectory => Path.Combine(CachePath, "temp");
}
}