Radarr/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs

50 lines
1.6 KiB
C#
Raw Permalink Normal View History

using System;
using System.IO;
using System.Reflection;
using NLog;
using NzbDrone.Common.Instrumentation;
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;
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(AppFolderInfo));
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-11-26 06:53:36 +00:00
AppDataFolder = startupContext.Args[StartupContext.APPDATA];
Logger.Info("Data directory is being overridden to [{0}]", AppDataFolder);
}
else
{
2019-12-22 22:08:53 +00:00
AppDataFolder = Path.Combine(Environment.GetFolderPath(_dataSpecialFolder, Environment.SpecialFolderOption.DoNotVerify), "Radarr");
}
StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
TempFolder = Path.GetTempPath();
}
public string AppDataFolder { get; private set; }
public string StartUpFolder { get; private set; }
public string TempFolder { get; private set; }
}
}