merged
This commit is contained in:
@@ -52,7 +52,7 @@ namespace Umbraco.Core.IO
|
||||
/// <para>If an <paramref name="oldpath"/> is provided then that file (and associated thumbnails if any) is deleted
|
||||
/// before the new file is saved, and depending on the media path scheme, the folder may be reused for the new file.</para>
|
||||
/// </remarks>
|
||||
string StoreFile(IContentBase content, PropertyType propertyType, string filename, Stream filestream, string oldpath);
|
||||
string StoreFile(IContentBase content, IPropertyType propertyType, string filename, Stream filestream, string oldpath);
|
||||
|
||||
/// <summary>
|
||||
/// Copies a media file as a new media file, associated to a property of a content item.
|
||||
@@ -61,6 +61,6 @@ namespace Umbraco.Core.IO
|
||||
/// <param name="propertyType">The property type owning the copy of the media file.</param>
|
||||
/// <param name="sourcepath">The filesystem-relative path to the source media file.</param>
|
||||
/// <returns>The filesystem-relative path to the copy of the media file.</returns>
|
||||
string CopyFile(IContentBase content, PropertyType propertyType, string sourcepath);
|
||||
string CopyFile(IContentBase content, IPropertyType propertyType, string sourcepath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using System.IO.Compression;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
@@ -15,6 +14,7 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
internal static IIOHelper Default { get; } = new IOHelper();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value forcing Umbraco to consider it is non-hosted.
|
||||
/// </summary>
|
||||
@@ -39,10 +39,10 @@ namespace Umbraco.Core.IO
|
||||
string retval = virtualPath;
|
||||
|
||||
if (virtualPath.StartsWith("~"))
|
||||
retval = virtualPath.Replace("~", SystemDirectories.Root);
|
||||
retval = virtualPath.Replace("~", Root);
|
||||
|
||||
if (virtualPath.StartsWith("/") && virtualPath.StartsWith(SystemDirectories.Root) == false)
|
||||
retval = SystemDirectories.Root + "/" + virtualPath.TrimStart('/');
|
||||
if (virtualPath.StartsWith("/") && virtualPath.StartsWith(Root) == false)
|
||||
retval = Root + "/" + virtualPath.TrimStart('/');
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -57,11 +57,11 @@ namespace Umbraco.Core.IO
|
||||
public string ResolveUrl(string virtualPath)
|
||||
{
|
||||
if (virtualPath.StartsWith("~"))
|
||||
return virtualPath.Replace("~", SystemDirectories.Root).Replace("//", "/");
|
||||
return virtualPath.Replace("~", Root).Replace("//", "/");
|
||||
else if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
|
||||
return virtualPath;
|
||||
else
|
||||
return VirtualPathUtility.ToAbsolute(virtualPath, SystemDirectories.Root);
|
||||
return VirtualPathUtility.ToAbsolute(virtualPath, Root);
|
||||
}
|
||||
|
||||
public Attempt<string> TryResolveUrl(string virtualPath)
|
||||
@@ -69,10 +69,10 @@ namespace Umbraco.Core.IO
|
||||
try
|
||||
{
|
||||
if (virtualPath.StartsWith("~"))
|
||||
return Attempt.Succeed(virtualPath.Replace("~", SystemDirectories.Root).Replace("//", "/"));
|
||||
return Attempt.Succeed(virtualPath.Replace("~", Root).Replace("//", "/"));
|
||||
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
|
||||
return Attempt.Succeed(virtualPath);
|
||||
return Attempt.Succeed(VirtualPathUtility.ToAbsolute(virtualPath, SystemDirectories.Root));
|
||||
return Attempt.Succeed(VirtualPathUtility.ToAbsolute(virtualPath, Root));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Core.IO
|
||||
if (useHttpContext && HttpContext.Current != null)
|
||||
{
|
||||
//string retval;
|
||||
if (String.IsNullOrEmpty(path) == false && (path.StartsWith("~") || path.StartsWith(SystemDirectories.Root)))
|
||||
if (String.IsNullOrEmpty(path) == false && (path.StartsWith("~") || path.StartsWith(Root)))
|
||||
return HostingEnvironment.MapPath(path);
|
||||
else
|
||||
return HostingEnvironment.MapPath("~/" + path.TrimStart('/'));
|
||||
@@ -115,22 +115,7 @@ namespace Umbraco.Core.IO
|
||||
return MapPath(path, true);
|
||||
}
|
||||
|
||||
//use a tilde character instead of the complete path
|
||||
public string ReturnPath(string settingsKey, string standardPath, bool useTilde)
|
||||
{
|
||||
var retval = ConfigurationManager.AppSettings[settingsKey];
|
||||
|
||||
if (string.IsNullOrEmpty(retval))
|
||||
retval = standardPath;
|
||||
|
||||
return retval.TrimEnd('/');
|
||||
}
|
||||
|
||||
public string ReturnPath(string settingsKey, string standardPath)
|
||||
{
|
||||
return ReturnPath(settingsKey, standardPath, false);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the current filepath matches a directory where the user is allowed to edit a file.
|
||||
@@ -160,7 +145,7 @@ namespace Umbraco.Core.IO
|
||||
// TODO: what's below is dirty, there are too many ways to get the root dir, etc.
|
||||
// not going to fix everything today
|
||||
|
||||
var mappedRoot = MapPath(SystemDirectories.Root);
|
||||
var mappedRoot = MapPath(Root);
|
||||
if (filePath.StartsWith(mappedRoot) == false)
|
||||
filePath = MapPath(filePath);
|
||||
|
||||
@@ -304,5 +289,27 @@ namespace Umbraco.Core.IO
|
||||
return path.EnsurePathIsApplicationRootPrefixed();
|
||||
}
|
||||
|
||||
private string _root;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root path of the application
|
||||
/// </summary>
|
||||
public string Root
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_root != null) return _root;
|
||||
|
||||
var appPath = HttpRuntime.AppDomainAppVirtualPath;
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
if (appPath == null || appPath == "/") appPath = string.Empty;
|
||||
|
||||
_root = appPath;
|
||||
|
||||
return _root;
|
||||
}
|
||||
//Only required for unit tests
|
||||
set => _root = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Umbraco.Core.IO
|
||||
#region Associated Media Files
|
||||
|
||||
/// <inheritoc />
|
||||
public string StoreFile(IContentBase content, PropertyType propertyType, string filename, Stream filestream, string oldpath)
|
||||
public string StoreFile(IContentBase content, IPropertyType propertyType, string filename, Stream filestream, string oldpath)
|
||||
{
|
||||
if (content == null) throw new ArgumentNullException(nameof(content));
|
||||
if (propertyType == null) throw new ArgumentNullException(nameof(propertyType));
|
||||
@@ -109,7 +109,7 @@ namespace Umbraco.Core.IO
|
||||
}
|
||||
|
||||
/// <inheritoc />
|
||||
public string CopyFile(IContentBase content, PropertyType propertyType, string sourcepath)
|
||||
public string CopyFile(IContentBase content, IPropertyType propertyType, string sourcepath)
|
||||
{
|
||||
if (content == null) throw new ArgumentNullException(nameof(content));
|
||||
if (propertyType == null) throw new ArgumentNullException(nameof(propertyType));
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
internal class ShadowWrapper : IFileSystem
|
||||
{
|
||||
private static readonly string ShadowFsPath = SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs";
|
||||
private static readonly string ShadowFsPath = Constants.SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs";
|
||||
|
||||
private readonly Func<bool> _isScoped;
|
||||
private readonly IFileSystem _innerFileSystem;
|
||||
|
||||
@@ -6,65 +6,7 @@ namespace Umbraco.Core.IO
|
||||
//all paths has a starting but no trailing /
|
||||
public class SystemDirectories
|
||||
{
|
||||
private static IIOHelper IOHelper => Current.Factory.GetInstance<IIOHelper>();
|
||||
|
||||
public static string Bin => "~/bin";
|
||||
|
||||
public static string Config => "~/config";
|
||||
|
||||
public static string Data => "~/App_Data";
|
||||
|
||||
public static string TempData => Data + "/TEMP";
|
||||
|
||||
public static string TempFileUploads => TempData + "/FileUploads";
|
||||
|
||||
public static string TempImageUploads => TempFileUploads + "/rte";
|
||||
|
||||
public static string Install => "~/install";
|
||||
|
||||
public static string AppCode => "~/App_Code";
|
||||
|
||||
public static string AppPlugins => "~/App_Plugins";
|
||||
|
||||
public static string MvcViews => "~/Views";
|
||||
|
||||
public static string PartialViews => MvcViews + "/Partials/";
|
||||
|
||||
public static string MacroPartials => MvcViews + "/MacroPartials/";
|
||||
|
||||
public static string Media => IOHelper.ReturnPath("umbracoMediaPath", "~/media");
|
||||
|
||||
public static string Scripts => IOHelper.ReturnPath("umbracoScriptsPath", "~/scripts");
|
||||
|
||||
public static string Css => IOHelper.ReturnPath("umbracoCssPath", "~/css");
|
||||
|
||||
public static string Umbraco => IOHelper.ReturnPath("umbracoPath", "~/umbraco");
|
||||
|
||||
public static string Packages => Data + "/packages";
|
||||
|
||||
public static string Preview => Data + "/preview";
|
||||
|
||||
private static string _root;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root path of the application
|
||||
/// </summary>
|
||||
public static string Root
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_root != null) return _root;
|
||||
|
||||
var appPath = HttpRuntime.AppDomainAppVirtualPath;
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
if (appPath == null || appPath == "/") appPath = string.Empty;
|
||||
|
||||
_root = appPath;
|
||||
|
||||
return _root;
|
||||
}
|
||||
//Only required for unit tests
|
||||
internal set => _root = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.IO;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
public class SystemFiles
|
||||
{
|
||||
public static string TinyMceConfig => SystemDirectories.Config + "/tinyMceConfig.config";
|
||||
public static string TinyMceConfig => Constants.SystemDirectories.Config + "/tinyMceConfig.config";
|
||||
|
||||
// TODO: Kill this off we don't have umbraco.config XML cache we now have NuCache
|
||||
public static string GetContentCacheXml(IGlobalSettings globalSettings)
|
||||
|
||||
Reference in New Issue
Block a user