using System;
using MediaBrowser.Common.Implementations;
using MediaBrowser.Controller;
using System.IO;
namespace MediaBrowser.Server.Implementations
{
    /// 
    /// Extends BaseApplicationPaths to add paths that are only applicable on the server
    /// 
    public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
    {
#if (DEBUG)
        /// 
        /// Initializes a new instance of the  class.
        /// 
        public ServerApplicationPaths(string applicationPath)
            : base(true, applicationPath)
        {
        }
#else
/// 
/// Initializes a new instance of the  class.
/// 
        public ServerApplicationPaths(string applicationPath)
            : base(false, applicationPath)
        {
        }
#endif
        /// 
        /// Initializes a new instance of the  class.
        /// 
        public ServerApplicationPaths(string programDataPath, string applicationPath)
            : base(programDataPath, applicationPath)
        {
        }
        /// 
        /// Gets the path to the base root media directory
        /// 
        /// The root folder path.
        public string RootFolderPath
        {
            get
            {
                return Path.Combine(ProgramDataPath, "root");
            }
        }
        /// 
        /// Gets the path to the default user view directory.  Used if no specific user view is defined.
        /// 
        /// The default user views path.
        public string DefaultUserViewsPath
        {
            get
            {
                return Path.Combine(RootFolderPath, "default");
            }
        }
        /// 
        /// Gets the path to localization data.
        /// 
        /// The localization path.
        public string LocalizationPath
        {
            get
            {
                return Path.Combine(ProgramDataPath, "localization");
            }
        }
        /// 
        /// The _ibn path
        /// 
        private string _ibnPath;
        /// 
        /// Gets the path to the Images By Name directory
        /// 
        /// The images by name path.
        public string ItemsByNamePath
        {
            get
            {
                return _ibnPath ?? (_ibnPath = Path.Combine(ProgramDataPath, "ImagesByName"));
            }
            set
            {
                _ibnPath = value;
            }
        }
        /// 
        /// Gets the path to the People directory
        /// 
        /// The people path.
        public string PeoplePath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "People");
            }
        }
        /// 
        /// Gets the path to the Genre directory
        /// 
        /// The genre path.
        public string GenrePath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "Genre");
            }
        }
        /// 
        /// Gets the path to the Genre directory
        /// 
        /// The genre path.
        public string MusicGenrePath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "MusicGenre");
            }
        }
        /// 
        /// Gets the path to the Studio directory
        /// 
        /// The studio path.
        public string StudioPath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "Studio");
            }
        }
        /// 
        /// Gets the path to the Year directory
        /// 
        /// The year path.
        public string YearPath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "Year");
            }
        }
        /// 
        /// Gets the path to the General IBN directory
        /// 
        /// The general path.
        public string GeneralPath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "general");
            }
        }
        /// 
        /// Gets the path to the Ratings IBN directory
        /// 
        /// The ratings path.
        public string RatingsPath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "ratings");
            }
        }
        /// 
        /// Gets the media info images path.
        /// 
        /// The media info images path.
        public string MediaInfoImagesPath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "mediainfo");
            }
        }
        /// 
        /// Gets the path to the user configuration directory
        /// 
        /// The user configuration directory path.
        public string UserConfigurationDirectoryPath
        {
            get
            {
                return Path.Combine(ConfigurationDirectoryPath, "users");
            }
        }
        private string _transcodingTempPath;
        public string TranscodingTempPath
        {
            get
            {
                return _transcodingTempPath ?? (_transcodingTempPath = Path.Combine(ProgramDataPath, "transcoding-temp"));
            }
            set
            {
                _transcodingTempPath = value;
            }
        }
        /// 
        /// Gets the artists path.
        /// 
        /// The artists path.
        public string ArtistsPath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "artists");
            }
        }
        /// 
        /// Gets the game genre path.
        /// 
        /// The game genre path.
        public string GameGenrePath
        {
            get
            {
                return Path.Combine(ItemsByNamePath, "GameGenre");
            }
        }
        public string InternalMetadataPath
        {
            get
            {
                return Path.Combine(DataPath, "metadata");
            }
        }
        public string GetInternalMetadataPath(Guid id)
        {
            var idString = id.ToString("N");
            return Path.Combine(InternalMetadataPath, idString.Substring(0, 2), idString);
        }
    }
}