Lidarr/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs

31 lines
903 B
C#
Raw Normal View History

2013-07-28 23:13:14 +00:00
using System.IO;
using NLog;
2013-07-28 23:13:14 +00:00
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
namespace NzbDrone.Api.Frontend.Mappers
2013-07-28 23:13:14 +00:00
{
public class LogFileMapper : StaticResourceMapperBase
2013-07-28 23:13:14 +00:00
{
private readonly IAppFolderInfo _appFolderInfo;
public LogFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger)
: base(diskProvider, logger)
2013-07-28 23:13:14 +00:00
{
_appFolderInfo = appFolderInfo;
}
protected override string Map(string resourceUrl)
2013-07-28 23:13:14 +00:00
{
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
path = Path.GetFileName(path);
return Path.Combine(_appFolderInfo.GetLogFolder(), path);
}
public override bool CanHandle(string resourceUrl)
2013-07-28 23:13:14 +00:00
{
return resourceUrl.StartsWith("/log") && resourceUrl.EndsWith(".txt");
2013-07-28 23:13:14 +00:00
}
}
}