sonarr-repo-only/NzbDrone.Common/PathProvider.cs

122 lines
2.9 KiB
C#
Raw Normal View History

using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace NzbDrone.Common
{
public class PathProvider
{
private const string WEB_FOLDER = "NzbDrone.Web";
private const string APP_DATA = "App_Data";
private const string LOG_CONFIG_FILE = "log.config";
private const string APP_CONFIG_FILE = "config.xml";
private const string NZBDRONE_DB_FILE = "nzbdrone.sdf";
private const string LOG_DB_FILE = "log.sdf";
2011-11-13 04:07:06 +00:00
private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update";
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup";
private readonly string _applicationPath;
2011-11-13 04:07:06 +00:00
public PathProvider(EnviromentProvider enviromentProvider)
{
_applicationPath = enviromentProvider.ApplicationPath;
}
public PathProvider()
{
2011-11-13 04:07:06 +00:00
}
public virtual String LogPath
{
get { return Environment.CurrentDirectory; }
}
public virtual string WebRoot
{
get
{
return Path.Combine(_applicationPath, WEB_FOLDER);
}
}
public virtual string AppData
{
get
{
var path = Path.Combine(WebRoot, APP_DATA);
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
return path;
}
}
public virtual string NzbDronoeDbFile
{
get
{
return Path.Combine(AppData, NZBDRONE_DB_FILE);
}
}
public virtual string LogDbFile
{
get
{
return Path.Combine(AppData, LOG_DB_FILE);
}
}
public virtual String SystemTemp
{
get
{
return Path.GetTempPath();
}
}
public string LogConfigFile
{
get { return Path.Combine(WebRoot, LOG_CONFIG_FILE); }
}
public string AppConfigFile
{
get { return Path.Combine(_applicationPath, APP_CONFIG_FILE); }
}
public string BannerPath
{
get { return Path.Combine(WebRoot, "Content", "Images", "Banners"); }
}
public string CacheFolder
{
get { return Path.Combine(AppData, "Cache"); }
}
2011-11-13 04:07:06 +00:00
public virtual string UpdateSandboxFolder
{
get { return Path.Combine(SystemTemp, UPDATE_SANDBOX_FOLDER_NAME); }
}
2011-11-13 04:07:06 +00:00
public virtual string UpdatePackageFolder
{
get { return Path.Combine(UPDATE_SANDBOX_FOLDER_NAME, "NzbDrone"); }
}
public virtual string UpdateBackUpFolder
{
get { return Path.Combine(UpdateSandboxFolder, UPDATE_BACKUP_FOLDER_NAME); }
}
}
}