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.
Sonarr/src/NzbDrone.Common/EnvironmentInfo/AppFolderInfo.cs

51 lines
1.8 KiB

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 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)
{
if (OsInfo.IsNotWindows)
{
_dataSpecialFolder = Environment.SpecialFolder.ApplicationData;
}
if (startupContext.Args.ContainsKey(StartupContext.APPDATA))
{
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; }
public string LegacyAppDataFolder { get; }
public string StartUpFolder { get; }
public string TempFolder { get; }
}
}