Esempio n. 1
0
        public AbsoluteFolderPath GetSiblingFolderPath(string folderName)
        {
            NameHelper.EnsureValidFilenameCharacters(folderName);
            // cant from root, can elsewhere
            if (Parts.Count == 1)
            {
                throw PathExceptions.UndefinedSiblingFor(RootValue);
            }
            var parts = Parts.CloneSublist(Parts.Count - 1);

            parts.Add(folderName);
            return(new AbsoluteFolderPath(parts));
        }
Esempio n. 2
0
        protected BasePath(PathType pathType, bool isFolder, string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (!isFolder)
            {
                char lastChar = path[path.Length - 1];
                if (lastChar == '\\' || lastChar == '/')
                {
                    throw new Exception("No filename specified: " + path);
                }
            }
            _isFolder = isFolder;

            NameHelper.EnsureValidPathCharacters(path);

            RootMatch rootMatch = RootMatch.FindRoot(path);

            if (rootMatch == null)
            {
                throw new Exception("Unsupported path: " + path);
            }
            if (pathType.IsRelative())
            {
                if (!rootMatch.PathType.IsRelative())
                {
                    throw PathExceptions.NotARelativePath(path);
                }
            }
            else
            {
                if (rootMatch.PathType.IsRelative())
                {
                    throw PathExceptions.NotAnAbsolutePath(path);
                }
            }
            _pathType = rootMatch.PathType;
            _parts    = rootMatch.Parts;
            Segment(rootMatch.ItemPath);
            CleanUpRoute();
        }