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()
: base(true)
{
}
#else
///
/// Initializes a new instance of the class.
///
public ServerApplicationPaths()
: base(false)
{
}
#endif
///
/// The _root folder path
///
private string _rootFolderPath;
///
/// Gets the path to the base root media directory
///
/// The root folder path.
public string RootFolderPath
{
get
{
if (_rootFolderPath == null)
{
_rootFolderPath = Path.Combine(ProgramDataPath, "Root");
if (!Directory.Exists(_rootFolderPath))
{
Directory.CreateDirectory(_rootFolderPath);
}
}
return _rootFolderPath;
}
}
///
/// The _default user views path
///
private string _defaultUserViewsPath;
///
/// 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
{
if (_defaultUserViewsPath == null)
{
_defaultUserViewsPath = Path.Combine(RootFolderPath, "Default");
if (!Directory.Exists(_defaultUserViewsPath))
{
Directory.CreateDirectory(_defaultUserViewsPath);
}
}
return _defaultUserViewsPath;
}
}
///
/// The _localization path
///
private string _localizationPath;
///
/// Gets the path to localization data.
///
/// The localization path.
public string LocalizationPath
{
get
{
if (_localizationPath == null)
{
_localizationPath = Path.Combine(ProgramDataPath, "Localization");
if (!Directory.Exists(_localizationPath))
{
Directory.CreateDirectory(_localizationPath);
}
}
return _localizationPath;
}
}
///
/// The _ibn path
///
private string _ibnPath;
///
/// Gets the path to the Images By Name directory
///
/// The images by name path.
public string ItemsByNamePath
{
get
{
if (_ibnPath == null)
{
_ibnPath = Path.Combine(ProgramDataPath, "ImagesByName");
if (!Directory.Exists(_ibnPath))
{
Directory.CreateDirectory(_ibnPath);
}
}
return _ibnPath;
}
set
{
_ibnPath = value;
_peoplePath = null;
_studioPath = null;
_genrePath = null;
_yearPath = null;
_musicArtistsPath = null;
_generalPath = null;
_ratingsPath = null;
_mediaInfoImagesPath = null;
}
}
///
/// The _people path
///
private string _peoplePath;
///
/// Gets the path to the People directory
///
/// The people path.
public string PeoplePath
{
get
{
if (_peoplePath == null)
{
_peoplePath = Path.Combine(ItemsByNamePath, "People");
if (!Directory.Exists(_peoplePath))
{
Directory.CreateDirectory(_peoplePath);
}
}
return _peoplePath;
}
}
///
/// The _genre path
///
private string _genrePath;
///
/// Gets the path to the Genre directory
///
/// The genre path.
public string GenrePath
{
get
{
if (_genrePath == null)
{
_genrePath = Path.Combine(ItemsByNamePath, "Genre");
if (!Directory.Exists(_genrePath))
{
Directory.CreateDirectory(_genrePath);
}
}
return _genrePath;
}
}
///
/// The _studio path
///
private string _studioPath;
///
/// Gets the path to the Studio directory
///
/// The studio path.
public string StudioPath
{
get
{
if (_studioPath == null)
{
_studioPath = Path.Combine(ItemsByNamePath, "Studio");
if (!Directory.Exists(_studioPath))
{
Directory.CreateDirectory(_studioPath);
}
}
return _studioPath;
}
}
///
/// The _year path
///
private string _yearPath;
///
/// Gets the path to the Year directory
///
/// The year path.
public string YearPath
{
get
{
if (_yearPath == null)
{
_yearPath = Path.Combine(ItemsByNamePath, "Year");
if (!Directory.Exists(_yearPath))
{
Directory.CreateDirectory(_yearPath);
}
}
return _yearPath;
}
}
///
/// The _general path
///
private string _generalPath;
///
/// Gets the path to the General IBN directory
///
/// The general path.
public string GeneralPath
{
get
{
if (_generalPath == null)
{
_generalPath = Path.Combine(ItemsByNamePath, "General");
if (!Directory.Exists(_generalPath))
{
Directory.CreateDirectory(_generalPath);
}
}
return _generalPath;
}
}
///
/// The _ratings path
///
private string _ratingsPath;
///
/// Gets the path to the Ratings IBN directory
///
/// The ratings path.
public string RatingsPath
{
get
{
if (_ratingsPath == null)
{
_ratingsPath = Path.Combine(ItemsByNamePath, "Ratings");
if (!Directory.Exists(_ratingsPath))
{
Directory.CreateDirectory(_ratingsPath);
}
}
return _ratingsPath;
}
}
///
/// The _media info images path
///
private string _mediaInfoImagesPath;
///
/// Gets the media info images path.
///
/// The media info images path.
public string MediaInfoImagesPath
{
get
{
if (_mediaInfoImagesPath == null)
{
_mediaInfoImagesPath = Path.Combine(ItemsByNamePath, "MediaInfo");
if (!Directory.Exists(_mediaInfoImagesPath))
{
Directory.CreateDirectory(_mediaInfoImagesPath);
}
}
return _mediaInfoImagesPath;
}
}
///
/// The _user configuration directory path
///
private string _userConfigurationDirectoryPath;
///
/// Gets the path to the user configuration directory
///
/// The user configuration directory path.
public string UserConfigurationDirectoryPath
{
get
{
if (_userConfigurationDirectoryPath == null)
{
_userConfigurationDirectoryPath = Path.Combine(ConfigurationDirectoryPath, "users");
if (!Directory.Exists(_userConfigurationDirectoryPath))
{
Directory.CreateDirectory(_userConfigurationDirectoryPath);
}
}
return _userConfigurationDirectoryPath;
}
}
///
/// The _f F MPEG stream cache path
///
private string _fFMpegStreamCachePath;
///
/// Gets the FF MPEG stream cache path.
///
/// The FF MPEG stream cache path.
public string EncodedMediaCachePath
{
get
{
if (_fFMpegStreamCachePath == null)
{
_fFMpegStreamCachePath = Path.Combine(CachePath, "encoded-media");
if (!Directory.Exists(_fFMpegStreamCachePath))
{
Directory.CreateDirectory(_fFMpegStreamCachePath);
}
}
return _fFMpegStreamCachePath;
}
}
///
/// The _images data path
///
private string _downloadedImagesDataPath;
///
/// Gets the images data path.
///
/// The images data path.
public string DownloadedImagesDataPath
{
get
{
if (_downloadedImagesDataPath == null)
{
_downloadedImagesDataPath = Path.Combine(DataPath, "remote-images");
if (!Directory.Exists(_downloadedImagesDataPath))
{
Directory.CreateDirectory(_downloadedImagesDataPath);
}
}
return _downloadedImagesDataPath;
}
}
///
/// The _music artists path
///
private string _musicArtistsPath;
///
/// Gets the artists path.
///
/// The artists path.
public string ArtistsPath
{
get
{
if (_musicArtistsPath == null)
{
_musicArtistsPath = Path.Combine(ItemsByNamePath, "Artists");
if (!Directory.Exists(_musicArtistsPath))
{
Directory.CreateDirectory(_musicArtistsPath);
}
}
return _musicArtistsPath;
}
}
}
}