Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        private static string Normalize(string path, PathAttributes attributes)
        {
            if (!string.IsNullOrEmpty(path))
            {
                path = "/" + path;

                if ((attributes & PathAttributes.File) != PathAttributes.File)
                {
                    path += "/";
                }
            }

            return(path);
        }
Ejemplo n.º 3
0
        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;
        }