public NormalizedPath Combine(string path, PathAttributes attributes) { if (IsFile()) { throw new ArgumentException("You cannot add path to path with extension"); } //combinedPath may contain "//" but it will be replaced to "/" in the constructor. var combinedPath = GetNormalPath() + path; return(new NormalizedPath(combinedPath, attributes)); }
private static string Normalize(string path, PathAttributes attributes) { if (!string.IsNullOrEmpty(path)) { path = "/" + path; if ((attributes & PathAttributes.File) != PathAttributes.File) { path += "/"; } } return(path); }
public NormalizedPath(string path, PathAttributes attributes = PathAttributes.File) { var normalizedPath = path.Replace("\\", "/"); while (normalizedPath.Contains("//")) { normalizedPath = normalizedPath.Replace("//", "/"); } //---------SpecChar restriction--------- //normalizedPath = Regex.Replace(normalizedPath, @"[^\w!\-.*'()\/ ?]", "?", RegexOptions.None); normalizedPath = normalizedPath.Trim(' ', '/'); _basePath = normalizedPath; _attributes = attributes; }