2020-11-18 04:49:03 -08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
2021-02-18 11:06:02 +01:00
|
|
|
|
using Umbraco.Cms.Core.Hosting;
|
2020-11-18 04:49:03 -08:00
|
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
|
namespace Umbraco.Cms.Core.IO
|
2020-11-18 04:49:03 -08:00
|
|
|
|
{
|
|
|
|
|
|
public class IOHelperLinux : IOHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
public IOHelperLinux(IHostingEnvironment hostingEnvironment) : base(hostingEnvironment)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool IsPathFullyQualified(string path) => Path.IsPathRooted(path);
|
|
|
|
|
|
|
|
|
|
|
|
public override bool PathStartsWith(string path, string root, params char[] separators)
|
|
|
|
|
|
{
|
|
|
|
|
|
// either it is identical to root,
|
|
|
|
|
|
// or it is root + separator + anything
|
|
|
|
|
|
|
|
|
|
|
|
if (separators == null || separators.Length == 0) separators = new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
|
|
|
|
|
|
if (!path.StartsWith(root, StringComparison.Ordinal)) return false;
|
|
|
|
|
|
if (path.Length == root.Length) return true;
|
|
|
|
|
|
if (path.Length < root.Length) return false;
|
|
|
|
|
|
return separators.Contains(path[root.Length]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|