make a relative path from source to target
430769
function makeRelPath(inSource, inTarget) {
	// node 0.5 has this nice thing, 0.4 does not
	if (path.relative) {
		return path.relative(inSource, inTarget);
	}
	var s,t;
	s = pathSplit(path.resolve(inSource));
	t = pathSplit(path.resolve(inTarget));
	while (s.length && s[0] === t[0]){
		s.shift();
		t.shift();
	}
	for(var i = 0, l = s.length; i < l; i++) {
		t.unshift("..");
	}
	return path.join.apply(null, t);
}
597686
def set_path(self, path):
        ''''''
        self._path = path
        return self._listitem.setPath(path)
1343053
def _merge_relative_path(dst_path, rel_path):
  """"""
  # Convert rel_path to be relative and normalize it to remove ".", "..", "//",
  # which are valid directories in fileystems like "gs://".
  norm_rel_path = os.path.normpath(rel_path.lstrip("/"))

  if norm_rel_path == ".":
    return dst_path

  # Check that the norm rel path does not starts with "..".
  if norm_rel_path.startswith(".."):
    raise ValueError("Relative path %r is invalid." % rel_path)

  merged = os.path.join(dst_path, norm_rel_path)

  # After merging verify that the merged path keeps the original dst_path.
  if not merged.startswith(dst_path):
    raise ValueError("Relative path %r is invalid. Failed to merge with %r." % (
        rel_path, dst_path))
  return merged
235710
function mkdirIfNotExists(relativePath) {
    const dir = path.join(__dirname, relativePath);
    let stat;
    try {
        stat = fs.statSync(dir);
    } catch (e) {
        fs.mkdirSync(dir);
    }
}
1344901
def link(source_path):
    """"""
    if not os.path.isfile(source_path):
        raise SourceNotFound(source_path)
    with open(source_path, 'r') as f:
        content = f.read()
    block_map = BlockMap()  # The map will be populated with the following function call.
    all_block = convert_lines_to_block(
            content.splitlines(), block_map, LinkStack(source_path), source_path)
    return all_block, block_map.get_variables()
1169082
function relativePath(file1, file2) {
  var file1Dirname = path.dirname(file1);
  var file2Dirname = path.dirname(file2);

  if (file1Dirname !== file2Dirname) {
    return path.relative(file1Dirname, file2Dirname);
  }
  return '';
}
1320068
def rellink (source, dest):
    
    from os.path import isabs, dirname, relpath, abspath

    if isabs (source):
        os.symlink (source, dest)
    elif isabs (dest):
        os.symlink (abspath (source), dest)
    else:
        os.symlink (relpath (source, dirname (dest)), dest)
108337
def make_path_func (*baseparts):
    """"""
    from os.path import join
    base = join (*baseparts)
    def path_func (*args):
        return join (base, *args)
    return path_func
565952
def get_gopath(self, target):
    """"""
    return os.path.join(self.workdir, target.id)
144729
def symlink(target, linkname):
    
    target = os.path.abspath(target)
    linkname = os.path.abspath(linkname)
    if not os.path.exists(target):
        raise ValueError("target {} not found".format(target))

    link_dir = os.path.dirname(linkname)
    if not os.path.exists(link_dir):
        os.makedirs(link_dir)

    run(['ln', '-s', '-f', target, linkname])
    return linkname
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
1186183
def relative_path_from(start, dest)
      start, dest = Pathname.new(start), Pathname.new(dest)
      start = start.dirname unless start.directory?
      dest.relative_path_from(start).to_s
    end
98936
function buildRelativePath(from, to) {
    from = core_1.normalize(from);
    to = core_1.normalize(to);
    // Convert to arrays.
    const fromParts = from.split('/');
    const toParts = to.split('/');
    // Remove file names (preserving destination)
    fromParts.pop();
    const toFileName = toParts.pop();
    const relativePath = core_1.relative(core_1.normalize(fromParts.join('/')), core_1.normalize(toParts.join('/')));
    let pathPrefix = '';
    // Set the path prefix for same dir or child dir, parent dir starts with `..`
    if (!relativePath) {
        pathPrefix = '.';
    }
    else if (!relativePath.startsWith('.')) {
        pathPrefix = `./`;
    }
    if (pathPrefix && !pathPrefix.endsWith('/')) {
        pathPrefix += '/';
    }
    return pathPrefix + (relativePath ? relativePath + '/' : '') + toFileName;
}
80123
def relative_path(path)
      base_dir = Dir.pwd

      return path[(base_dir.length + 1)..-1] if path.start_with?(base_dir)

      path_name = Pathname.new(File.expand_path(path))
      path_name.relative_path_from(Pathname.new(base_dir)).to_s
    end
1184211
def dest_fpath(self, source_fpath: str) -> str:
        """"""
        relative_fpath = os.path.join(*source_fpath.split(os.sep)[1:])
        relative_dirpath = os.path.dirname(relative_fpath)

        source_fname = relative_fpath.split(os.sep)[-1]
        base_fname = source_fname.split('.')[0]
        dest_fname = f'{base_fname}.json'

        return os.path.join(self.dest_dir, relative_dirpath, dest_fname)
798055
def symlink(source, destination):
    """"""
    log("Symlinking {} as {}".format(source, destination))
    cmd = [
        'ln',
        '-sf',
        source,
        destination,
    ]
    subprocess.check_call(cmd)
1240902
def cargo_target_path(target, *path_components)
      target_base = ENV.fetch('CARGO_TARGET_DIR', File.join(rust_toplevel_dir, 'target'))
      File.join(target_base, target, *path_components)
    end