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.
        /// 
        /// The program data path.
        /// The log directory path.
        /// The configuration directory path.
        /// The cache directory path.
        /// The web directory path.
        protected BaseApplicationPaths(
            string programDataPath,
            string logDirectoryPath,
            string configurationDirectoryPath,
            string cacheDirectoryPath,
            string webDirectoryPath)
        {
            ProgramDataPath = programDataPath;
            LogDirectoryPath = logDirectoryPath;
            ConfigurationDirectoryPath = configurationDirectoryPath;
            CachePath = cacheDirectoryPath;
            WebPath = webDirectoryPath;
            DataPath = Directory.CreateDirectory(Path.Combine(ProgramDataPath, "data")).FullName;
        }
        /// 
        /// Gets the path to the program data folder.
        /// 
        /// The program data path.
        public string ProgramDataPath { get; }
        /// 
        public string WebPath { get; }
        /// 
        /// Gets the path to the system folder.
        /// 
        /// The path to the system folder.
        public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
        /// 
        /// Gets the folder path to the data directory.
        /// 
        /// The data directory.
        public string DataPath { get; }
        /// 
        public string VirtualDataPath => "%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; }
        /// 
        /// Gets the path to the application configuration root directory.
        /// 
        /// The configuration directory path.
        public string ConfigurationDirectoryPath { get; }
        /// 
        /// Gets the path to the system configuration file.
        /// 
        /// The system configuration file path.
        public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
        /// 
        /// Gets or sets 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");
    }
}