Ejemplo n.º 1
0
        protected override string NormalizeRelativePath(string path, string basePath)
        {
            var normPath = new Path(path).NormalizeSlashes();
            var normBase = new Path(basePath).NormalizeSlashes();
            if (!normPath.StartsWith(normBase))
            {
                var ex = new PSArgumentException("Path is outside of base path!", "PathOutsideBasePath",
                    ErrorCategory.InvalidArgument);
                WriteError(ex.ErrorRecord);
                return null;
            }

            return new Path(path.Substring(basePath.Length)).TrimStartSlash().ToString();
        }
Ejemplo n.º 2
0
        protected override Path GetParentPath(Path path, Path root)
        {
            Path parentPath = base.GetParentPath(path, root);

            // TODO: deal with UNC
            if (!path.StartsWith("\\\\")) // UNC?
            {
                parentPath = MakeSlashedPath(parentPath);
            }
            return parentPath;
        }