using System;
using System.IO;
using Emby.Server.Implementations.AppBase;
using MediaBrowser.Controller;
namespace Emby.Server.Implementations
{
///
/// Extends BaseApplicationPaths to add paths that are only applicable on the server
///
public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
{
///
/// Initializes a new instance of the class.
///
public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath, string logDirectoryPath = null)
: base(programDataPath, appFolderPath, logDirectoryPath)
{
ApplicationResourcesPath = applicationResourcesPath;
}
public string ApplicationResourcesPath { get; private set; }
///
/// 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");
}
}
///
/// Gets the path to the People directory
///
/// The people path.
public string PeoplePath
{
get
{
return Path.Combine(InternalMetadataPath, "People");
}
}
public string ArtistsPath
{
get
{
return Path.Combine(InternalMetadataPath, "artists");
}
}
///
/// Gets the path to the Genre directory
///
/// The genre path.
public string GenrePath
{
get
{
return Path.Combine(InternalMetadataPath, "Genre");
}
}
///
/// Gets the path to the Genre directory
///
/// The genre path.
public string MusicGenrePath
{
get
{
return Path.Combine(InternalMetadataPath, "MusicGenre");
}
}
///
/// Gets the path to the Studio directory
///
/// The studio path.
public string StudioPath
{
get
{
return Path.Combine(InternalMetadataPath, "Studio");
}
}
///
/// Gets the path to the Year directory
///
/// The year path.
public string YearPath
{
get
{
return Path.Combine(InternalMetadataPath, "Year");
}
}
///
/// Gets the path to the General IBN directory
///
/// The general path.
public string GeneralPath
{
get
{
return Path.Combine(InternalMetadataPath, "general");
}
}
///
/// Gets the path to the Ratings IBN directory
///
/// The ratings path.
public string RatingsPath
{
get
{
return Path.Combine(InternalMetadataPath, "ratings");
}
}
///
/// Gets the media info images path.
///
/// The media info images path.
public string MediaInfoImagesPath
{
get
{
return Path.Combine(InternalMetadataPath, "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 _defaultTranscodingTempPath;
public string DefaultTranscodingTempPath
{
get
{
return _defaultTranscodingTempPath ?? (_defaultTranscodingTempPath = Path.Combine(ProgramDataPath, "transcoding-temp"));
}
}
private string _transcodingTempPath;
public string TranscodingTempPath
{
get
{
return _transcodingTempPath ?? (_transcodingTempPath = DefaultTranscodingTempPath);
}
set
{
_transcodingTempPath = value;
}
}
public string GetTranscodingTempPath()
{
var path = TranscodingTempPath;
if (!string.Equals(path, DefaultTranscodingTempPath, StringComparison.OrdinalIgnoreCase))
{
try
{
Directory.CreateDirectory(path);
var testPath = Path.Combine(path, Guid.NewGuid().ToString());
Directory.CreateDirectory(testPath);
Directory.Delete(testPath);
return path;
}
catch
{
}
}
path = DefaultTranscodingTempPath;
Directory.CreateDirectory(path);
return path;
}
///
/// Gets the game genre path.
///
/// The game genre path.
public string GameGenrePath
{
get
{
return Path.Combine(InternalMetadataPath, "GameGenre");
}
}
private string _internalMetadataPath;
public string InternalMetadataPath
{
get
{
return _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
}
set
{
_internalMetadataPath = value;
}
}
private const string _virtualInternalMetadataPath = "%MetadataPath%";
public string VirtualInternalMetadataPath
{
get
{
return _virtualInternalMetadataPath;
}
}
}
}