From ad291265f35ffb9bae060aa41bec90d5a9c3d6f2 Mon Sep 17 00:00:00 2001 From: "Matt@MBP13-PC" Date: Mon, 13 Aug 2012 10:23:45 -0100 Subject: [PATCH] Added PhysicalFileSystem constructor overload to work out the rootPath / rootUrl from a virtualRoot path (Can only work with a valid HttpContext) --- src/Umbraco.Core/IO/PhysicalFileSystem.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index 6f7fab4521..30398c5e04 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -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))