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

51 lines
1.8 KiB
C#
Raw Normal View History

2017-09-19 04:21:26 +00:00
using System;
using System.IO;
using System.Reflection;
using NLog;
using NzbDrone.Common.Instrumentation;
namespace NzbDrone.Common.EnvironmentInfo
{
public interface IAppFolderInfo
{
string AppDataFolder { get; }
2017-09-19 04:21:26 +00:00
string LegacyAppDataFolder { get; }
string TempFolder { get; }
string StartUpFolder { get; }
}
public class AppFolderInfo : IAppFolderInfo
{
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
{
_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
{
AppDataFolder = Path.Combine(Environment.GetFolderPath(_dataSpecialFolder, Environment.SpecialFolderOption.DoNotVerify), "Sonarr");
LegacyAppDataFolder = Path.Combine(Environment.GetFolderPath(_dataSpecialFolder, Environment.SpecialFolderOption.DoNotVerify), "NzbDrone");
}
StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
TempFolder = Path.GetTempPath();
}
public string AppDataFolder { get; }
2017-09-19 04:21:26 +00:00
public string LegacyAppDataFolder { get; }
public string StartUpFolder { get; }
public string TempFolder { get; }
}
2017-09-19 04:21:26 +00:00
}