If 'path' is relative, it is rooted at 'root'. Otherwise, it's unchanged.
358390
def root (path, root):
    
    if os.path.isabs (path):
        return path
    else:
        return os.path.join (root, path)
948899
def _to_relative_path(cls, parent_repo, path):
        """"""
        path = to_native_path_linux(path)
        if path.endswith('/'):
            path = path[:-1]
        # END handle trailing slash

        if osp.isabs(path):
            working_tree_linux = to_native_path_linux(parent_repo.working_tree_dir)
            if not path.startswith(working_tree_linux):
                raise ValueError("Submodule checkout path '%s' needs to be within the parents repository at '%s'"
                                 % (working_tree_linux, path))
            path = path[len(working_tree_linux.rstrip('/')) + 1:]
            if not path:
                raise ValueError("Absolute submodule path '%s' didn't yield a valid relative path" % path)
            # end verify converted relative path makes sense
        # end convert to a relative path

        return path
885701
def get_absolute_path(cls, roots, path):
        
        for root in roots:
            abspath = os.path.abspath(os.path.join(root, path))
            if abspath.startswith(root) and os.path.exists(abspath):
                return abspath
        # XXX TODO
        return 'file-not-found'
140838
private boolean isTabRootLevel(String path) {

        path = path.substring(1);
        if (!path.contains("/")) {
            return true;
        }
        if (m_tabInfos != null) {
            for (CmsTabInfo info : m_tabInfos) {
                if (info.isCollapsed()
                    && path.startsWith(info.getStartName())
                    && !path.substring(info.getStartName().length() + 1).contains("/")) {
                    return true;
                }
            }
        }
        return false;
    }
1310490
function ensureRelative(outputDir, p) {
    if (path.isAbsolute(p)) {
        return path.relative(outputDir, p);
    } else {
        return p;
    }
}
598728
public static String relativePath(String base,
                                      String pathSpec,
                                      String path )
    {
        String info=pathInfo(pathSpec,path);
        if (info==null)
            info=path;

        if( info.startsWith( "./"))
            info = info.substring( 2);
        if( base.endsWith( "/"))
            if( info.startsWith( "/"))
                path = base + info.substring(1);
            else
                path = base + info;
        else
            if( info.startsWith( "/"))
                path = base + info;
            else
                path = base + "/" + info;
        return path;
    }
478315
public static boolean hasRoot(String path, String root) {
        String p = cleanPath(path);
        String r = cleanPath(root);
        return p.equals(r)
               || r.equals(cleanPath(ROOT.getPath()))
               || p.startsWith(r + SEPARATOR);
    }
1261954
def relative_to_local_path(path)
      if path && path.length > 0
        case_insensitive_join(local_path, path)
      else
        case_insensitive_resolve(local_path)
      end
    end
1160015
def resolve_path(root, path):
  """"""
  path = parse_path(path)

  parent = root

  for part in path[:-1]:
    parent = get_child(parent, rfc_6901_replace(part))

  return (parent, rfc_6901_replace(path[-1]))
344158
function(root, path)
	{
		var parent = root;
		
		if (path != null)
		{
			var tokens = path.split(mxCellPath.PATH_SEPARATOR);
			
			for (var i=0; i<tokens.length; i++)
			{
				parent = parent.getChildAt(parseInt(tokens[i]));
			}
		}
		
		return parent;
	}
308071
def root_dir(relpath)
      r = relpath.match(%r(^[/]?.+?[/$]))
      return relpath if r.nil?
      r[0] || relpath
    end
895086
def relative_path(self, filepath, basepath=None):
        
        if basepath is None:
            basepath = self.basedir
        if not basepath:
            return filepath
        if filepath.startswith(basepath):
            rel = filepath[len(basepath):]
        if rel and rel[0] == os.sep:
            rel = rel[1:]
        return rel
1343983
def get_relative_path(self, root):
        
        if self.path == root:
            return ''
        ancestors = self.ancestors(stop=root)
        return functools.reduce(lambda f, p: Folder(p.name).child(f),
                                ancestors,
                                self.name)
672849
function(root, path) {
				if (path.indexOf(this.SEPARATOR) === 0) {
					root = this.rootNode;
					path = path.substring(1);
				} else {
					if (!root) {
						if (!this.currentDirectory) {
							/* no node to resolve the path in terms of */
							return null;
						}
						root = this.currentDirectory;
					}
				}
				var segments = path.substring(0, path.lastIndexOf(this.SEPARATOR)).split(this.SEPARATOR);
				var result = root;
				for (var i = 0; i < segments.length; i++) {
					if (segments[i].length > 0) {
						result = this.getChild(result, segments[i]);
						if (!result || !result.Directory) {
							/* non-existent directory */
							return null;
						}
					}
				}

				/*
				 * If the full path represents a directory then initiate the
				 * retrieval of its full node info and children.
				 */
				var lastSegment = path.substring(path.lastIndexOf(this.SEPARATOR) + 1);
				var child = this.getChild(result, lastSegment);
				if (child) {
					this._retrieveNode(child);
				}

				if (!result.Children) {
					this._retrieveNode(result);
				}
				return result;
			}
1138936
function targetPath(fromPath, basePath, targetDirectory) {
  // console.log('targetPath:fromPath: ' + fromPath);
  // console.log('targetPath:basePath: ' + basePath);
  // console.log('targetPath:targetDirectory: ' + targetDirectory);
  var relativePath = path.relative(basePath, fromPath);
  // console.log('targetPath:relativePath: ' + relativePath);
  // console.log('targetPath: ' + path.resolve(targetDirectory, relativePath));
  return path.resolve(targetDirectory, relativePath);
}
1189572
def is_root_path(self, filename):
        """"""
        test_filename = filename + '/'
        for root_dir in self.root_dirs:
            if test_filename.startswith(root_dir):
                return True
        return False
1010797
def get_root_path():
    """"""
    return os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir))