class Build::Files::Path

def self.shortest_path(path, root)

Return the shortest relative path to get to path from root. Root should be a directory with which you are computing the relative path.
def self.shortest_path(path, root)
	path_components = Path.components(path)
	root_components = Path.components(root)
	
	# Find the common prefix:
	i = prefix_length(path_components, root_components) || 0
	
	# The difference between the root path and the required path, taking into account the common prefix:
	up = root_components.size - i
	
	return File.join([".."] * up + path_components[i..-1])
end