2013-07-05 04:43:28 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
2014-12-17 22:44:02 +00:00
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
2013-07-05 04:43:28 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Common.EnvironmentInfo
|
|
|
|
|
{
|
|
|
|
|
public interface IAppFolderInfo
|
|
|
|
|
{
|
|
|
|
|
string AppDataFolder { get; }
|
|
|
|
|
string TempFolder { get; }
|
|
|
|
|
string StartUpFolder { get; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AppFolderInfo : IAppFolderInfo
|
|
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
|
private readonly Environment.SpecialFolder _dataSpecialFolder = Environment.SpecialFolder.CommonApplicationData;
|
2013-07-26 06:48:35 +00:00
|
|
|
|
|
2014-12-17 22:44:02 +00:00
|
|
|
|
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(AppFolderInfo));
|
|
|
|
|
|
2014-01-06 06:20:08 +00:00
|
|
|
|
public AppFolderInfo(IStartupContext startupContext)
|
2013-07-27 04:53:05 +00:00
|
|
|
|
{
|
2014-12-07 20:54:07 +00:00
|
|
|
|
if (OsInfo.IsNotWindows)
|
2013-07-27 04:53:05 +00:00
|
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
|
_dataSpecialFolder = Environment.SpecialFolder.ApplicationData;
|
2013-07-27 04:53:05 +00:00
|
|
|
|
}
|
2013-06-19 21:08:56 +00:00
|
|
|
|
|
2013-11-26 06:53:36 +00:00
|
|
|
|
if (startupContext.Args.ContainsKey(StartupContext.APPDATA))
|
2013-08-13 05:08:37 +00:00
|
|
|
|
{
|
2013-11-26 06:53:36 +00:00
|
|
|
|
AppDataFolder = startupContext.Args[StartupContext.APPDATA];
|
2014-12-17 22:44:02 +00:00
|
|
|
|
Logger.Info("Data directory is being overridden to [{0}]", AppDataFolder);
|
2013-08-13 05:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
|
AppDataFolder = Path.Combine(Environment.GetFolderPath(_dataSpecialFolder, Environment.SpecialFolderOption.DoNotVerify), "Radarr");
|
2013-08-13 05:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 06:48:35 +00:00
|
|
|
|
StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
|
|
|
|
|
TempFolder = Path.GetTempPath();
|
2013-07-05 06:30:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
|
public string AppDataFolder { get; private set; }
|
|
|
|
|
|
|
|
|
|
public string StartUpFolder { get; private set; }
|
|
|
|
|
|
2015-10-03 17:45:26 +00:00
|
|
|
|
public string TempFolder { get; private set; }
|
2013-07-05 04:43:28 +00:00
|
|
|
|
}
|
2019-10-14 21:42:30 +00:00
|
|
|
|
}
|