Added PhysicalFileSystem constructor overload to work out the rootPath / rootUrl from a virtualRoot path (Can only work with a valid HttpContext)

This commit is contained in:
Matt@MBP13-PC
2012-08-13 10:23:45 -01:00
parent d2ac9158c6
commit ad291265f3

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
namespace Umbraco.Core.IO
{
@@ -11,6 +12,15 @@ namespace Umbraco.Core.IO
private readonly string _rootPath;
private readonly string _rootUrl;
public PhysicalFileSystem(string virtualRoot)
{
if(HttpContext.Current == null)
throw new InvalidOperationException("The single parameter constructor can only be accessed when there is a valid HttpContext");
_rootPath = HttpContext.Current.Server.MapPath(virtualRoot);
_rootUrl = VirtualPathUtility.ToAbsolute(virtualRoot);
}
public PhysicalFileSystem(string rootPath, string rootUrl)
{
if (string.IsNullOrEmpty(rootPath))