You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
2.9 KiB
122 lines
2.9 KiB
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";
|
|
|
|
private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update";
|
|
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup";
|
|
|
|
private readonly string _applicationPath;
|
|
|
|
|
|
public PathProvider(EnviromentProvider enviromentProvider)
|
|
{
|
|
_applicationPath = enviromentProvider.ApplicationPath;
|
|
}
|
|
|
|
public PathProvider()
|
|
{
|
|
|
|
}
|
|
|
|
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"); }
|
|
}
|
|
|
|
public virtual string UpdateSandboxFolder
|
|
{
|
|
get { return Path.Combine(SystemTemp, UPDATE_SANDBOX_FOLDER_NAME); }
|
|
}
|
|
|
|
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); }
|
|
}
|
|
}
|
|
} |