提交 fe918b3b 编写于 作者: X Xavier Noria

simplifies the implementation of existing parent

上级 4e1cff0e
......@@ -126,19 +126,8 @@ def longest_common_subpath(paths)
# Returns the deepest existing ascendant, which could be the argument itself.
def existing_parent(dir)
loop do
if dir.directory?
break dir
else
if dir.root?
# Edge case in which not even the root exists. For example, Windows
# paths could have a non-existing drive letter. Since the parent of
# root is root, we need to break to prevent an infinite loop.
break
else
dir = dir.parent
end
end
dir.ascend do |ascendant|
break ascendant if ascendant.directory?
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册